Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # set ACPI Wakeup alarm
- # safe_margin - minutes to start up system before the earliest timer
- # script does not check if recording is in progress
- #
- #
- echo 1 > /timer
- # bootup system 60 sec. before timer
- safe_margin=720
- # modyfy if different location for tvheadend dvr/log path
- cd /mnt/cache/.appdata/tvheadend-stable/dvr/log
- ######################
- start_date=0
- stop_date=0
- current_date=`date +%s`
- for i in $( ls ); do
- tmp_start=`cat $i | grep '"start":' | cut -f 2 -d " " | cut -f 1 -d ","`
- tmp_stop=`cat $i | grep '"stop":' | cut -f 2 -d " " | cut -f 1 -d ","`
- # check for outdated timer
- if [ $((tmp_stop)) -gt $((current_date)) -a $((tmp_start)) -gt $((current_date)) ]; then
- # take lower value (tmp_start or start_date)
- if [ $((start_date)) -eq 0 -o $((tmp_start)) -lt $((start_date)) ]; then
- start_date=$tmp_start
- stop_date=$tmp_stop
- fi
- fi
- done
- wake_date=$((start_date-safe_margin))
- echo $start_date >> /timer
- echo $wake_date >> /timer
- # set up waleup alarm
- if [ $((start_date)) -ne 0 ]; then
- echo 2 >> /timer
- echo 0 > /sys/class/rtc/rtc0/wakealarm
- echo $wake_date > /sys/class/rtc/rtc0/wakealarm
- fi
Add Comment
Please, Sign In to add comment