w_scan: change path to channels.conf for vdr 2.x.
[people/teissler/ipfire-2.x.git] / config / w_scan / w_scan_start
CommitLineData
7e616a32
AF
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
d2a94495 5# Copyright (C) 2007-2013 IPFire Team <info@ipfire.org> #
7e616a32
AF
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21###############################################################################
d2a94495
AF
22# w_scan_start for IPFire v 1.01 - 2013-04-20 Arne Fitzenreiter - path vdr 2 #
23# - 2012-11-15 Arne Fitzenreiter - inital vers.#
7e616a32
AF
24###############################################################################
25
26err_msg ()
27{
28 whiptail --msgbox "$1" 8 70 --title "Error"
29 clear
30 exit 1
31}
32
33chk_cancel ()
34{
35 if [ ! "${?}" == 0 ];then
36 clear
37 echo "Terminated by user!"
38 exit 0
39 fi
40}
41
42yes_no ()
43{
44 whiptail --yesno "$1" 8 70
45 chk_cancel
46}
47
48WSCAN=$(which w_scan)
49
bb91f5a5
AF
50# Whiptail does not like en_US.UTF-8
51LANG=c
52
7e616a32
AF
53# Some initial checks...
54if [ -z $WSCAN ];then
55 err_msg "w_scan not found!";
56fi
57if [ ! -e /dev/dvb/adapter[0-9]/frontend[0-9] ];then
58 err_msg "No dvb tuner frontend found!";
59fi
60
61# Is vdr running?
62if [ "$(ps -A | grep " runvdr$")" != "" ] ;then
bb91f5a5 63 yes_no "VDR is running. Cannot scan with active VDR. Should I stop it?"
7e616a32
AF
64 clear
65 /etc/init.d/vdr stop
7e616a32
AF
66fi
67
68# Select DVB type
69whiptail --checklist "\nSelect DVB type" 12 40 3 \
70 DVB-T "Terrestrial" yes \
71 DVB-C "Cable" no \
bb91f5a5 72 DVB-S "Satellite" no \
7e616a32
AF
73 2>/tmp/w_scan_type
74chk_cancel
75W_SCAN_TYPE=$(cat /tmp/w_scan_type)
76rm /tmp/w_scan_type
77
78if [[ "$W_SCAN_TYPE" == *DVB-T* ]] || [[ "$W_SCAN_TYPE" == *DVB-C* ]]; then
79 # Generate and run separate country menubox and default germany
80 echo '#!/bin/bash' > /tmp/w_scan_countryselect.sh
81 echo 'whiptail --radiolist "\nSelect country" 19 70 10 \' >> /tmp/w_scan_countryselect.sh
82 $WSCAN -c? 2>&1 | cut -f2,4 | sed 's|[ ]| "|g' | sed 's|$|" off \\|g' | sed 's|"GERMANY" off |"GERMANY" on |g' >> /tmp/w_scan_countryselect.sh
83 echo ' 2>/tmp/w_scan_country' >> /tmp/w_scan_countryselect.sh
84 sh /tmp/w_scan_countryselect.sh
85 chk_cancel
86 rm /tmp/w_scan_countryselect.sh
87 W_SCAN_COUNTRY=$(cat /tmp/w_scan_country)
88 rm /tmp/w_scan_country
89fi
90
91if [[ "$W_SCAN_TYPE" == *DVB-S* ]]; then
92 # Generate and run separate satelite menubox and default astra
93 echo '#!/bin/bash' > /tmp/w_scan_satselect.sh
bb91f5a5 94 echo 'whiptail --checklist "\nSelect satellites" 19 70 10 \' >> /tmp/w_scan_satselect.sh
7e616a32 95 $WSCAN -s? 2>&1 | cut -f2,4 | sed 's|[ ]| "|g' | sed 's|$|" off \\|g' | sed 's|19.2 east.*|19.2 east Astra 1F/1G/1H/1KR/1L" on \\|g' >> /tmp/w_scan_satselect.sh
bb91f5a5 96 echo ' 2>/tmp/w_scan_satellite' >> /tmp/w_scan_satselect.sh
7e616a32
AF
97 sh /tmp/w_scan_satselect.sh
98 chk_cancel
99 rm /tmp/w_scan_satselect.sh
bb91f5a5
AF
100 W_SCAN_SATELLITE=$(cat /tmp/w_scan_satellite | sed 's|"||g')
101 rm /tmp/w_scan_satellite
7e616a32
AF
102fi
103
104# Now start the scan ...
105clear
106rm -rf /tmp/channels.conf
107if [[ "$W_SCAN_TYPE" == *DVB-T* ]]; then
bb91f5a5 108 echo ":->W-SCAN DVB-T $(date +%Y%m%d%H%M)" >>/tmp/channels.conf
22f94778 109 $WSCAN -f t -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf
7e616a32
AF
110fi
111if [[ "$W_SCAN_TYPE" == *DVB-C* ]]; then
bb91f5a5 112 echo ":->W-SCAN DVB-C $(date +%Y%m%d%H%M)" >>/tmp/channels.conf
22f94778 113 $WSCAN -f c -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf
7e616a32
AF
114fi
115if [[ "$W_SCAN_TYPE" == *DVB-S* ]]; then
bb91f5a5 116 for SATELLITE in $W_SCAN_SATELLITE;
7e616a32 117 do
bb91f5a5 118 echo ":->W-SCAN DVB-S $SATELLITE $(date +%Y%m%d%H%M)" >>/tmp/channels.conf
22f94778 119 $WSCAN -f s -s $SATELLITE -C UTF-8 -o 7 >>/tmp/channels.conf
7e616a32
AF
120 done
121fi
122
123# Save result to current dir.
124cp /tmp/channels.conf w_scan-$(date +%Y%m%d%H%M).channels.conf
125echo Results saved to w_scan-$(date +%Y%m%d%H%M).channels.conf
126
127# Do this only if vdr is installed ...
128if [ -e /opt/pakfire/db/installed/meta-vdr ]; then
bb91f5a5 129 yes_no "Install new channels-conf for VDR."
7e616a32 130 # Backup old channels conf...
d2a94495
AF
131 cp -f /etc/vdr/channels.conf \
132 /etc/vdr/channels.conf.backup$(date +%Y%m%d%H%M)
133 cp -f /tmp/channels.conf /etc/vdr/
bb91f5a5 134 yes_no "Should i start the VDR?"
7e616a32
AF
135 clear
136 /etc/init.d/vdr start
137fi