#!/bin/sh # PC zeitgesteuert starten indem die rtc-Zeit per acpi gestellt wird # $1 - wakeup time # $2 - second up to wakeup # $3 - only a test if set to "test" # current time cur_time=`date +%s` # how many seconds before the next event the system should be booted boot_time=120 down_time=60 # Zeit beim Runterfahren setzen if [ -n "$1" ] ; then if [ $1 -eq 0 ] ; then # kein timer gesetzt wake_time=$(( $cur_time - $boot_time )) else if [ $2 -lt $(( $boot_time + $down_time )) ] ; then # zeit bis zum naechsten timer ist zu kurtz exit 2 fi wake_time=$(( $1 - $boot_time )) fi if [ -e /sys/class/rtc/rtc0/wakealarm ]; then if [ "$3" = "test" ];then exit 0 fi echo 0 > /sys/class/rtc/rtc0/wakealarm || exit 2 echo $wake_time > /sys/class/rtc/rtc0/wakealarm || exit 2 echo $wake_time > /sys/class/rtc/rtc0/wakealarm elif [ -e /proc/acpi/alarm ]; then if [ "$3" = "test" ];then if [ "$4" = "onchange" -a "`cat /proc/acpi/alarm`" != "`mydate -d $wake_time "+%Y-%m-%d %H:%M:%S"`" ];then exit 1 fi exit 0 fi mydate -d $wake_time "+%Y-%m-%d %H:%M:%S" >/proc/acpi/alarm || exit 2 mydate -d $wake_time "+%Y-%m-%d %H:%M:%S" >/proc/acpi/alarm else echo "No timer device found" >&2 exit 2 fi fi exit 0