X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Finit.d%2Fgrml-reboot;h=5564504b864b56ab16f9be0b1b3f92c808fc9e8b;hb=7a8acd5cb4cc3637cd18af83ce47418634c0fb0b;hp=ebc91730cbafe4679117656a449e956c28dd55a5;hpb=699350f077f1bf4eb7e47ae940e0503129ad81b5;p=grml-etc.git diff --git a/etc/init.d/grml-reboot b/etc/init.d/grml-reboot index ebc9173..5564504 100755 --- a/etc/init.d/grml-reboot +++ b/etc/init.d/grml-reboot @@ -4,7 +4,6 @@ # Authors: grml-team (grml.org), (c) Klaus Knopper, (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Die Jun 26 00:08:30 CEST 2007 [mika] ################################################################################ export PATH=/sbin:/bin:/usr/bin:/usr/sbin @@ -18,12 +17,18 @@ cd / exec >/dev/console 2>&1 /dev/null 2>&1 && { pump -k ; sleep 2; } + killall dhclient dhclient3 2>/dev/null + log_begin_msg "Shutting down network device..." + for n in $NETDEVICES; do + echo "${SUBMSG} ${WHITE}$n${NORMAL}" + ifdown $n 1>/dev/null 2>&1 + ifconfig $n down + done ; log_end_msg $? + fi +} + # Disable kernel messages echo "0" > /proc/sys/kernel/printk +# make sure halt/reboot commands are available even if +# someone is using shutdown command: +cat /sbin/halt /sbin/reboot >/dev/null + # We may kill our network connection here before unmounting NFS. Bad luck. # poweroff pcmcia devices if [ -d /sys/bus/pcmcia -a -x /sbin/pccardctl ] ; then @@ -91,31 +116,9 @@ sleep 1 log_begin_msg_nn "Sending all processes the KILL signal: " mysleep "$RED" ; log_end_msg $? -# check for nfsdir -if grep -q nfsdir /proc/cmdline ; then - log_begin_msg "Bootoption nfsdir detected, syncing filesystems." - sync && sleep 1 ; log_end_msg $? -else - # Unmount network filesystems first before shutting down network - NETMOUNTS="$(awk '{if($1~/:/){print $2}}' /proc/mounts 2>/dev/null)" - if [ -n "$NETMOUNTS" ]; then - log_begin_msg "Unmounting network filesystems." - umount -t nfs,nfs4,smbfs -alvf 2>/dev/null - fi - # Shutdown network - NETDEVICES="$(/sbin/ifconfig | awk '/^[^ ]+/ {print $1}' | grep -v '^lo$')" - if [ -n "$NETDEVICES" ]; then - pidof pump >/dev/null 2>&1 && { pump -k ; sleep 2; } - killall dhclient dhclient3 2>/dev/null - log_begin_msg "Shutting down network device..." - for n in $NETDEVICES; do - echo "${SUBMSG} ${WHITE}$n${NORMAL}" - ifdown $n 1>/dev/null 2>&1 - ifconfig $n down - done ; log_end_msg $? - fi - log_begin_msg "Syncing local filesystems..." - sync && sleep 1 ; log_end_msg $? +# shut down network only when not booting via NFS: +if [ -z "$NFSBOOT" ] ; then + shutdown_network fi # Turn off swap, then unmount file systems. @@ -126,12 +129,9 @@ swapoff -a >/dev/null 2>&1 ; log_end_msg $? log_begin_msg "Deactivating udev:" echo -n " ${GREEN}-${NORMAL} " /etc/init.d/udev stop ; log_end_msg $? -[ -n $INSTALLED ] || mkdir -p /dev/pts -[ -n $INSTALLED ] || cp -a /GRML/dev/console /GRML/dev/tty[0-9]* /GRML/dev/loop* /GRML/dev/initctl /GRML/dev/null /dev/ -[ -n $INSTALLED ] || ln -s /GRML/dev/* /dev/ 2>/dev/null # Read in boot parameters -CMDLINE="`cat /proc/cmdline 2>/dev/null`" +CMDLINE="$(cat /proc/cmdline 2>/dev/null)" # noprompt or noeject option given? NOPROMPT=${NOPROMPT:-''} case "$CMDLINE" in *noprompt*) NOPROMPT="yes"; ;; esac @@ -148,9 +148,17 @@ fi # Detected cdrom device if [ -z "$INSTALLED" ]; then - CDROM="$(awk '/ \/cdrom /{print $1;exit 0;}' /proc/mounts)" + # new live-initramfs layout: + if [ -d /live/image ] ; then + CDROM="$(awk '/ \/live\/image /{print $1;exit 0;}' /proc/mounts)" + else # old unionfs layout: + CDROM="$(awk '/ \/cdrom /{print $1;exit 0;}' /proc/mounts)" + fi fi +log_begin_msg "Syncing local filesystems..." +sync && sleep 1 ; log_end_msg $? + # Umount everything but root log_begin_msg "Unmounting file systems." @@ -163,25 +171,33 @@ fi # Free loopback devices if necessary, so we can unmount the host media for i in /dev/loop*; do losetup -d $i 2>/dev/null; done -# Remove remaining unused modules (Kernel 2.4) -# rmmod -a >/dev/null 2>&1 - umount -t notmpfs,nosysfs,noproc,nousbfs -adrvf 1>/dev/null 2>&1 log_end_msg 0 +# shut down network only when not booting via NFS: +if [ -n "$NFSBOOT" ] ; then + log_begin_msg "Booting via NFS detected" + echo -n " ${GREEN}-${NORMAL} Unmounting network filesystems" + umount -t nfs,nfs4,smbfs -alvf 2>/dev/null ; log_end_msg $? + + echo -n " ${GREEN}-${NORMAL} Finally shutting down network..." + shutdown_network ; log_end_msg $? +fi + # For a harddisk installation: mount / ro [ -n "$INSTALLED" ] && mount -n -o remount,ro / 2>/dev/null if [ -z "$INSTALLED" -a -z "$NOPROMPT" ]; then # do not prompt for removal when running in grml2ram mode: - if ! mount | grep -q 'on /cdrom ' ; then + if ! mount | grep -qe 'on /cdrom' -qe 'on /live/image' ; then echo "CD not mounted, nothing to eject therefore." else - umount -l /cdrom + [ -d /live/image ] && umount -l /live/image + [ -d /cdrom ] && umount -l /cdrom [ -n "$CDROM" -a -z "$NOEJECT" ] && eject -p "$CDROM" 2>/dev/null echo - read -s -p "${GREEN}Please remove CD, close cdrom drive and hit return [auto 2 minutes].${NORMAL}" -t 120 a + read -s -p "${GREEN}Please remove the disc, close the tray (if any) and press ENTER to continue [auto 2 minutes].${NORMAL}" -t 120 a fi fi