-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
145 lines (136 loc) · 5.06 KB
/
setup.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
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
#
# v1.2
echo "uninstalling previous version of this script"
# Remove old script data
rm /etc/epgimport/new.EPG.sources.xml
rm /etc/hdd/epg/iptvepg.xml.gz
# Removing Cron
cron=$(crontab -l | grep -F "00 06 * * * cd /usr/script/ && ./xmltv.sh " | wc -m)
if [ $cron -eq "0" ]; then
echo "no cron found"
else
crontab -l | grep -v "00 06 \* \* \* cd /usr/script/ && ./xmltv.sh " | crontab -
echo
echo "Old cron removed"
fi
cron=$(crontab -l | grep -F "59 05 * * * cd /usr/script/ && ./xmltv.sh " | wc -m)
if [ $cron -eq "0" ]; then
echo "no cron found"
else
crontab -l | grep -v "59 05 \* \* \* cd /usr/script/ && ./xmltv.sh " | crontab -
echo
echo "Old cron removed"
fi
cron=$(crontab -l | grep -F "10 06 * * * cd /usr/script/ && ./xmltv.sh " | wc -m)
if [ $cron -eq "0" ]; then
echo "no cron found"
else
crontab -l | grep -v "10 06 \* \* \* cd /usr/script/ && ./xmltv.sh " | crontab -
echo
echo "Old cron removed"
fi
xmltv=$(cd /usr/script/ && ls -d *xmltv.sh* | wc -l)
if [ $xmltv -eq "1" ]; then
graburl=$(grep -o 'url=".*$' /usr/script/xmltv.sh | cut -c6- | cut -f 1 -d '"')
echo $graburl
grabxmltvfilename=$(grep -o 'xmltvfilename=".*$' /usr/script/xmltv.sh | cut -c16- | cut -f 1 -d '"')
echo $grabxmltvfilename
grabsource=$(grep -o 'source=".*$' /usr/script/xmltv.sh | cut -c9- | cut -f 1 -d '"')
echo $grabsource
pathh=$(grep -o '\[CDATA\[.*$' $grabsource | cut -c8- | cut -f 1 -d "]")
if [ "$pathh" == "$grabxmltvfilename".gz ]; then
sed -i "s|$grabxmltvfilename.gz|\\&|" $grabsource
sed -i "s|\\&|$graburl|" $grabsource
rm ${grabxmltvfilename}.gz
echo "Original iptv url replaced in $grabsource"
else
echo "Iptv url already exists in $grabsource"
fi
fi
echo "starting new installation"
workdir="/media/hdd/epg"
epgimport="/etc/epgimport"
echo
echo "This script will fix EPG offset issue for IPTV i.e. if your epg is ahead or behind and showing wrong program information.
You can adjust the offset time between any range from 1 minute to up to 23 hours."
echo
sleep 6
count=$(cd ${epgimport}/ && ls -d *jmx.*.sources.xml* | wc -l)
if [ $count -eq "1" ]; then
filename=$(find ${epgimport}/ -name "jmx.*.sources.xml" -exec basename {} \;)
echo "One jedimaker playlist found: $filename, proceeding installation..."
sleep 2
else
echo "Enter full file name from below list starting with jmx.XXXX.sources.xml, For example: You want to fix EPG offset for provider's playlist named IPTV in jedimakerxtreme then you should look for file named jmx.IPTV.sources.xml"
echo
find $epgimport/ -name "jmx.*.sources.xml" -exec basename {} \;
echo
read -p "Enter file name: " filename
fi
filename1=$(cd ${epgimport}/ && ls ${filename})
if [ "$filename1" == "$filename" ]; then
echo
else
echo "Wrong input installation aborted. Try to run the script again by typing ./setup.sh below and hit enter"
echo
exit
fi
echo
echo "Enter the time you would like to offset including +/-HHMM
Example:
your epg is half an hour ahead then put -0030
your epg is an hour ahead then put -0100
your epg is two hours ahead then put -0200
your epg is half an hour behind then put +0030
your epg is an hour behind then put +0100
your epg is two hours behind then put +0200, and so on.."
echo
read -p "Enter time: " time
echo
echo $filename
echo
echo $time
if [ ! -d "${workdir}" ]; then
mkdir -p "${workdir}"
fi
source="${epgimport}/$filename"
# get url from source file
url=$(grep -o "<url><\!\[\CDATA.*$" ${source} | cut -c 15- | cut -f 1 -d ']')
echo $url
#get name from source file, remove illegal file characters with underscore and make lower case
name=$(grep -o 'catname=.*$' ${source} | cut -c10- | cut -f 1 -d '"' | \
sed -e 's|<|_|g; s|>|_|g; s|:|_|g; s|"|_|g; s|/|_|g; s|\\|_|g; s/|/_/g; s|?|_|g; s|*|_|g; s| |_|g')
echo $name
insdir="/usr/script"
if [ ! -d "${insdir}" ]; then
mkdir -p "${insdir}"
fi
#download xmltv file (xmltv.sh) to filename $xmltvfilename - replace old time with new time
xmltvfilename="${workdir}/${name}.xml"
echo $xmltvfilename
wget -O /usr/script/xmltv.sh "https://github.com/ravstar/Enigma2/raw/main/xmltv.sh"
sed -i "s|\\&|$url|" "/usr/script/xmltv.sh"
sed -i "s|dddddd|$xmltvfilename|; s|tttttt|$time|; s|ssssss|$source|" "/usr/script/xmltv.sh"
cd /usr/script/ && chmod 755 xmltv.sh
wget -O /usr/script/uninstall1.sh "https://github.com/ravstar/Enigma2/raw/main/uninstall1.sh"
sed -i "s|dddddd|$xmltvfilename|; s|tttttt|$time|; s|ssssss|$source|" "/usr/script/uninstall1.sh"
cd /usr/script/ && chmod 755 uninstall1.sh
crontab -l | { cat; echo "10 06 * * * cd /usr/script/ && ./xmltv.sh "; } | crontab -
echo "Daily cron added to run script daily at 06:10am"
HHMM=$(wget -qO- "$url" | awk -F 'start="' '{print $2;exit;}' | cut -c15- | cut -f 1 -d '"' | tail -n +1 | head -1)
echo
echo "xml HHMM is $HHMM"
echo
if [ $HHMM -eq "+0000" ]; then
cd /usr/script/ &&./xmltv.sh
else
echo "ERROR: Script has been installed though it won't work until you follow one more step manually. Please make a note of following text"
echo
echo "My xml HHMM is: $HHMM and I want to adjust it by: $time"
echo
echo "Please follow the additional step mentioned in original post or reach out to 'ravstar'"
echo
fi
rm /tmp/setup.sh
exit