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