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