]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - rc.d/rc.shutdown
Umount remaining filesystems one by one (using -R) option which helps in cases when...
[projects/rc-scripts.git] / rc.d / rc.shutdown
index a7efc8b9a7a4c218b38d53efed4ca8b922d44504..be5c7857a7152cf42ffca8d386d3e0d2327d8619 100755 (executable)
@@ -4,7 +4,6 @@
 #
 # Author:      Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
 #
-# $Id$
 
 # Set the path.
 PATH=/sbin:/bin:/usr/bin:/usr/sbin
@@ -20,8 +19,6 @@ IN_SHUTDOWN=yes
 trap "echo" INT SEGV QUIT TERM
 set +e
 
-emit pld.shutdown-started
-
 rc_splash "reboot"
 
 # Kill all processes.
@@ -35,6 +32,10 @@ if [ -x /sbin/blogd ]; then
        killall -q -QUIT blogd
 fi
 
+if [ -e /dev/rtc -o -e /dev/rtc0 ]; then
+       run_cmd "$(nls 'Syncing hardware clock to system time')" hwclock --systohc
+fi
+
 # check for other processes.
 # there could be none if all services were terminated properly
 # pgrep -g 0 requires procps >= 3.2.6-1.1
@@ -76,12 +77,24 @@ if ! is_yes "$VSERVER"; then
                UMOUNT_IGNORE="/ $UMOUNT_IGNORE"
        fi
        remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
-                       $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \
+                       $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|cgroup|cgroup2|sysfs|securityfs|squashfs)$/ \
                        && $1 !~ /^(none|\/dev\/root)$/ \
                        && $2 !~ ig {print $2}' /proc/mounts)
        while [ -n "$remaining" -a "$retry" -gt 0 ]; do
-               show "Unmounting file systems"; busy
-               ERRORS=$(umount -a $force -t noproc 2>&1); rc=$?
+               for mnt in $remaining; do
+                       run_cmd "$(nls 'Umounting file system: %s' $mnt)" umount $force -R $mnt
+
+                       # we might had unmounted /usr, recheck $TPUT availability
+                       # but well. we need tput only for show() and busy() (ok() and fail() messages are already cached)
+                       # TODO: look ahead the messages?
+                       if is_yes "$TPUT"; then
+                           TPUT=
+                           rc_gettext_init
+                       fi
+               done
+
+               show "Unmounting remainging file systems"; busy
+               ERRORS=$(umount -a $force -t noproc,nosysfs,notmpfs,nodevpts,nodevtmpfs 2>&1); rc=$?
 
                # we might had unmounted /usr, recheck $TPUT availability
                # but well. we need tput only for show() and busy() (ok() and fail() messages are already cached)
@@ -95,12 +108,15 @@ if ! is_yes "$VSERVER"; then
                        ok
                else
                        fail
-                       [ -n "$ERRORS" ] && echo "$ERRORS"
+                       if [ -n "$ERRORS" ]; then
+                              nls "Umount errors:"
+                              echo "$ERRORS"
+                       fi
                fi
 
                sleep 2
                remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
-                               $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \
+                               $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|cgroup|cgroup2|sysfs|securityfs|squashfs)$/ \
                                && $1 !~ /^(none|\/dev\/root)$/ \
                                && $2 !~ ig {print $2}' /proc/mounts)
                [ -z "$remaining" ] && break
@@ -116,36 +132,18 @@ if ! is_yes "$VSERVER"; then
        if [ -x /sbin/vgchange ]; then
                lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
                if [ "$lvmversion" = "2" ]; then
-                       lvmignorelock="--ignorelockingfailure"
+                       lvmsysinit="--sysinit --noudevsync"
                else
-                       lvmignorelock=""
+                       lvmsysinit=""
                fi
-               run_cmd "Stopping LVM volume groups" /sbin/vgchange -a n $lvmignorelock
+               /sbin/vgchange -a n $lvmsysinit > /dev/null 2>&1
        fi
 
-       goraidtab=1
        if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
                if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
                        /sbin/mdadm --stop --scan > /dev/null 2>&1
                        rc=$?
-                       [ "$rc" -eq 0 ] && goraidtab=0
-               fi
-       fi
-
-       # turn off raid
-       if [ -x /sbin/raidstop -a -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
-               # we can not use raidstop -a here because this will only stop
-               # devices listed in the default config file which is not always
-               # the case. So we look only for the active raid devices
-               if [ -f /proc/mdstat ] ; then
-                       mddevs=$(awk '/^md.* active/ {print $1}' /proc/mdstat)
-                       for mddev in $mddevs ; do
-                               show "Turning off RAID for %s" "$mddev"
-                               daemon /sbin/raidstop /dev/$mddev
-                       done
-                       unset mddev mddevs
                fi
-               # runcmd "Turning off RAID" /sbin/raidstop -a
        fi
 
        show "Remounting remaining filesystems ro mode"; busy
@@ -184,7 +182,7 @@ if [ "$runlevel" = "0" ] ; then
                       [ -x /sbin/poweroff-ups ] && /sbin/poweroff-ups
               fi
        fi
-       [ "$previous" != "unknown" ] && eval halt -d -p -f
+       [ "$previous" != "unknown" ] && halt -d -p -f
 else
        show "Please stand by while rebooting the $_rebootwhat"; ok
        if [ -f /fastboot ]; then
@@ -197,5 +195,5 @@ else
                fail
        fi
 
-       [ "$previous" != "unknown" ] && eval reboot -d -f
+       [ "$previous" != "unknown" ] && reboot -d -f
 fi
This page took 0.034492 seconds and 4 git commands to generate.