Skip to content

Instantly share code, notes, and snippets.

@TopperBG
Created November 10, 2022 08:01
Show Gist options
  • Save TopperBG/819defe31db0eaccb7f0c8a10d349699 to your computer and use it in GitHub Desktop.
Save TopperBG/819defe31db0eaccb7f0c8a10d349699 to your computer and use it in GitHub Desktop.
TorrServer update file
#!/bin/bash
#TorrServer don't have docker image at least not often updated so I create script to build one from latest github tag
REPO="YouROK/TorrServer"
WORKDIR="/root/Docker/TorrServer/"
cd $WORKDIR
TARGETVER=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | awk -F '"' '/tag_name/{print $4}')
CURRENTVER=$(< current.ver)
echo "$TARGETVER" > target.ver
if [[ "$TARGETVER" != "$CURRENTVER" ]]; then
docker stop TorrServer
echo "Updating ..."
sed -i "s/^\(ENV TS_VERSION\s*=\s*\).*$/\1$TARGETVER/" Dockerfile
docker rm TorrServer
echo "$TARGETVER" > current.ver
docker build -t torrserver:$TARGETVER .
docker run -d --name TorrServer --restart=always -v /torrserver/db:/torrserver/db -p 8090:8090 torrserver:$TARGETVER
docker start TorrServer
else
echo "Already have latest TorrServer $CURRENTVER"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment