forked from localhosthack0r/kingofsat2satip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIO_do_sorta_ftadiseqc_setup_openwrt.sh
135 lines (125 loc) · 3.79 KB
/
AIO_do_sorta_ftadiseqc_setup_openwrt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# configure SATIP server name/IP address, here
#SERVER="192.168.178.42"
SERVER="192.168.1.113"
echo your server ip adress is $SERVER
# T1 = tuner 1,T2 = tuner 2,T3 = tuner3,T4 = tuner 4
# P1 = diseqc A,P2 = diseqc B,P3 = diseqc C,P4 = diseqc D
#tuner 1
T1P1=39.0E
T1P2=42.0E
T1P3=46.0E
T1P4=50.0E
#tuner 2
T2P1=26.0E
T2P2=28.2E
T2P3=31.0E
T2P4=36.0E
#tuner 3
T3P1=16.0E
T3P2=19.2E
T3P3=21.5E
T3P4=23.5E
#tuner 4
T4P1=4.8E
T4P2=7.0E
T4P3=10.0E
T4P4=13.0E
DIR=($T1P1 $T1P2 $T1P3 $T1P4 $T2P1 $T2P2 $T2P3 $T2P4 $T3P1 $T3P2 $T3P3 $T3P4 $T4P1 $T4P2 $T4P3 $T4P4)
echo your configured sat positions "${DIR[@]}"
OUTFILES=(*.php *.m3u /tmp/*.m3u )
echo cleaning
if [ -f $OUTFILES ]; then
rm $OUTFILES
fi
echo cleaned
echo setting positions sources
rm -r "${DIR[@]}"
mkdir "${DIR[@]}"
echo '1' > $T1P1/N
echo '2' > $T1P2/N
echo '3' > $T1P3/N
echo '4' > $T1P4/N
echo '1' > $T2P1/N
echo '2' > $T2P2/N
echo '3' > $T2P3/N
echo '4' > $T2P4/N
echo '1' > $T3P1/N
echo '2' > $T3P2/N
echo '3' > $T3P3/N
echo '4' > $T3P4/N
echo '1' > $T4P1/N
echo '2' > $T4P2/N
echo '3' > $T4P3/N
echo '4' > $T4P4/N
echo positions have settings
echo fetching files from site
# download PHP files from kingofsat
for i in "${DIR[@]}";
do
cd $i
wget https://de.kingofsat.net/tv-$i-fta.php
cd ..
done
echo files fetched
echo creating m3u lists for each position
for i in "${DIR[@]}";
do
cd $i
src=$(cat "N")
python ../getchannels.py $SERVER tv-$i-fta.php $src
cd ..
done
echo basic m3u sat playlist created
echo creating FTA dir with today date
mkdir FTA
mkdir FTA/$(date +%F)
echo Directories setted up
echo apllying necessary corrections
for i in "${DIR[@]}";
do
sed 's/pol=V/pol=v/g' $i/tv-$i-fta.m3u > /tmp/tv-$i-fta.m3u && sed 's/pol=H/pol=h/g' /tmp/tv-$i-fta.m3u > FTA/$(date +%F)/TV-$i-FTA-$(date +%F)-$(date +%M).m3u
done
echo corrections applied succesfully
echo merging m3u to one playlist
cat FTA/$(date +%F)/*.m3u > FTA/$(date +%F)/allChannels.m3u
echo playlists merged
echo corrections for merged playlists
sed 's/pol=V/pol=v/g' FTA/$(date +%F)/allChannels.m3u > /tmp/allChannels.m3u && sed 's/pol=H/pol=h/g' /tmp/allChannels.m3u > FTA/$(date +%F)/ALL_FTA-$(date +%F)-$(date +%M).m3u
echo all done
echo playlist file for each configured and all in one positions ALL_FTA-$(date +%F)-$(date +%M).m3u is in "FTA / $(date +%F)" Directory
rm FTA/$(date +%F)/allChannels.m3u
rm -r "${DIR[@]}"
mkdir DATABASE
list_new=FTA/$(date +%F)/ALL_FTA-$(date +%F)-*.m3u
list_old=FTA/$(date -d "yesterday" +%F)/ALL_FTA-$(date -d "yesterday" +%F)-*.m3u
grep -Fxvf $list_new $list_old >> DATABASE/removed-$(date +%F)-$(date +%M).m3u
grep -Fxvf $list_old $list_new >> DATABASE/added-$(date +%F)-$(date +%M).m3u
cat DATABASE/removed*.m3u >> AllRemoved.m3u
cat DATABASE/added*.m3u >> Alladded.m3u
echo preparing files for openwrt "uhttpd" service place /www/ on router , TIP: install cmd for uhttpd : "opkg update && opkg install uhttpd" in ssh session on openwrt router
mkdir openwrt_www
IP=$(/sbin/ip route | awk '/default/ { print $3 }')
cp FTA/$(date +%F)/ALL_FTA-$(date +%F)-$(date +%M).m3u openwrt_www/ALL_SAT_FTA.m3u
cp Alladded.m3u AllRemoved.m3u openwrt_www/
for i in "${DIR[@]}";
do
cp FTA/$(date +%F)/TV-$i-FTA-$(date +%F)-$(date +%M).m3u openwrt_www/$i.m3u
done
echo '#EXTM3U' > Master.m3u
echo '#EXTINF:0,source=ALL_SAT_FTA' >> Master.m3u
echo "http://$IP/ALL_SAT_FTA.m3u" >> Master.m3u
echo '#EXTM3U' >> Master.m3u
echo '#EXTINF:0,source=AllRemoved' >> Master.m3u
echo "http://$IP/AllRemoved.m3u" >> Master.m3u
echo '#EXTM3U' >> Master.m3u
echo '#EXTINF:0,source=Alladded' >> Master.m3u
echo "http://$IP/Alladded.m3u" >> Master.m3u
for i in "${DIR[@]}";
do
echo "#EXTINF:0,Sat=${i}" >> Master.m3u
echo "http://$IP/${i}.m3u" >> Master.m3u
done
mv Master.m3u openwrt_www/
echo files for openwrt ready
rm -r FTA/