Skip to content

Instantly share code, notes, and snippets.

@chirvo
Created November 20, 2022 10:50
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 chirvo/fae590490cbc3a067afb678e95c500a9 to your computer and use it in GitHub Desktop.
Save chirvo/fae590490cbc3a067afb678e95c500a9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://askubuntu.com/questions/755059/how-do-i-get-the-latest-version-of-winetricks-on-ubuntu
URL="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
if [ "$1" == "--user" ]
then
DESTINATION="$HOME/.local/bin"
SUDO=""
else
DESTINATION="/usr/local/bin"
SUDO="sudo"
fi
CURRENT=$(whereis -b winetricks | cut -f2 -d' ')
if [ "$CURRENT" == "winetricks:" ]
then
CURRENT="none"
fi
if [ "$CURRENT" == "/usr/bin/winetricks" ]
then
echo "Winetricks already installed on $CURRENT. To proceed please uninstall it first. Exiting."
exit 1
fi
LATEST=$(curl --silent --show-error $URL --stderr - | grep ^WINETRICKS_VERSION | cut -d '=' -f 2)
echo
echo "Winetricks installed version: $($CURRENT --version)"
echo "Winetricks latest available version: $LATEST"
echo
read -p "Do you want to proceed? (yes/no) " YN
case $YN in
yes ) echo ok, we will proceed;;
no ) echo Exiting.;
exit;;
* ) echo Invalid response. Bailing out!;
exit 2;;
esac
TMPFILE="/tmp/winetricks.$(date +%H%M%S)"
echo "Installing Winetricks on $DESTINATION... "
cd /tmp && \
wget $URL -O $TMPFILE && \
$SUDO mv $TMPFILE $DESTINATION/winetricks && \
$SUDO chmod 755 $DESTINATION/winetricks
[ $? -eq 0 ] && echo "Done!" || echo "Error while trying to install winetricks. Bailing out!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment