#!/bin/sh USBDIR="`dirname $0`" SYSLEDPATH_4_0_IBTS="/sys/class/leds/yellow:debug" SYSLEDPATH_4_0_IFEMTO="/sys/class/leds/led1:red:power" SYSLEDPATH="/sys/class/leds/status" led_path="/do/not/exist" if [ -e "${SYSLEDPATH}" ]; then led_path="${SYSLEDPATH}" elif [ -e "${SYSLEDPATH_4_0_IBTS}" ]; then led_path="${SYSLEDPATH_4_0_IBTS}" elif [ -e "${SYSLEDPATH_4_0_IFEMTO}" ]; then led_path="${SYSLEDPATH_4_0_IFEMTO}" fi # # Set default led behavior # $1: trigger # # if trigger = timer : $2 = delay_on, $3 = delay_off # set_led() { trigger="${1}" on="$2" off="$3" if [ -e "${led_path}" ]; then echo $trigger > "${led_path}/trigger" case "$trigger" in "timer") echo ${on:=500} > "${led_path}/delay_on" echo ${off:=500} > "${led_path}/delay_off" ;; "none") echo ${on:=0} > "${led_path}/brightness" ;; *) # Nothing to do ;; esac fi } deploy_packages() { mkdir -p /user/.updates for pkg in ${USBDIR}/*.ipk do cp ${pkg} /user/.updates/ done sync } # # Force the system to put the packages immediately in backup # force_backup() { touch /user/.updates/force_backup sync } # # Trigger update and reboot in $1 minutes (or 'now') # trigger_update() { REBOOT_TIMEOUT=$1 kerosd -u [ ${REBOOT_TIMEOUT:=0} -ne 0 ] && shutdown -r ${REBOOT_TIMEOUT} } ##################### # MAIN ##################### # Set led On set_led none 1 # Deploy packages deploy_packages # Trigger Update trigger_update # Optional: Force the system to put the packages immediately in backup #force_backup # Prepare reboot after USB unplug cat > /tmp/usbkey_remove << EOF # Switch off Led echo "none" > ${led_path}/trigger # Reboot Now to get Update reboot EOF # All is right, make Led blinking fast to notify User set_led "timer" 100 100