-
Notifications
You must be signed in to change notification settings - Fork 30
/
entrypoint.sh
executable file
·47 lines (35 loc) · 1.26 KB
/
entrypoint.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
#!/bin/sh
cd /usr/src/app
nginx
NGINX_ROOT=/usr/share/nginx/html
get_latest_release() {
curl --silent "https://api.github.com/repos/maddox/pluto-for-channels/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
while :
do
START=$START node index.js $VERSIONS
CURRENT_VERSION=`cat VERSION`
LATEST_VERSION=`get_latest_release`
UPDATE_AVAILABLE=""
LAST_RAN=`date`
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
UPDATE_AVAILABLE="\<a href='https\:\/\/github.com\/maddox\/pluto-for-channels\/releases\/tag\/$LATEST_VERSION'\>\<span class='tag is-warning'\\>UPDATE AVAILABLE\: $LATEST_VERSION\<\/span\>\<\/a\>"
fi
LINKED_VERSIONS=""
for i in $(echo $VERSIONS | sed "s/,/ /g")
do
LINKED_VERSIONS="$LINKED_VERSIONS \<ul\>\<li\>\<a href='\/$i-playlist.m3u'\>$i Playlist\<\/a\>\<\/li\>\<li\>\<a href='\/$i-epg.xml'\>$i EPG\<\/a\>\<\/li\>\<\/ul\>"
done
echo $LINKED_VERSIONS
sed -e "s/LAST_RAN/$LAST_RAN/g" \
-e "s/LINKED_VERSIONS/$LINKED_VERSIONS/g" \
-e "s/VERSION/$CURRENT_VERSION/g" \
-e "s/UPDATE_AVAILABLE/$UPDATE_AVAILABLE/g" \
index.html > "$NGINX_ROOT/index.html"
mv *playlist.m3u "$NGINX_ROOT"
mv *epg.xml "$NGINX_ROOT"
echo "Last ran: $LAST_RAN"
sleep 10800 # run every 3 hours
done