2008-08-18 18:49:11 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 SUSE LINUX Products GmbH
|
|
|
|
# Author: Bernhard Walle <bwalle@suse.de>
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: kexec
|
2008-10-13 17:08:03 +02:00
|
|
|
# Required-Start: $null
|
2008-08-18 18:49:11 +02:00
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
2008-10-13 17:08:03 +02:00
|
|
|
# Required-Stop: $local_fs $remote_fs
|
|
|
|
# Default-Start: 1 2 3 5 S
|
|
|
|
# Default-Stop: 1 2 3 5 S
|
2008-08-18 18:49:11 +02:00
|
|
|
# Short-Description: Enables reboot through kexec
|
|
|
|
# Description: Enables reboot through kexec
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
. /etc/rc.status
|
|
|
|
|
|
|
|
KEXEC_BOOTLOADER=/usr/sbin/kexec-bootloader
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
;;
|
|
|
|
stop)
|
2008-10-13 17:08:03 +02:00
|
|
|
# Only execute that script if we're going to reboot the system.
|
|
|
|
if [ "$RUNLEVEL" -eq 6 ] ; then
|
|
|
|
if ! [ -f /sys/kernel/kexec_loaded ] ; then
|
|
|
|
echo -n "Cannot check if kexec kernel has been loaded."
|
|
|
|
rc_failed
|
2008-08-18 18:49:11 +02:00
|
|
|
else
|
2008-10-13 17:08:03 +02:00
|
|
|
read -t 2 kexec_loaded < /sys/kernel/kexec_loaded
|
|
|
|
if [ "$kexec_loaded" -ne 0 ] ; then
|
|
|
|
echo -n "kexec kernel already loaded."
|
|
|
|
rc_status -s
|
|
|
|
else
|
|
|
|
echo -n "Loading kexec kernel for reboot ..."
|
|
|
|
$KEXEC_BOOTLOADER
|
|
|
|
rc_status -v
|
|
|
|
fi
|
2008-08-18 18:49:11 +02:00
|
|
|
fi
|
2008-10-13 17:08:03 +02:00
|
|
|
else
|
|
|
|
echo "Loading kexec kernel ..."
|
|
|
|
rc_status -s
|
2008-08-18 18:49:11 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
echo "not implemented"
|
|
|
|
rc_status -s
|
|
|
|
;;
|
|
|
|
restart|reload)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|status|restart|reload|try-reload}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
rc_exit
|
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 et: :mode=shellscript:
|