1 |
#!/bin/sh |
2 |
|
3 |
# based on http://www.turtlespond.net/scripts/dvb-t.html |
4 |
|
5 |
adapter=$1 |
6 |
channel=$2 |
7 |
time=$3 |
8 |
|
9 |
if [ -z "$adapter" -o -z "$channel" -o -z "$time" ] ; then |
10 |
echo "Usage: $0 adapter_nr Channel_name duration" |
11 |
exit 1; |
12 |
fi |
13 |
|
14 |
dir=/mnt/usb/ |
15 |
uid=`date +%Y-%m-%d_%H:%M:%S` |
16 |
file=$dir/$channel-$uid.ts |
17 |
|
18 |
# If frontend0 is active, kill it. |
19 |
fuser -k /dev/dvb/adapter$adapter/frontend0 |
20 |
|
21 |
# Tune in and lock channel |
22 |
tzap -a $adapter -c channels.conf -r "$channel" & |
23 |
# Then get the pid of tzap |
24 |
TZAP_PID=$! |
25 |
|
26 |
cat /dev/dvb/adapter$adapter/dvr0 > "$file" & |
27 |
STREAM_PID=$! |
28 |
|
29 |
trap "kill $TZAP_PID $STREAM_PID" 1 2 15 |
30 |
|
31 |
# Set duration of recording after converting minutes to seconds |
32 |
DURATION=$(($time*60)) |
33 |
echo "record $DURATION s" |
34 |
sleep $DURATION |
35 |
|
36 |
kill $TZAP_PID |
37 |
kill $STREAM_PID |
38 |
|
39 |
ls -al $file |