]>
Commit | Line | Data |
---|---|---|
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 | ############################################################################### | |
e200ab58 AF |
22 | # w_scan_start for IPFire v 1.02 - 2013-04-30 Arne Fitzenreiter - add atsc # |
23 | # - 2013-04-20 Arne Fitzenreiter - path vdr 2 # | |
d2a94495 | 24 | # - 2012-11-15 Arne Fitzenreiter - inital vers.# |
7e616a32 AF |
25 | ############################################################################### |
26 | ||
27 | err_msg () | |
28 | { | |
29 | whiptail --msgbox "$1" 8 70 --title "Error" | |
30 | clear | |
31 | exit 1 | |
32 | } | |
33 | ||
34 | chk_cancel () | |
35 | { | |
36 | if [ ! "${?}" == 0 ];then | |
37 | clear | |
38 | echo "Terminated by user!" | |
39 | exit 0 | |
40 | fi | |
41 | } | |
42 | ||
43 | yes_no () | |
44 | { | |
45 | whiptail --yesno "$1" 8 70 | |
46 | chk_cancel | |
47 | } | |
48 | ||
49 | WSCAN=$(which w_scan) | |
50 | ||
bb91f5a5 AF |
51 | # Whiptail does not like en_US.UTF-8 |
52 | LANG=c | |
53 | ||
7e616a32 AF |
54 | # Some initial checks... |
55 | if [ -z $WSCAN ];then | |
56 | err_msg "w_scan not found!"; | |
57 | fi | |
58 | if [ ! -e /dev/dvb/adapter[0-9]/frontend[0-9] ];then | |
59 | err_msg "No dvb tuner frontend found!"; | |
60 | fi | |
61 | ||
62 | # Is vdr running? | |
63 | if [ "$(ps -A | grep " runvdr$")" != "" ] ;then | |
bb91f5a5 | 64 | yes_no "VDR is running. Cannot scan with active VDR. Should I stop it?" |
7e616a32 AF |
65 | clear |
66 | /etc/init.d/vdr stop | |
7e616a32 AF |
67 | fi |
68 | ||
e200ab58 AF |
69 | # Select system type |
70 | whiptail --checklist "\nSelect system type" 12 40 5 \ | |
7e616a32 | 71 | DVB-T "Terrestrial" yes \ |
e200ab58 AF |
72 | DVB-C "Cable" no \ |
73 | DVB-S "Satellite" no \ | |
74 | ATSC-T "Terrestrial" no \ | |
75 | ATSC-C "Cable" no \ | |
7e616a32 AF |
76 | 2>/tmp/w_scan_type |
77 | chk_cancel | |
78 | W_SCAN_TYPE=$(cat /tmp/w_scan_type) | |
79 | rm /tmp/w_scan_type | |
80 | ||
e200ab58 | 81 | if [[ "$W_SCAN_TYPE" == *ATSC* ]] || [[ "$W_SCAN_TYPE" == *DVB-T* ]] || [[ "$W_SCAN_TYPE" == *DVB-C* ]]; then |
7e616a32 AF |
82 | # Generate and run separate country menubox and default germany |
83 | echo '#!/bin/bash' > /tmp/w_scan_countryselect.sh | |
84 | echo 'whiptail --radiolist "\nSelect country" 19 70 10 \' >> /tmp/w_scan_countryselect.sh | |
85 | $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 | |
86 | echo ' 2>/tmp/w_scan_country' >> /tmp/w_scan_countryselect.sh | |
87 | sh /tmp/w_scan_countryselect.sh | |
88 | chk_cancel | |
89 | rm /tmp/w_scan_countryselect.sh | |
90 | W_SCAN_COUNTRY=$(cat /tmp/w_scan_country) | |
91 | rm /tmp/w_scan_country | |
92 | fi | |
93 | ||
94 | if [[ "$W_SCAN_TYPE" == *DVB-S* ]]; then | |
95 | # Generate and run separate satelite menubox and default astra | |
96 | echo '#!/bin/bash' > /tmp/w_scan_satselect.sh | |
bb91f5a5 | 97 | echo 'whiptail --checklist "\nSelect satellites" 19 70 10 \' >> /tmp/w_scan_satselect.sh |
7e616a32 | 98 | $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 | 99 | echo ' 2>/tmp/w_scan_satellite' >> /tmp/w_scan_satselect.sh |
7e616a32 AF |
100 | sh /tmp/w_scan_satselect.sh |
101 | chk_cancel | |
102 | rm /tmp/w_scan_satselect.sh | |
bb91f5a5 AF |
103 | W_SCAN_SATELLITE=$(cat /tmp/w_scan_satellite | sed 's|"||g') |
104 | rm /tmp/w_scan_satellite | |
7e616a32 AF |
105 | fi |
106 | ||
107 | # Now start the scan ... | |
108 | clear | |
109 | rm -rf /tmp/channels.conf | |
110 | if [[ "$W_SCAN_TYPE" == *DVB-T* ]]; then | |
bb91f5a5 | 111 | echo ":->W-SCAN DVB-T $(date +%Y%m%d%H%M)" >>/tmp/channels.conf |
22f94778 | 112 | $WSCAN -f t -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf |
7e616a32 AF |
113 | fi |
114 | if [[ "$W_SCAN_TYPE" == *DVB-C* ]]; then | |
bb91f5a5 | 115 | echo ":->W-SCAN DVB-C $(date +%Y%m%d%H%M)" >>/tmp/channels.conf |
22f94778 | 116 | $WSCAN -f c -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf |
7e616a32 AF |
117 | fi |
118 | if [[ "$W_SCAN_TYPE" == *DVB-S* ]]; then | |
bb91f5a5 | 119 | for SATELLITE in $W_SCAN_SATELLITE; |
7e616a32 | 120 | do |
bb91f5a5 | 121 | echo ":->W-SCAN DVB-S $SATELLITE $(date +%Y%m%d%H%M)" >>/tmp/channels.conf |
22f94778 | 122 | $WSCAN -f s -s $SATELLITE -C UTF-8 -o 7 >>/tmp/channels.conf |
7e616a32 AF |
123 | done |
124 | fi | |
e200ab58 AF |
125 | if [[ "$W_SCAN_TYPE" == *ATSC-T* ]]; then |
126 | echo ":->W-SCAN ATSC-T $(date +%Y%m%d%H%M)" >>/tmp/channels.conf | |
127 | $WSCAN -f a -A 1 -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf | |
128 | fi | |
129 | if [[ "$W_SCAN_TYPE" == *ATSC-C* ]]; then | |
130 | echo ":->W-SCAN ATSC-C $(date +%Y%m%d%H%M)" >>/tmp/channels.conf | |
131 | $WSCAN -f a -A 2 -c $W_SCAN_COUNTRY -C UTF-8 -o 7 >>/tmp/channels.conf | |
132 | fi | |
7e616a32 AF |
133 | |
134 | # Save result to current dir. | |
135 | cp /tmp/channels.conf w_scan-$(date +%Y%m%d%H%M).channels.conf | |
136 | echo Results saved to w_scan-$(date +%Y%m%d%H%M).channels.conf | |
137 | ||
138 | # Do this only if vdr is installed ... | |
139 | if [ -e /opt/pakfire/db/installed/meta-vdr ]; then | |
bb91f5a5 | 140 | yes_no "Install new channels-conf for VDR." |
7e616a32 | 141 | # Backup old channels conf... |
d2a94495 AF |
142 | cp -f /etc/vdr/channels.conf \ |
143 | /etc/vdr/channels.conf.backup$(date +%Y%m%d%H%M) | |
144 | cp -f /tmp/channels.conf /etc/vdr/ | |
bb91f5a5 | 145 | yes_no "Should i start the VDR?" |
7e616a32 AF |
146 | clear |
147 | /etc/init.d/vdr start | |
148 | fi |