tags 507545 + patch
thanks
I had a look at the handling of the leds-blinking init.d scripts after
discussing this with Joey Hess at debconf, and here is a proposal
rewriting the build system to use update-rc.d in a more traditional
way.
It installs two unique init.d scripts in each runlevel, one at the
start (leds-lvl#) and one at the end (zleds-stop-lvl#), taking care of
the blinking to be done during the runlevel. The leds_startup script
should no longer be needed, as a start script is used in the start of
each runlevel, and thus no trick is needed in the rcS.d -> rc#.d
transition.
I also added proposed LSB headers to the other init.d scripts, and
rewrite all scripts to use the argument passed into the script.
Please test to see if I made any mistakes.
diff -ur -N nslu2-utils-20080403-before/debian/nslu2-rtc.init
nslu2-utils-20080403/debian/nslu2-rtc.init
--- nslu2-utils-20080403-before/debian/nslu2-rtc.init 2008-06-22
12:37:55.000000000 +0200
+++ nslu2-utils-20080403/debian/nslu2-rtc.init 2009-07-25 10:35:53.000000000
+0200
@@ -1,2 +1,20 @@
#!/bin/sh
-modprobe rtc-dev
+### BEGIN INIT INFO
+# Provides: nslu2-rtc
+# Required-Start:
+# Required-Stop:
+# Should-Start: udev
+# X-Start-Before: hwclock
+# Default-Start: S
+# Default-Stop:
+# Short-Description: Load kernel module for the RTC device interface.
+# Description: Load kernel module for the RTC device interface.
+### END INIT INFO
+
+case "$1" in
+ start)
+ modprobe rtc-dev
+ ;;
+ stop|restart|force-reload|*)
+ ;;
+esac
diff -ur -N nslu2-utils-20080403-before/debian/rules
nslu2-utils-20080403/debian/rules
--- nslu2-utils-20080403-before/debian/rules 2008-06-22 12:37:55.000000000
+0200
+++ nslu2-utils-20080403/debian/rules 2009-07-25 10:56:40.000000000 +0200
@@ -17,16 +17,25 @@
dh_install initramfs-tools usr/share
dh_install files/leds usr/bin
dh_install nslu2-flashkernel usr/sbin
- dh_install files/initscripts/zleds files/initscripts/rmrecovery \
- files/initscripts/leds_startup etc/init.d
+ dh_install files/initscripts/rmrecovery etc/init.d
+ set -e ; tmpdir=debian/nslu2-utils; for runlvl in S 1 2 3 4 5 ; do \
+ startscript="etc/init.d/leds-lvl$$runlvl" ; \
+ stopscript="etc/init.d/zleds-stop-lvl$$runlvl" ; \
+ cp files/initscripts/leds $$tmpdir/$$startscript ; \
+ cp files/initscripts/zleds-stop $$tmpdir/$$stopscript ; \
+ for file in $$startscript $$stopscript ; do \
+ sed s/@LVL@/$$runlvl/ < $$tmpdir/$$file > foo \
+ && mv foo $$tmpdir/$$file ; \
+ done ; \
+ dh_installinit --no-start --onlyscripts \
+ --name=leds-lvl$$runlvl -- start 1 $$runlvl . ; \
+ dh_installinit --no-start --onlyscripts \
+ --name=zleds-stop-lvl$$runlvl -- start 99 $$runlvl . ; \
+ done
dh_installdirs etc/default
cp files/initscripts/rmrecovery.default
debian/nslu2-utils/etc/default/rmrecovery
- dh_installinit --no-start --onlyscripts --name=zleds \
- -- start 99 S 1 2 3 4 5 . stop 5 0 1 2 3 4 5 6 .
dh_installinit --no-start --onlyscripts --name=rmrecovery \
-- start 99 1 2 3 4 5 .
- dh_installinit --no-start --onlyscripts --name=leds_startup \
- -- start 1 1 2 3 4 5 .
dh_installinit --no-start --name=nslu2-rtc \
-- start 10 S .
dh_installudev --name=nslu2-rtc
diff -ur -N nslu2-utils-20080403-before/files/initscripts/leds
nslu2-utils-20080403/files/initscripts/leds
--- nslu2-utils-20080403-before/files/initscripts/leds 1970-01-01
01:00:00.000000000 +0100
+++ nslu2-utils-20080403/files/initscripts/leds 2009-07-25 10:34:57.000000000
+0200
@@ -0,0 +1,53 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: le...@lvl@
+# Required-Start: $local_fs
+# Required-Stop:
+# Default-Start: S 1 2 3 4 5
+# Default-Stop:
+# Short-Description: Start led blinking
+# Description: This script is executed at the start of
+# each run-level transition. It should be
+# the first 'start' script.
+### END INIT INFO
+#
+# 'start' indicates the start of a runlevel change
+# 'stop' at the end of the runlevel change - we are in the new
+# runlevel.
+#
+# 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|N) echo system;;
+ 0|6) echo shutdown;;
+ 1) echo singleuser;;
+ 2|3|4|5) echo user;;
+ *) echo "led change: $runlevel: runlevel unknown" >&2
+ echo system;;
+ esac
+}
+
+# trumpet "beeps" an announcement on systems with such support.
+l=120 # Long beep time
+s=40 # Try to keep a 3:1 ratio
+trumpet(){
+ case "$1" in
+ k) leds beep -l $l; leds beep -l $s; leds beep -l $l;;
+ n) leds beep -l $l; leds beep -l $s;;
+ *) leds beep;;
+ esac
+}
+
+case "$1" in
+stop) leds "$(state "$runlevel")"
+ if [ "$(state "$runlevel")" = "user" ]; then
+ trumpet "k"
+ fi
+ ;;
+start) leds boot "$(state "$runlevel")"
+ ;;
+restart|force-reload|*)
+ echo "led change: $1: command ignored" >&2
+ ;;
+esac
diff -ur -N nslu2-utils-20080403-before/files/initscripts/leds_startup
nslu2-utils-20080403/files/initscripts/leds_startup
--- nslu2-utils-20080403-before/files/initscripts/leds_startup 2008-06-22
12:37:56.000000000 +0200
+++ nslu2-utils-20080403/files/initscripts/leds_startup 1970-01-01
01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-#!/bin/sh
-# Bug fix: during the initial boot sysvinit sets PREVLEVEL to
-# nothing in rcS and to 'N' in the transition from rcS to the
-# user state. This script runs on that transition and, if
-# the PREVLEVEL is 'N', sets 'previous' (as in /etc/init.d/rc)
-# to 'S'
-if test "$PREVLEVEL" = N
-then
- previous=S exec /etc/init.d/zleds stop
-fi
-exit 0
diff -ur -N nslu2-utils-20080403-before/files/initscripts/rmrecovery
nslu2-utils-20080403/files/initscripts/rmrecovery
--- nslu2-utils-20080403-before/files/initscripts/rmrecovery 2008-06-22
12:37:56.000000000 +0200
+++ nslu2-utils-20080403/files/initscripts/rmrecovery 2009-07-25
10:46:52.000000000 +0200
@@ -1,7 +1,29 @@
#!/bin/sh
-# Run to remove /.recovery if the boot seems to have succeeded
-RMRECOVERY=yes
-. /etc/default/rmrecovery || true
-if [ "$RMRECOVERY" != no ]; then
- rm -f /.recovery
-fi
+### BEGIN INIT INFO
+# Provides: rmrecovery
+# Required-Start: $remote_fs $all
+# Required-Stop:
+# Default-Start: 1 2 3 4 5
+# Default-Stop:
+# Short-Description: Remove OpenSlug recovery file on successfull boot
+# Description: If instead of booting using the Debian initrd, you are
+# using the OpenSlug firmware to boot Debian from a
+# USB drive on your slug, then it creates a
+# /.recovery file during boot, and unless this file
+# is removed, the next boot will be back into the
+# openslug system. This script removes this file on
+# each boot, so that Debian will boot each time.
+### END INIT INFO
+
+case "$1" in
+ start)
+ # Run to remove /.recovery if the boot seems to have succeeded
+ RMRECOVERY=yes
+ . /etc/default/rmrecovery || true
+ if [ "$RMRECOVERY" != no ]; then
+ rm -f /.recovery
+ fi
+ ;;
+ stop|restart|force-reload|*)
+ ;;
+esac
diff -ur -N nslu2-utils-20080403-before/files/initscripts/zleds
nslu2-utils-20080403/files/initscripts/zleds
--- nslu2-utils-20080403-before/files/initscripts/zleds 2008-06-22
12:37:56.000000000 +0200
+++ nslu2-utils-20080403/files/initscripts/zleds 1970-01-01
01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-#!/bin/sh
-#
-# This script is executed at the start and end of each run-level
-# transition. It is the first 'stop' script and the last 'start'
-# script.
-#
-# 'stop' indicates the start of a runlevel change
-# 'start' at the end of the runlevel change - we are in the new
-# runlevel.
-#
-# 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|N) echo system;;
- 0|6) echo shutdown;;
- 1) echo singleuser;;
- 2|3|4|5) echo user;;
- *) echo "led change: $runlevel: runlevel unknown" >&2
- echo system;;
- esac
-}
-
-# trumpet "beeps" an announcement on systems with such support.
-l=120 # Long beep time
-s=40 # Try to keep a 3:1 ratio
-trumpet(){
- case "$1" in
- k) leds beep -l $l; leds beep -l $s; leds beep -l $l;;
- n) leds beep -l $l; leds beep -l $s;;
- *) leds beep;;
- esac
-}
-
-case "$1" in
-start) leds "$(state "$runlevel")"
- if [ "$(state "$runlevel")" = "user" ]; then
- trumpet "k"
- fi
- ;;
-stop) leds boot "$(state "$runlevel")"
- ;;
-*) echo "led change: $1: command ignored" >&2
- ;;
-esac
diff -ur -N nslu2-utils-20080403-before/files/initscripts/zleds-stop
nslu2-utils-20080403/files/initscripts/zleds-stop
--- nslu2-utils-20080403-before/files/initscripts/zleds-stop 1970-01-01
01:00:00.000000000 +0100
+++ nslu2-utils-20080403/files/initscripts/zleds-stop 2009-07-25
10:35:27.000000000 +0200
@@ -0,0 +1,20 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: leds-st...@lvl@
+# Required-Start: $local_fs $all
+# Required-Stop:
+# Default-Start: S 1 2 3 4 5
+# Default-Stop:
+# Short-Description: Stop led blinking
+# Description: This script is executed at the end of
+# each run-level transition. It should be
+# the last 'start' script.
+### END INIT INFO
+
+case "$1" in
+start) /etc/init.d/leds stop
+ ;;
+restart|force-reload|*)
+ echo "led change: $1: command ignored" >&2
+ ;;
+esac
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]