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