#!/bin/sh set -e # change this to the location where you put the .dl file: FIRMWARE="/root/hplj1018.dl" DEVICE=$(uci get p910nd.@p910nd[0].device) LOGFILE=/var/log/hp PROD_ID="3f0/4117/100" DEV_TYPE="usb_device" daemon_restart() { echo "$(date) : (Re)Starting print daemon" >> $LOGFILE /etc/init.d/p910nd restart } daemon_stop() { echo "$(date) : Stopping print daemon" >> $LOGFILE /etc/init.d/p910nd stop } send_firmware() { echo "$(date) : Sending firmware to printer" >> $LOGFILE cat $FIRMWARE > $DEVICE echo "$(date) : done." >> $LOGFILE } if [ "$PRODUCT" = "${PROD_ID}" ]; then case "$ACTION" in add) sleep 1 # Check whether dev is character type if [ -c $DEVICE ]; then # Check whether the hotplug devtype is usb_device if [ "$DEVTYPE" = "${DEV_TYPE}" ]; then send_firmware daemon_restart fi fi ;; remove) daemon_stop ;; #Also available: bind) ;; esac fi