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