Shutdown.sh
Aus VDR Wiki
(Unterschied zwischen Versionen)
Zeile 113: | Zeile 113: | ||
shell> cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nvram-wakeup co nvram-wakeup/reboot | shell> cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nvram-wakeup co nvram-wakeup/reboot | ||
− | Hier sollte sich ein passender Reboot-Kernel finden. | + | Hier sollte sich ein passender ''Reboot-Kernel'' finden, welcher nach '''/boot''' verfrachtet wird. |
shell> KERNEL_VERSION=`uname -r` | shell> KERNEL_VERSION=`uname -r` |
Version vom 22. April 2006, 00:16 Uhr
Vorschlag für ein einfaches Shutdown-Skript.
$PATH/shutdown.sh
#!/bin/bash # # shutdown.sh # wake up method ('off','acpi','nvram','suspend') WAKEUP_METHOD="off" # read board configuration from specified configuration file (e.g: "/etc/nvram-wakeup.conf") NVRAM_CONFIG="" # specify the iw (infowriter) name. (e.g: gigabyte_5aa) NVRAM_IWNAME="" # try "nvram-wakeup --help" NVRAM_OPT="--syslog" # Which boot manager are you using? (grub/lilo) BOOT_MANAGER="grub" TIMER=$1 LILOCNF=/etc/lilo.conf GRUBCNF=/boot/grub/menu.lst ACPIALARM=/proc/acpi/alarm case ${#TIMER}-${WAKEUP_METHOD:-off} in 10-acpi) test -e $ACPIALARM case $? in 0) date -d "1970-01-01 UTC $((TIMER-120)) seconds" +"%Y-%m-%d %R:%S" > $ACPIALARM sudo poweroff exit 0 ;; *) logger -t ${0##*/} "ARG -> missing $ACPIALARM" ;; esac ;; 10-nvram) test -e /dev/nvram -a -e /dev/rtc -a -e /dev/mem case $? in 0) which nvram-wakeup >/dev/null 2>&1 case $? in 0) IWNAME="${NVRAM_IWNAME/*[unknown, ]*}" sudo nvram-wakeup -s $TIMER $NVRAM_OPT ${NVRAM_CONFIG:+-C $NVRAM_CONFIG} ${IWNAME:+-I $IWNAME} case ${BOOT_MANAGER:-lilo} in grub) REBOOT_LINE=`grep -s ^title "$GRUBCNF" | grep -i -n poweroff | { IFS=: read a b ; echo $a ; }` test -n "$REBOOT_LINE" case $? in 0) which grub-set-default >/dev/null 2>&1 case $? in 0) sudo grub-set-default $((REBOOT_LINE-1)) ;; *) echo -e "savedefault --default=$((REBOOT_LINE-1)) --once\nquit" | sudo grub --batch ;; esac ;; *) logger -t ${0##*/} "ARG -> missing poweroff entry in $GRUBCNF" ;; esac ;; lilo) REBOOT_ENTRY=`grep -s -i label.*poweroff "$LILOCNF" | { IFS== read a b ; echo $b ; }` test -n "$REBOOT_ENTRY" case $? in 0) sudo lilo -R $REBOOT_ENTRY ;; *) logger -t ${0##*/} "ARG -> missing poweroff entry in $LILOCNF" ;; esac ;; esac sudo shutdown -r now exit 0 ;; *) logger -t ${0##*/} "ARG -> missing nvram-wakeup" ;; esac ;; *) logger -t ${0##*/} "ARG -> missing /dev/nvram -o /dev/rtc -o /dev/mem" ;; esac ;; 10-suspend) test -e $ACPIALARM -a -e /sys/power/state case $? in 0) date -d "1970-01-01 UTC $((TIMER-30)) seconds" +"%Y-%m-%d %R:%S" > $ACPIALARM echo mem > /sys/power/state sudo reboot exit 0 ;; *) logger -t ${0##*/} "ARG -> missing $ACPIALARM -o /sys/power/state" ;; esac ;; 10-off) logger -t ${0##*/} "MESG -> no wakeup method" ;; 1-*) logger -t ${0##*/} "MESG -> no timer" ;; esac sudo shutdown -h now exit $?
NVRAM WakeUp
shell> cd /tmp shell> cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nvram-wakeup login shell> cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nvram-wakeup co nvram-wakeup/reboot
Hier sollte sich ein passender Reboot-Kernel finden, welcher nach /boot verfrachtet wird.
shell> KERNEL_VERSION=`uname -r` shell> find $PWD -name "bzImage.${KERNEL_VERSION:0:3}*" -exec cp -v {} /boot/bzImage.poweroff \;
Ergänzung für LILO