Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # WARNING: I have very basic/limited unix/linux
- # scripting abilities.
- # BEGIN HP 1020 PRINTER SCRIPT
- echo "`date` ----------------BEGIN PRINTER SCRIPT `date` --------------" >> /var/log/hp
- if [ "$ACTION" = "add" ]
- then
- # OK So the action is what we expected
- echo "`date` : Action is the expected result: '$ACTION'" >> /var/log/hp
- # Lets validate the product ID
- HPPRODUCTID="3f0/2b17/100"
- #HPPRODUCTID=03f0/4117/100
- echo "`date` : HP Product ID set to '$HPPRODUCTID'" >> /var/log/hp
- if [ "$PRODUCT" = "$HPPRODUCTID" ]
- then
- # OK So the product ID is what we expected
- echo "`date` : Product is the expected result: '$PRODUCT'" >> /var/log/hp
- # OK So the action is what we expected
- echo "`date` : Action is the expected result: '$ACTION'" >> /var/log/hp
- # Adding a pause to make sure its fully initialized before we try to upload firmware
- printersleep=5
- echo "`date` : Sleeping $printersleep seconds before preparing to upload firmware to printer..." >> /var/log/hp
- sleep $printersleep
- echo "`date` : Finished sleeping $printersleep seconds; Continuing with firmware upload." >> /var/log/hp
- # Set path to HP firmware file
- HPFIRMWARE="/usr/syno/hotplug/firmware/sihp1020.dl"
- echo "`date` : Firmware path set to: '$HPFIRMWARE'" >> /var/log/hp
- # Lets make sure the firmware file not only actually
- # exists in the path above, but has a size greater than zero.
- # Alternatively we could use
- # -e = simply check if the file exists
- # -a = same as -e but has been deprecated and use discouraged
- # -f = make sure its a regular file, not a directory or device file
- # -r = make sure file is readable
- if [ -s "$HPFIRMWARE" ]
- then
- # OK So the Firmware is present!
- echo "`date` : Firmware file '$HPFIRMWARE' is present" >> /var/log/hp
- # At this point all should be fine!
- echo "`date` : Sending firmware to printer..." >> /var/log/hp
- cat $HPFIRMWARE > /dev/usb/lp0
- echo "`date` : Finished sending firmeware to printer!" >> /var/log/hp
- #echo "`date` ----------------END PRINTER SCRIPT `date` --------------" >> /var/log/hp
- else
- # Whoops - the firmware is missing it seems!
- echo "`date` : ERROR: Missing Firmware File: $HPFIRMWARE" >> /var/log/hp
- echo "`date` : Download firmware: http://oleg.wl500g.info/hplj/sihp1020.dl/ " >> /var/log/hp
- #echo "`date` ----------------END PRINTER SCRIPT `date` --------------" >> /var/log/hp
- fi
- else
- # The device/product ID is different than we anticipated
- # Check the log to see what it is
- echo "`date` : WARN: Product is not '$HPPRODUCTID', its '$PRODUCT'" >> /var/log/hp
- fi
- else
- # The action is different than we anticipated
- # Check the log to see what it is
- echo "`date` : WARN: Action is not add, its '$ACTION'" >> /var/log/hp
- fi
- echo "`date` ----------------END PRINTER SCRIPT `date` --------------" >> /var/log/hp
Advertisement
Add Comment
Please, Sign In to add comment