Skip to content

Instantly share code, notes, and snippets.

@xstar97
Created October 11, 2022 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xstar97/769878e95e4c505d7339fc840b88c82e to your computer and use it in GitHub Desktop.
Save xstar97/769878e95e4c505d7339fc840b88c82e 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 SteamPrefill
#!/bin/bash
Cyan='\033[0;36m'
RED='\033[0;31m'
Yellow='\033[0;33m'
NC='\033[0m' # No Color
cd /data
# make steam dir
if [ -d "Steam" ]
then
echo "Directory `Steam` exists."
else
echo "Creating Steam dir"
mkdir Steam
fi
cd Steam
# 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_STEAM="https://api.github.com/repos/tpill90/steam-lancache-prefill/releases"
LATEST_TAG_STEAM=$(curl -s $VERSION_API_STEAM | jq -r '.[0].tag_name' | cut -c 2-)
if [ -z "${LATEST_TAG_STEAM}" ]; then
echo -e " ${RED}Something went wrong, unable to get latest version!${NC}"
exit 1
fi
echo -e " Found latest version : ${Cyan} ${LATEST_TAG_STEAM} ${NC}"
# Downloading latest version
echo -e "${Yellow} Downloading... ${NC}"
DOWNLOAD_URL_STEAM="https://github.com/tpill90/steam-lancache-prefill/releases/download/v${LATEST_TAG_STEAM}/SteamPrefill-${LATEST_TAG_STEAM}-linux-x64.zip"
wget -q -nc --show-progress --progress=bar:force:noscroll $DOWNLOAD_URL_STEAM
# Unzip
echo -e "${Yellow} Unzipping... ${NC}"
unzip -q -j -o SteamPrefill-${LATEST_TAG_STEAM}-linux-x64.zip
# Cleanup
rm SteamPrefill-${LATEST_TAG_STEAM}-linux-x64.zip
chmod +x SteamPrefill
if [ -f update.sh ]
then
chmod +x update.sh
else
echo update file doesnt exists.
fi
echo -e " ${Cyan} Complete! ${NC}"
@Albatrosicks
Copy link

Albatrosicks commented Oct 28, 2022

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

@xstar97
Copy link
Author

xstar97 commented Oct 28, 2022

I suggest using the following command instead of unzip: perl -e "use Archive::Extract;(Archive::Extract->new(archive => 'SteamPrefill-${LATEST_TAG_STEAM}-linux-x64.zip'))->extract;" Because unzip is not available in many places by default

Great suggestion. I'll test it out and add it later. But you should make a pr to the upstream script instead :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment