/
openarena
90 lines (73 loc) · 2.14 KB
/
openarena
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
APP=openarena
CATEGORIES="Game"
ICONURL="https://upload.wikimedia.org/wikipedia/commons/f/f0/Openarena-logo.svg"
URL=https://aur.archlinux.org/packages/openarena
COMMENT="A violent, sexy, multiplayer first person shooter based on the ioquake3 engine"
APPNAME=OpenArena
# CREATE THE FOLDER
mkdir /opt/$APP
cd /opt/$APP
# ADD THE REMOVER
echo '#!/bin/sh' >> /opt/$APP/remove
echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/games/$APP" >> /opt/$APP/remove
chmod a+x /opt/$APP/remove
# DOWNLOAD THE ZIP ARCHIVE
mkdir tmp
cd ./tmp
version=$(curl -Ls https://aur.archlinux.org/packages/openarena | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep .zip | head -1)
wget $version
dir=$(ls . | rev | cut -c 5- | rev)
echo "$version" >> /opt/$APP/version
unzip -qq ./*.zip
cd ..
mv ./tmp/$dir/* ./
rm -R -f ./tmp
# LINK
cat >> /usr/local/games/$APP << 'EOF'
#!/bin/sh
APP=openarena
exec /opt/$APP/$APP.x86_64
EOF
chmod a+x /usr/local/games/$APP
# SCRIPT TO UPDATE THE PROGRAM
cat >> /opt/$APP/AM-updater << 'EOF'
#!/usr/bin/env bash
APP=openarena
version0=$(cat /opt/$APP/version)
url=https://aur.archlinux.org/packages/openarena
if curl -L -s $url | grep -ioF "$version0"; then
echo "Update not needed!"
else
notify-send "A new version of $APP is available, please wait"
mkdir /opt/$APP/tmp
cd /opt/$APP/tmp
version=$(curl -Ls https://aur.archlinux.org/packages/openarena | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep .zip | head -1)
wget $version
dir=$(ls . | rev | cut -c 5- | rev)
unzip -qq ./*.zip
cd ..
if test -f ./tmp/*.zip; then rm ./version
fi
echo $version >> ./version
mv --backup=t ./tmp/$dir/* ./
chmod a+x /opt/$APP/$APP
rm -R -f ./tmp ./*~
notify-send "$APP is updated!"
fi
EOF
sed -i s/FILENAMEEXTENTION/$FILENAMEEXTENTION/g /opt/$APP/AM-updater
chmod a+x /opt/$APP/AM-updater
# LAUNCHER
rm -f /usr/share/applications/AM-$APP.desktop
echo "[Desktop Entry]
Name=$APPNAME
Exec=$APP
Icon=/opt/$APP/icons/$APP
Type=Application
Terminal=false
Categories=$CATEGORIES;
Comment=$COMMENT" >> /usr/share/applications/AM-$APP.desktop
# ICON
mkdir ./icons
wget $ICONURL -O /opt/$APP/icons/$APP