Skip to content

Commit

Permalink
write the current version and check if there's an update
Browse files Browse the repository at this point in the history
  • Loading branch information
maddox committed Dec 2, 2020
1 parent 3f452dd commit b2f6656
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,30 @@ 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
node index.js
LAST_RAN=date
sed "s/XXX/$($LAST_RAN)/g" index.html > "$NGINX_ROOT/index.html"

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

sed -e "s/LAST_RAN/$LAST_RAN/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/playlist.m3u"
mv epg.xml "$NGINX_ROOT/epg.xml"
echo "Last ran: $($LAST_RAN)"
Expand Down

0 comments on commit b2f6656

Please sign in to comment.