aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/slugos-init/files/initscripts
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/slugos-init/files/initscripts
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
downloadopenembedded-709c4d66e0b107ca606941b988bad717c0b45d9b.tar.gz
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/slugos-init/files/initscripts')
-rw-r--r--recipes/slugos-init/files/initscripts/fixfstab91
-rw-r--r--recipes/slugos-init/files/initscripts/leds_startup11
-rw-r--r--recipes/slugos-init/files/initscripts/loadmodules.sh15
-rw-r--r--recipes/slugos-init/files/initscripts/rmrecovery4
-rw-r--r--recipes/slugos-init/files/initscripts/sysconfsetup46
-rw-r--r--recipes/slugos-init/files/initscripts/syslog.buffer23
-rw-r--r--recipes/slugos-init/files/initscripts/syslog.file23
-rw-r--r--recipes/slugos-init/files/initscripts/syslog.network28
-rw-r--r--recipes/slugos-init/files/initscripts/umountinitrd.sh33
-rw-r--r--recipes/slugos-init/files/initscripts/zleds45
10 files changed, 319 insertions, 0 deletions
diff --git a/recipes/slugos-init/files/initscripts/fixfstab b/recipes/slugos-init/files/initscripts/fixfstab
new file mode 100644
index 0000000000..67116a12fd
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/fixfstab
@@ -0,0 +1,91 @@
+#!/bin/sh
+# validate /etc/fstab against the current UUID list in
+# /etc/uuid_by_partition
+#
+. /etc/default/functions
+pfile=/etc/uuid_by_partition
+
+#
+# use debug to find out what is going on
+test "$1" = start -o "$1" = debug || exit 0
+
+#
+# obtain the current list of parititions with UUIDs
+newlist="$(uuid_by_partition)"
+
+if test -r "$pfile"
+then
+ # read the old list
+ oldlist="$(cat "$pfile")"
+ #
+ # if it hasn't changed nothing need be done
+ test "$newlist" = "$oldlist" && exit 0
+ #
+ # it has changed, but this only matters if
+ # a previously existing uuid has moved, build
+ # a list of old device vs new device for every
+ # uuid which has moved
+ changedlist="$(
+ { echo "$oldlist"
+ echo "$newlist"
+ } | awk 'device[$2] == ""{device[$2] = $1}
+ device[$2] != $1{print device[$2], $1}')"
+
+ if test -n "$changedlist"
+ then
+ # at least one partition has moved, scan the
+ # current fstab to see if it has a reference
+ # to this partition
+ changedfstab="$(
+ { echo "$changedlist"
+ echo '#fstab'
+ cat /etc/fstab
+ } | awk 'BEGIN{list=1}
+ list==1 && $0=="#fstab"{list=0; continue}
+ list==1{new[$1] = $2; continue}
+ new[$1] != ""{print $1, new[$1]}')"
+
+ # if this list is not empty edit the fstab
+ if test -n "$changedfstab"
+ then
+ rm -f /tmp/fstab.$$
+ # if the edit fails then do not overwrite the old
+ # partition list - just exit with an error
+ { echo "$changedlist"
+ echo '#fstab'
+ cat /etc/fstab
+ } | awk 'BEGIN{list=1}
+ list==1 && $0=="#fstab"{list=0; continue}
+ list==1{new[$1] = $2; continue}
+ new[$1] != ""{$1 = new[$1]}
+ {print}' >/tmp/fstab.$$ || {
+ if test "$1" = start
+ then
+ logger -s "/etc/init.d/fixfstab: /tmp/fstab.$$: awk failed"
+ else
+ echo "debug: awk script failed with:" >&2
+ echo "$changedlist" >&2
+ echo "output in /tmp/fstab.$$" >&2
+ fi
+ exit 1
+ }
+
+ if test "$1" = start
+ then
+ mv /tmp/fstab.$$ /etc/fstab || {
+ logger -s "/etc/init.d/fixfstab: /tmp/fstab.$$: update failed"
+ exit 1
+ }
+ else
+ echo "debug: fstab changed:"
+ diff -u /etc/fstab /tmp/fstab.$$
+ fi
+ fi
+ fi
+fi
+
+# write the new list to the file, only if we
+# are doing something...
+test "$1" = start && echo "$newlist" >"$pfile"
+
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/leds_startup b/recipes/slugos-init/files/initscripts/leds_startup
new file mode 100644
index 0000000000..945d75bd02
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/leds_startup
@@ -0,0 +1,11 @@
+#!/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 --git a/recipes/slugos-init/files/initscripts/loadmodules.sh b/recipes/slugos-init/files/initscripts/loadmodules.sh
new file mode 100644
index 0000000000..e80f995598
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/loadmodules.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# This script is used for loading modules required by SlugOS
+# This script may not be necessary if udev is present, but is included
+# for 'backup' purposes in case udev is playing silly buggers
+
+. /etc/default/modulefunctions # Load module loading logic
+
+loadnetmods
+
+loaddiskmods
+
+loadmiscmods
+
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/rmrecovery b/recipes/slugos-init/files/initscripts/rmrecovery
new file mode 100644
index 0000000000..eec822b154
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/rmrecovery
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Run to remove /.recovery if the boot seems to have succeeded
+test -e /.recovery && rm -f /.recovery
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/sysconfsetup b/recipes/slugos-init/files/initscripts/sysconfsetup
new file mode 100644
index 0000000000..a4f9074d9c
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/sysconfsetup
@@ -0,0 +1,46 @@
+#!/bin/sh
+# This script is run once when the system first boots. Its sole
+# purpose is to create /etc/default/sysconf (the overall system
+# configuration file) and other files derived from this.
+#
+# The script runs immediately after S10checkroot.sh - this is the
+# point at which the rootfs will be mounted rw even if the kernel
+# booted with it ro.
+#
+# rm or mv the file (/etc/default/sysconf) to recreate it, run this
+# script with the reload option to overwrite the system files. The
+# configuration files described in sysconf_reload (in
+# /sbin/sysconf) will be overwritten on reload.
+#
+# start: standard startup, do a complete (auto) restore if necessary
+# reinit: always do a complete auto restore
+# reload: just reload sysconf (no config files!)
+#
+# /etc/default/functions contains useful utility functions - it's
+# in a separate file so that it can be loaded by any script
+. /etc/default/functions
+load_functions sysconf || exit 1
+#
+case "$1" in
+start) test -s /etc/default/sysconf || {
+ if sysconf_read
+ then
+ if sysconf_valid
+ then
+ sysconf_restore auto
+ else
+ sysconf_reload
+ fi
+ else
+ sysconf_default
+ sysconf_reload
+ fi
+ };;
+
+reload) test -s /etc/default/sysconf || sysconf_read || sysconf_default
+ sysconf_reload;;
+
+reinit) sysconf_restore auto;;
+
+*) ;;
+esac
diff --git a/recipes/slugos-init/files/initscripts/syslog.buffer b/recipes/slugos-init/files/initscripts/syslog.buffer
new file mode 100644
index 0000000000..9285c02946
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/syslog.buffer
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses (only) 'buffer' as the DESTINATION
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) doit=1;;
+ file) exit 0;;
+ remote) exit 0;;
+ *) echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+test -n "$doit" -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/syslog.file b/recipes/slugos-init/files/initscripts/syslog.file
new file mode 100644
index 0000000000..80ee5f0174
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/syslog.file
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses 'file' (and, optionally, buffer) as the DESTINATION
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) :;;
+ file) doit=1;;
+ remote) exit 0;;
+ *) echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+test -n "$doit" -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/syslog.network b/recipes/slugos-init/files/initscripts/syslog.network
new file mode 100644
index 0000000000..3d7f4ab8e6
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/syslog.network
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses 'remote', or doesn't use 'buffer' or 'file'
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+doneit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) doneit=1;;
+ file) doneit=1;;
+ remote) doit=1;;
+ *) doit=1
+ echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+# One of doneit or doit is set unless the DESTINATION value
+# is empty (which is probably an error), let syslog handle
+# the error.
+test \( -n "$doit" -o -z "$doneit" \) -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
diff --git a/recipes/slugos-init/files/initscripts/umountinitrd.sh b/recipes/slugos-init/files/initscripts/umountinitrd.sh
new file mode 100644
index 0000000000..93f05a00f6
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/umountinitrd.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# umount /mnt, which is where the initrd ends up mounted
+# if the directory /initrd is not present, if this fails
+# then the /initrd is mounted and we want to remount that
+# ro - this works round the shutdown -r hang problem
+. /etc/default/functions
+
+case "$(machine)" in
+nslu2)
+ ffspart="Flashdisk";;
+*)
+ ffspart="filesystem";;
+esac
+
+while read device directory remainder
+do
+ case "$directory" in
+ /mnt) echo "InitRD: unmount initrd on /mnt" >&2
+ umount /mnt;;
+ /initrd)# need the device for a remount
+ ffsdev="$(mtblockdev $ffspart)"
+ [ -n "$ffsdev" ] || \
+ ffsdev="$(mtblockdev rootfs)"
+ echo "Remounting $ffsdev read-only on /initrd" >&2
+ if test -n "$ffsdev" -a -b "$ffsdev"
+ then
+ mount -o remount,ro "$ffsdev" /initrd
+ else
+ echo "$ffspart: $ffsdev: flash device not found" >&2
+ fi;;
+ esac
+done </proc/mounts
diff --git a/recipes/slugos-init/files/initscripts/zleds b/recipes/slugos-init/files/initscripts/zleds
new file mode 100644
index 0000000000..4c8277a53d
--- /dev/null
+++ b/recipes/slugos-init/files/initscripts/zleds
@@ -0,0 +1,45 @@
+#!/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