/ programs / x86_64 / wine
wine
 1  #!/usr/bin/env bash
 2  
 3  APP=wine
 4  SITE="mmtrt/WINE_AppImage"
 5  
 6  # CREATE DIRECTORIES
 7  if [ -z "$APP" ]; then exit 1; fi
 8  mkdir -p "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
 9  
10  # ADD THE REMOVER
11  echo "#!/bin/sh
12  rm -f /usr/local/bin/$APP /usr/local/bin/wine64
13  rm -R -f /opt/$APP" > "/opt/$APP/remove"
14  chmod a+x "/opt/$APP/remove"
15  
16  # DOWNLOAD AND PREPARE THE APP
17  # $version is also used for updates
18  
19  printf "%s\n" "$(curl -Ls https://api.github.com/repos/"$SITE"/releases \
20  	| grep browser_download_url | cut -d '"' -f 4)" | tr ' ' '\n' | grep -i appimage | grep -v zsync >> ./wine-args
21  printf "Select a URL from this menu (read carefully) or press CTRL+C to abort:\n-----------------------------------------------------------------------\n"; sleep 1;
22  	select version in $(cat ./wine-args | sort -u | uniq); do test -n "$version" && break; echo ">>> Invalid Selection"; done
23  wget "$version"
24  wget "$version.zsync" 2> /dev/null
25  echo "$version" >> /opt/$APP/version
26  # Use tar fx ./*tar* for example in this line in case a compressed file is downloaded.
27  cd ..
28  mv ./tmp/*mage ./"$APP"
29  mv ./tmp/*.zsync ./"$APP".zsync 2> /dev/null
30  chmod a+x "/opt/$APP/$APP"
31  rm -R -f ./tmp
32  
33  # LINK
34  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
35  ln -s "/usr/local/bin/$APP" "/usr/local/bin/wine64"
36  
37  # SCRIPT TO UPDATE THE PROGRAM
38  cat >> "/opt/$APP/AM-updater" << 'EOF'
39  #!/bin/sh
40  APP=wine
41  SITE="mmtrt/WINE_AppImage"
42  if [ -z "$APP" ]; then exit 1; fi
43  version0=$(cat "/opt/$APP/version")
44  tag=$(echo "$version0" | tr '/' '\n' | tail -2 | head -1)
45  version=$(curl -Ls https://api.github.com/repos/mmtrt/WINE_AppImage/releases | grep browser_download_url | grep -i "download/$tag/$app" | grep -i appimage | cut -d '"' -f 4 | head -1)
46  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
47  if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then
48  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
49  	[ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait"
50  	[ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; }
51  	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
52  	cd ..
53  	mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP"
54  	[ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; }
55  	chmod a+x ./"$APP" || exit 1
56  	echo "$version" > ./version
57  	rm -R -f ./*zs-old ./*.part ./tmp ./*~
58  	notify-send "$APP is updated!"
59  else
60  	echo "Update not needed!"
61  fi
62  EOF
63  chmod a+x "/opt/$APP/AM-updater"