summaryrefslogtreecommitdiff
path: root/core/opiealarm/opieatd
blob: fc2d4213447b9fbd9b240ae81260155d82cd52a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

timefile=/etc/resumeat

trap exit 0 SIGTERM SIGINT SIGQUIT

echo $$ >/var/run/opieatd.pid

mkdir -p /var/spool/at
[ -p /var/spool/at/trigger ] || mkfifo /var/spool/at/trigger

while true; do
	while read </var/spool/at/trigger dummy; do
		FILES=`ls /var/spool/at/[0-9]* 2>/dev/null`
	
		if [ -z "$FILES" ]; then
			echo "clear resume at"
			echo "" >$timefile
		else
			for i in "$FILES"; do
				echo "File = $i"

				unixtime=`basename $i | cut -c1-10`
				pid=`basename $i | cut -c12-` 
				
				if [ -d /proc/$pid ]; then				
					echo "Datestring = $unixtime"
					echo "$unixtime" >$timefile
				else
					rm -f $i
				fi
			done
		fi
	done
done

exit 0