diff options
Diffstat (limited to 'packages/slugos-init/files/initscripts/zleds')
| -rw-r--r-- | packages/slugos-init/files/initscripts/zleds | 77 |
1 files changed, 13 insertions, 64 deletions
diff --git a/packages/slugos-init/files/initscripts/zleds b/packages/slugos-init/files/initscripts/zleds index b6d2f1600b..f5bd703b65 100644 --- a/packages/slugos-init/files/initscripts/zleds +++ b/packages/slugos-init/files/initscripts/zleds @@ -4,76 +4,25 @@ # transition. It is the first 'stop' script and the last 'start' # script. # -# 'stop' sets the correct colour power LED to flash between the -# two colours of the previous and next runlevel. -# 'start' sets the LED to steady +# 'stop' indicates the start of a runlevel change +# 'start' at the end of the runlevel change - we are in the new +# runlevel. # -# The 'ready' led is used for the indication of state, except that -# if a 'status' led is used ready+status is set in place of !ready. -# -# For NSLU2: -# -# 'amber' is used for run levels S (from /linuxrc), 0 (halt), -# 1 (single user) and 6 (reboot). halt and reboot do not -# terminate therefore the LED remains flashing until the -# kernel terminates. -# -# 'green' is used for run levels 2-5 - the normal user run levels. -# -# state outputs 's' (for 'system') or 'u' (for user) to distinguish -# the required colours. -# -# NOTE: this will change +# state outputs 'system', 'user' etc according the the nature of +# the runlevel it is passed (the *new* runlevel is used). state(){ case "$1" in - S|0|1|6) echo s;; - 2|3|4|5) echo u;; - N) echo s;; + S|N) echo system;; + 0|6) echo shutdown;; + 1) echo singleuser;; + 2|3|4|5) echo user;; *) echo "led change: $runlevel: runlevel unknown" >&2 - echo s;; + echo system;; esac } -# Make the named LED do something -flash(){ - echo timer >/sys/class/leds/"$1"/trigger - echo 200 >/sys/class/leds/"$1"/frequency -} -on(){ - echo none >/sys/class/leds/"$1"/trigger - echo 100 >/sys/class/leds/"$1"/brightness -} -off(){ - echo none >/sys/class/leds/"$1"/trigger - echo 0 >/sys/class/leds/"$1"/brightness -} - -test -d /sys/class/leds/ready && case "$1" in -start) if test -d /sys/class/leds/status - then - case "$(state "$runlevel")" in - s) on status - on ready;; - u) off status - on ready;; - esac - else - on ready - fi;; -stop) if test -d /sys/class/leds/status - then - case "$(state "$previous")$(state "$runlevel")" in - ss) flash status - flash ready;; - su|us) flash status - on ready;; - uu) off status - flash ready;; - esac - else - flash ready - fi;; +case "$1" in +start) leds "$(state "$runlevel")";; +stop) leds boot "$(state "$runlevel")";; *) echo "led change: $1: command ignored" >&2;; esac - -exit 0 |
