Shutdown.sh
Aus VDR Wiki
(Unterschied zwischen Versionen)
K |
|||
Zeile 61: | Zeile 61: | ||
grub) REBOOT_LINE=`grep -s ^title "$GRUBCNF" | grep -i -n poweroff | { IFS=: read a b ; echo $a ; }` | grub) REBOOT_LINE=`grep -s ^title "$GRUBCNF" | grep -i -n poweroff | { IFS=: read a b ; echo $a ; }` | ||
test -n "$REBOOT_LINE" | test -n "$REBOOT_LINE" | ||
− | |||
0) which grub-set-default >/dev/null 2>&1 | 0) which grub-set-default >/dev/null 2>&1 | ||
case $? in | case $? in | ||
− | 0) sudo grub-set-default $((REBOOT_LINE-1)) | + | 0) which grubonce >/dev/null 2>&1 |
+ | case $? in | ||
+ | 0) sudo grubonce $((REBOOT_LINE-1)) | ||
+ | ;; | ||
+ | *) sudo grub-set-default $((REBOOT_LINE-1)) | ||
+ | ;; | ||
+ | esac | ||
;; | ;; | ||
*) echo -e "savedefault --default=$((REBOOT_LINE-1)) --once\nquit" | sudo grub --batch | *) echo -e "savedefault --default=$((REBOOT_LINE-1)) --once\nquit" | sudo grub --batch |
Version vom 1. Mai 2006, 21:48 Uhr
Vorschlag für ein einfaches Shutdown-Skript.
Übergabe.
-s $PATH/shutdown.sh --shutdown=$PATH/shutdown.sh
Siehe auch VDR Optionen.
Quellen:
- shutdown.sh NVRAM WakeUp
- Hubertus Sandmann
$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) sudo nvram-wakeup -s $TIMER $NVRAM_OPT ${NVRAM_CONFIG:+-C $NVRAM_CONFIG} ${NVRAM_IWNAME:+-I $NVRAM_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" 0) which grub-set-default >/dev/null 2>&1 case $? in 0) which grubonce >/dev/null 2>&1 case $? in 0) sudo grubonce $((REBOOT_LINE-1)) ;; *) sudo grub-set-default $((REBOOT_LINE-1)) ;; esac ;; *) 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-120)) 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 GRUB
Ergänzung für LILO
Oder.
Dannach LILO aufrufen.
shell> lilo # Added pluto * # Added PowerOff