batch.txt 699 B

123456789101112131415161718
  1. #!/bin/bash
  2. EEPROMHex='eeprom-content.hex' # File used for manufacturer brand
  3. Product='Block Erupter Sapphire'
  4. SerialPrefix='Foo-' # Prepended before 8-digit serial number
  5. SerialNoFile='last-serialno' # File holds the last allocated serial number
  6. if ! [ -e "${SerialNoFile}" ]; then
  7. echo "WARNING: Initializing ${SerialNoFile} file (this should only happen ONCE EVER)" >&2
  8. echo '10000000' > "${SerialNoFile}"
  9. fi
  10. i="$(<"${SerialNoFile}")"
  11. for dev in $(lsusb | perl -nle 'm/(\d{3}).*?(\d{3}).*CP210x/ && print "$1/$2"'); do
  12. let ++i
  13. echo "$i" >"${SerialNoFile}"
  14. ./cp210x-program -m $dev -w -F "$EEPROMHex" \
  15. --set-product-string="$Product" \
  16. --set-serial-number "${SerialPrefix}$i"
  17. done