Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #SETTINGS
- DLL="CleanChat-AutoClearChannel.dll"
- VERSION_URL="http://drive.alexandernorup.com/CleanChat/latest.txt"
- DOWNLOAD_URL="http://drive.alexandernorup.com/CleanChat/latest.zip"
- #Thanks to "Paused until further notice." on Stackoverflow <3
- #https://stackoverflow.com/a/4025065
- vercomp () {
- if [[ $1 == $2 ]]
- then
- return 0
- fi
- local IFS=.
- local i ver1=($1) ver2=($2)
- # fill empty fields in ver1 with zeros
- for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
- do
- ver1[i]=0
- done
- for ((i=0; i<${#ver1[@]}; i++))
- do
- if [[ -z ${ver2[i]} ]]
- then
- # fill empty fields in ver2 with zeros
- ver2[i]=0
- fi
- if ((10#${ver1[i]} > 10#${ver2[i]}))
- then
- return 1
- fi
- if ((10#${ver1[i]} < 10#${ver2[i]}))
- then
- return 2
- fi
- done
- return 0
- }
- testvercomp () {
- vercomp $1 $2
- case $? in
- 0) op='=';;
- 1) op='>';;
- 2) op='<';;
- esac
- if [[ $op != $3 ]]
- then
- echo "Server is up to date!"
- start_server
- return 0
- else
- do_update $2
- fi
- }
- get_version() {
- strings $DLL | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
- }
- get_latest_version() {
- curl -s --user-agent "CleanChat Auto Updater" $VERSION_URL
- }
- do_update () {
- echo "New update ready to download: v. $1"
- curl -o "update.zip" --user-agent "CleanChat AutoUpdater" $DOWNLOAD_URL
- echo "Update downloaded!"
- unzip -o "update.zip"
- rm "update.zip"
- echo "Update installed!"
- start_server
- }
- start_server () {
- echo "Starting server..."
- dotnet $DLL
- }
- VERSION=$(get_version)
- NEWEST=$(get_latest_version)
- echo "Checking for updates..."
- echo "Current version: $VERSION"
- echo "Newest version: $NEWEST"
- testvercomp $VERSION $NEWEST '<'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement