-
Notifications
You must be signed in to change notification settings - Fork 4
/
timersalon.sh
executable file
·100 lines (76 loc) · 1.95 KB
/
timersalon.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#
# Perform return to RRF after timeout
# F4HWN Armel
#
# Set timeout in seconds
if [ $# -eq 0 ]
then
timeout=360
else
timeout=$1
fi
# Init other values (don't touch)
last=`date +%s`
timer=0
talker_start=0
talker_stop=`date +%s`
log='/tmp/timersalon.log'
# Start log
cat << EOF > $log
Start QSY at : `date +'%d-%m-%Y %H:%M:%S' -d @$last` ($last)
--------------------
EOF
# Main loop
while [ $timer -lt $timeout ]; do
# Standby
sleep 10
# Catch last Talker start (if exist)
tmp=`grep 'ReflectorLogic: Talker start:' /tmp/svxlink.log | tail -1 | cut -c1-24`
if [ ! -z "$tmp" ]
then
talker_start=`date -d "$tmp" +%s`
fi
# Catch last Talker stop (if exist)
tmp=`grep 'ReflectorLogic: Talker stop:' /tmp/svxlink.log | tail -1 | cut -c1-24`
if [ ! -z "$tmp" ]
then
talker_stop=`date -d "$tmp" +%s`
fi
# If last Talker start > last Talker stop, then somebody is speaking so
# last activity is now
# Else
# last activity was at last Talker stop...
if [ $talker_start -gt $talker_stop ]
then
last=`date +%s`
trace=false
else
last=$talker_stop
trace=true
fi
now=`date +%s`
timer=$(($now-$last))
# Write trace for debug, only if trace is true (nobody speaking...)
if [ "$trace" = true ]
then
cat << EOF >> $log
Last Talker Start : `date +'%d-%m-%Y %H:%M:%S' -d @$talker_start` ($talker_start)
Last Talker Stop : `date +'%d-%m-%Y %H:%M:%S' -d @$talker_stop` ($talker_stop)
Last Radio Activity : `date +'%d-%m-%Y %H:%M:%S' -d @$last` ($last)
Timout : $timeout seconds
Timer : $timer seconds
--------------------
EOF
else
cat << EOF > $log
Last QSO active at : `date +'%d-%m-%Y %H:%M:%S' -d @$now` ($now)
--------------------
EOF
fi
done
# Return to RRF
cat << EOF >> $log
Return to RRF at : `date +'%d-%m-%Y %H:%M:%S' -d @$now` ($now)
EOF
/etc/spotnik/restart.rrf