#!/bin/bash # # /etc/rc.d/kexec: start/stop kexec # [ -f /etc/kexec.conf ] && . /etc/kexec.conf case "$1" in start) echo "Kexec rc dummy entry" ;; stop|load) if [ ! "$RUNLEVEL" = "6" ]; then if [ "$1" = "load" ]; then /sbin/kexec -u echo "Loading Kexec kernel" [ -f "$KPATH" ] [ -f "$INITRD" ] && _INITRD="--initrd=$INITRD" if [ -z "$2" ]; then /sbin/kexec -l $KPATH --append="root=$ROOTPART $KPARAM 2" $_INITRD > /dev/null 2>&1 else /sbin/kexec -l $KPATH --append="root=$ROOTPART $KPARAM $2" $_INITRD > /dev/null 2>&1 fi # if [ "$RUNLEVEL" = "6" ]; then # /sbin/killall rc.shutdown # /usr/bin/clear # fi # Clean up the system (extracted from rc.shutdown) . /etc/rc.conf /bin/stty onlcr if [ "${SERVICES[*]}" ]; then echo -n "Stopping services:" for service in "${SERVICES[@]}"; do R_SERVICES=($service ${R_SERVICES[@]}) done for service in "${R_SERVICES[@]}"; do if [ "$service" = "kexec" ]; then echo -n " ( not stopping $service )" else echo -n " $service" /etc/rc.d/$service stop &> /tmp/rc.$$ /usr/bin/logger -t $service -f /tmp/rc.$$ /bin/rm -f /tmp/rc.$$ fi done fi /sbin/killall5 -15 /bin/sleep 5 /sbin/killall5 -9 /bin/sleep 5 /bin/dd if=/dev/urandom of=/var/lib/urandom/seed count=1 2> /dev/null /sbin/hwclock --systohc /sbin/halt -w /sbin/swapoff -a /bin/umount -a -r /bin/mount -n -o remount,ro / ### /sbin/kexec -e > /dev/null 2>&1 else echo "Skipping loading Kexec kernel" fi fi ;; restart) echo "Unloading Kexec kernel" /sbin/kexec -u ;; *) echo "usage: $0 {start|stop|load |restart}" echo "for \"$0 load\", you may specify a runlevel for the Kexec kernel image (the default is level 2/multi-user) -" echo " # $0 load 0/1/2/6" esac exit 0 # End of file