Created
October 11, 2022 19:05
-
-
Save xstar97/ebb42ccbd9b00a1407e363dbd917309b to your computer and use it in GitHub Desktop.
A modified script from https://github.com/tpill90/steam-lancache-prefill/blob/master/scripts/update.sh to install & update BattleNetPrefill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
Cyan='\033[0;36m' | |
RED='\033[0;31m' | |
Yellow='\033[0;33m' | |
NC='\033[0m' # No Color | |
cd /data | |
# make BattleNet dir | |
if [ -d "BattleNet" ] | |
then | |
echo "Directory `BattleNet` exists." | |
else | |
echo "Creating BattleNet dir" | |
mkdir BattleNet | |
fi | |
cd BattleNet | |
# Checking for required software | |
if ! [ -x "$(command -v curl)" ]; then | |
echo -e "${RED}Required software curl is not installed.${NC}" >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v jq)" ]; then | |
echo -e "${RED}Required software jq is not installed.${NC}" >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v unzip)" ]; then | |
echo -e "${RED}Required software unzip is not installed.${NC}" >&2 | |
exit 1 | |
fi | |
# Getting latest version tag | |
echo -e "${Yellow} Checking for latest version ${NC}" | |
VERSION_API_BATTLENET="https://api.github.com/repos/tpill90/battlenet-lancache-prefill/releases" | |
LATEST_TAG_BATTLENET=$(curl -s $VERSION_API_BATTLENET | jq -r '.[0].tag_name' | cut -c 2-) | |
if [ -z "${LATEST_TAG_BATTLENET}" ]; then | |
echo -e " ${RED}Something went wrong, unable to get latest version!${NC}" | |
exit 1 | |
fi | |
echo -e " Found latest version : ${Cyan} ${LATEST_TAG_BATTLENET} ${NC}" | |
# Downloading latest version | |
echo -e "${Yellow} Downloading... ${NC}" | |
DOWNLOAD_URL_BATTLENET="https://github.com/tpill90/battlenet-lancache-prefill/releases/download/v${LATEST_TAG_BATTLENET}/BattleNetPrefill-${LATEST_TAG_BATTLENET}-linux-x64.zip" | |
wget -q -nc --show-progress --progress=bar:force:noscroll $DOWNLOAD_URL_BATTLENET | |
# Unzip | |
echo -e "${Yellow} Unzipping... ${NC}" | |
unzip -q -j -o BattleNetPrefill-${LATEST_TAG_BATTLENET}-linux-x64.zip | |
# Cleanup | |
rm BattleNetPrefill-${LATEST_TAG_BATTLENET}-linux-x64.zip | |
chmod +x BattleNetPrefill | |
if [ -f update.sh ] | |
then | |
chmod +x update.sh | |
else | |
echo update file doesnt exists. | |
fi | |
echo -e " ${Cyan} Complete! ${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest using the following command instead of unzip:
unzip(){ python3-c "from zipfile import PyZipFile; PyZipFile( '''$1''' ).extractall()"; }
Because unzip is not available in many places by default