Skip to content

Instantly share code, notes, and snippets.

@Demiu
Created November 19, 2016 17:59
Show Gist options
  • Save Demiu/d0a08c7024183c04e25cda1740215345 to your computer and use it in GitHub Desktop.
Save Demiu/d0a08c7024183c04e25cda1740215345 to your computer and use it in GitHub Desktop.
#!/bin/sh
update() {
echo "Downloading lastest version..."
wget -q --show-progress http://downloads.counterplay.co/duelyst/v$VERSION/duelyst-v$VERSION-win32-x64.zip
echo "Extracting lastest version..."
unzip -q "duelyst-v$VERSION-win32-x64.zip" -d "duelyst-v$VERSION"
#Edit to run on Linux
echo "Editing files..."
cd duelyst-v$VERSION/resources/app
sed -i "s/app.on('ready', function () {/app.on('ready', function () {\n argv.token = '32432543254'\n/" desktop.js
sed -i "/if (pkgJson.name === 'duelyst' && argv.token === undefined) {/,+12d" desktop.js
sed -i "s/fullscreen: \!argv.windowed/fullscreen: false/" desktop.js
sed -i "s/if (process.platform === 'win32') setupWin32Shortcuts()/if (process.platform === 'win32' || process.platform === 'linux') setupWin32Shortcuts()/" desktop.js
#Install dependencies through npm
echo "Insalling duelyst dependencies..."
npm install electron-packager --silent
npm install electron --save --silent
#Package game
echo "Packaging..."
./node_modules/.bin/electron-packager . $npm_package_product_name --asar --platform=linux --overwrite --arch=x64 --app-version=$npm_package_version --icon=icon.icns --out=build --ignore='build|node_modules/gulp-*|node_modules/(electron-packager|electron-prebuilt|electron-rebuild|electron-windows-installer|electron-connect|gulp|tape)'
echo "Moving build..."
rm -rf ../../../Duelyst-linux-x64
mv build/Duelyst-linux-x64/ ../../..
mv icon.png ../../../icon.png
echo "Removing temporary files from download..."
cd ../../..
rm -rf duelyst-v$VERSION*
echo "Saving current version..."
echo $VERSION > version
echo "Making a .desktop launcher..."
echo "[Desktop Entry]" > ~/.local/share/applications/Duelyst.desktop
echo "Name=Duelyst" >> ~/.local/share/applications/Duelyst.desktop
echo "Comment=The ULTIMATE collectible tactics game. Competitive head-to-head turn-based battles at its best!" >> ~/.local/share/applications/Duelyst.desktop
echo "Exec=$DIR/duelyst.sh" >> ~/.local/share/applications/Duelyst.desktop
echo "Icon=$DIR/icon.png" >> ~/.local/share/applications/Duelyst.desktop
echo "Terminal=false" >> ~/.local/share/applications/Duelyst.desktop
echo "Type=Application" >> ~/.local/share/applications/Duelyst.desktop
echo "Categories=Game;" >> ~/.local/share/applications/Duelyst.desktop
}
echo "Navigating to directory..."
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
echo "Checking dependencies..."
echo -n "curl... "
hash curl 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that curl is installed and avaiable" ; exit 1;}
echo -en "\nwget... "
hash wget 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that wget is installed and avaiable" ; exit 1;}
echo -en "\ngrep... "
hash grep 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that grep is installed and avaiable" ; exit 1;}
echo -en "\ntail... "
hash tail 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that tail is installed and avaiable" ; exit 1;}
echo -en "\ncat... "
hash cat 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that tail is installed and avaiable" ; exit 1;}
echo -en "\nhead... "
hash head 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that head is installed and avaiable" ; exit 1;}
echo -en "\nunzip... "
hash unzip 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that unzip is installed and avaiable" ; exit 1;}
echo -en "\nsed... "
hash sed 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that sed is installed and avaiable" ; exit 1;}
echo -en "\nnpm... "
hash npm 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that npm is installed and avaiable" ; exit 1;}
echo -en "\ndirname... "
hash dirname 2>/dev/null || { echo -e "[FAIL]\nPlease ensure that dirname is installed and avaiable"; exit 1;}
echo -e "\nALL OK"
echo "Checking lastest version..."
VERSION=$(curl -# https://updates.counterplay.co/ | grep duelyst |grep -v staging | grep zip | tail -c 18 | head -c 6)
echo "Found version $VERSION"
#Check if file local exists
if [ -f version ]; then
LOCAL_VERSION=$(cat version)
if [ ! "$LOCAL_VERSION" == "$VERSION" ]; then
#If local version doesn't match lastest then update
update
fi
else
#If local version file doesn't already exists then game is not installed, install
update
fi
echo "Launching game..."
./Duelyst-linux-x64/Duelyst -w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment