From 69b4aac9d13d3c4a6c4604cfb763033aa0dab3d6 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sun, 24 Apr 2011 23:25:10 +0200 Subject: rc cleaning run rc.d scripts rc helper now call rc.d scripts in root directory with a clean environment. Chosen vars came from init man page. It allows to launch scripts from the command line, as if they had been launched by init Signed-off-by: Sebastien Luttringer --- rc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rc b/rc index 1e64119..9889d1e 100755 --- a/rc +++ b/rc @@ -43,8 +43,14 @@ case $1 in *) action=$1 shift + # set same environment variables as init + runlevel=$(/sbin/runlevel) + ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'" + ENV+=" PREVLEVEL='${runlevel:0:1}'" + ENV+=" RUNLEVEL='${runlevel:2:1}'" + ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" for i; do - [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" (( ret += $? )) done esac -- cgit v1.2.3-54-g00ecf From e04d6599f19532c996f541835d5f8f0aa87b2e3a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 26 Apr 2011 00:28:14 +0200 Subject: fixup: umount tmpfs on shutdown As suggested by seblu: - add comment to explain what we unmount and why, and - use /bin/grep rather than grep Also add some more redirects to /dev/null. Signed-off-by: Tom Gundersen --- rc.shutdown | 3 ++- rc.sysinit | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index f847ddf..ec5fb9b 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -54,9 +54,10 @@ if [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]]; then fi stat_busy "Unmounting Filesystems" -if grep -q devtmpfs /proc/filesystems 2>/dev/null; then +if /bin/grep -q devtmpfs /proc/filesystems &>/dev/null; then /bin/umount -a -r -t nosysfs,noproc,nodevtmpfs,nodevpts -O no_netdev else + # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it /bin/umount -a -r -t notmpfs,nosysfs,noproc,nodevpts -O no_netdev fi stat_done diff --git a/rc.sysinit b/rc.sysinit index 0dd644e..67d7771 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -21,7 +21,7 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" /bin/mountpoint -q /sys || /bin/mount -n -t sysfs sysfs /sys -o nosuid,noexec,nodev /bin/mountpoint -q /run || /bin/mount -n -t tmpfs tmpfs /run -o mode=755,size=10M,nosuid,noexec,nodev if ! /bin/mountpoint -q /dev; then - if grep -q devtmpfs /proc/filesystems 2>/dev/null; then + if /bin/grep -q devtmpfs /proc/filesystems &>/dev/null; then /bin/mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid else /bin/mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid @@ -88,7 +88,7 @@ status "Starting UDev Daemon" /sbin/udevd --daemon run_hook sysinit_udevlaunched # Trigger udev uevents -if /bin/pidof /sbin/udevd >/dev/null; then +if /bin/pidof /sbin/udevd &>/dev/null; then stat_busy "Triggering UDev uevents" /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems @@ -103,7 +103,7 @@ fi unset mods # Wait for udev uevents -if /bin/pidof /sbin/udevd >/dev/null; then +if /bin/pidof /sbin/udevd &>/dev/null; then status "Waiting for UDev uevents to be processed" \ /sbin/udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30} fi -- cgit v1.2.3-54-g00ecf From e0153f33ea46d23da4add5409b344e3cc050c6cc Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Tue, 26 Apr 2011 12:36:16 -0700 Subject: Fix a small typo introduced by 09c27ea248efebe1e72aa688cb55996dadbbbe29 /devshm -> /dev/shm Signed-off-by: Tom Gundersen --- rc.sysinit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 67d7771..2262d32 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,7 +31,7 @@ fi /bin/chmod 1777 /run/lock /bin/mountpoint -q /dev/pts || /bin/mount /dev/pts &> /dev/null \ || /bin/mount -n -t devpts devpts /dev/pts -o mode=620,gid=5,nosuid,noexec -/bin/mountpoint -q /dev/shm || /bin/mount /devshm &> /dev/null \ +/bin/mountpoint -q /dev/shm || /bin/mount /dev/shm &> /dev/null \ || /bin/mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev # remount root ro to allow for fsck later on, we remount now to -- cgit v1.2.3-54-g00ecf From bcbcea89b153aed0c905201c14ea3d3e3a1ee043 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 24 Apr 2011 17:35:05 -0400 Subject: rc: exit with error count, not error sum cc199761f assumes that /etc/rc.d scripts will exit with a value of 0 or 1. Since this can't be guaranteed, clamp the return value to 0 or 1 before adding it to the exit value. Note that a lot of /etc/rc.d scripts don't properly exit with 0 or 1, so this is more of a forward looking change in the hope that these scripts are cleaned up. Signed-off-by: Tom Gundersen --- rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc b/rc index 1e64119..54dc11c 100755 --- a/rc +++ b/rc @@ -45,7 +45,7 @@ case $1 in shift for i; do [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action - (( ret += $? )) + (( ret += !! $? )) # clamp exit value to 0/1 done esac -- cgit v1.2.3-54-g00ecf From 8dcc8d0e030aa4b84f02d1a862335afd74b772e8 Mon Sep 17 00:00:00 2001 From: Ian-Xue Li Date: Sat, 30 Apr 2011 21:16:09 +0200 Subject: rc.shutdown should recognize LVM upon LUKS option This fixes FS#23889. Signed-off-by: Tom Gundersen --- rc.shutdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc.shutdown b/rc.shutdown index ec5fb9b..a78bc4d 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -65,6 +65,11 @@ stat_done # Kill non-root encrypted partition mappings if [[ -f /etc/crypttab && -n $CS ]] && /bin/grep -q ^[^#] /etc/crypttab; then stat_busy "Deactivating encrypted volumes:" + # Maybe someone has LVM on an encrypted block device + # executing an extra vgchange is errorless + if [[ $USELVM =~ yes|YES ]]; then + /sbin/vgchange --sysinit -a n >/dev/null 2>&1 + fi do_lock() { stat_append "${1}.." if $CS remove "$1" >/dev/null 2>&1; then -- cgit v1.2.3-54-g00ecf From 05d4eaa92f004f066e47de0453384563f2c5f867 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Sat, 30 Apr 2011 15:41:11 -0300 Subject: Change udev trigger order Respect the order documented at udev README and systemd files. Signed-off-by: Gerardo Exequiel Pozzi Signed-off-by: Tom Gundersen --- rc.single | 2 +- rc.sysinit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.single b/rc.single index b9701d5..8c3358f 100755 --- a/rc.single +++ b/rc.single @@ -20,8 +20,8 @@ if [[ $PREVLEVEL != N ]]; then if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Triggering UDev uevents" /sbin/udevadm control --property=STARTUP=1 - /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems + /sbin/udevadm trigger --action=add --type=devices stat_done fi diff --git a/rc.sysinit b/rc.sysinit index 2262d32..dc4be58 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -90,8 +90,8 @@ run_hook sysinit_udevlaunched # Trigger udev uevents if /bin/pidof /sbin/udevd &>/dev/null; then stat_busy "Triggering UDev uevents" - /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems + /sbin/udevadm trigger --action=add --type=devices stat_done fi -- cgit v1.2.3-54-g00ecf From a43cb3c03ca768956ceb9e2856683eae5c48c68f Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Sat, 30 Apr 2011 15:41:12 -0300 Subject: workaround: do not set property=STARTUP=1 when calling udevadm Apply same logic like in rc.sysinit (commit c3063d0400e7a55c9dbd6ff1b76887744e9b6224) Signed-off-by: Gerardo Exequiel Pozzi Signed-off-by: Tom Gundersen --- rc.single | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rc.single b/rc.single index 8c3358f..06bd83c 100755 --- a/rc.single +++ b/rc.single @@ -19,7 +19,6 @@ if [[ $PREVLEVEL != N ]]; then # Trigger udev uevents if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Triggering UDev uevents" - /sbin/udevadm control --property=STARTUP=1 /sbin/udevadm trigger --action=add --type=subsystems /sbin/udevadm trigger --action=add --type=devices stat_done @@ -27,10 +26,8 @@ if [[ $PREVLEVEL != N ]]; then # Wait for udev uevents if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then - stat_busy "Waiting for UDev uevents to be processed" - /sbin/udevadm settle - /sbin/udevadm control --property=STARTUP= - stat_done + status "Waiting for UDev uevents to be processed" \ + /sbin/udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30} fi run_hook single_udevsettled -- cgit v1.2.3-54-g00ecf