openarena
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=openarena 6 SITE="http://openarena.ws" 7 8 # CREATE DIRECTORIES AND ADD REMOVER 9 [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1 10 printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove 11 printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove 12 chmod a+x ../remove || exit 1 13 14 # DOWNLOAD AND PREPARE THE APP, $version is also used for updates 15 version=$(curl -Ls https://aur.archlinux.org/packages/openarena | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep .zip | head -1) 16 wget "$version" || exit 1 17 [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z 18 [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.* 19 [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip 20 cd .. 21 if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi 22 rm -R -f ./tmp || exit 1 23 echo "$version" > ./version 24 chmod a+x ./"$APP".x86_64 || exit 1 25 26 # LINK TO PATH 27 cat >> /usr/local/bin/"$APP" << 'EOF' 28 #!/bin/sh 29 APP=openarena 30 exec /opt/$APP/$APP.x86_64 31 EOF 32 chmod a+x /usr/local/bin/"$APP" 33 34 # SCRIPT TO UPDATE THE PROGRAM 35 cat >> ./AM-updater << 'EOF' 36 #!/bin/sh 37 set -u 38 APP=openarena 39 SITE="http://openarena.ws" 40 version0=$(cat "/opt/$APP/version") 41 version=$(curl -Ls https://aur.archlinux.org/packages/openarena | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep .zip | head -1) 42 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 43 if [ "$version" != "$version0" ]; then 44 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 45 notify-send "A new version of $APP is available, please wait" 46 wget "$version" || exit 1 47 [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z 48 [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.* 49 [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip 50 cd .. 51 if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi 52 chmod a+x ./"$APP".x86_64 || exit 1 53 echo "$version" > ./version 54 rm -R -f ./tmp ./*~ 55 notify-send "$APP is updated!" 56 else 57 echo "Update not needed!" 58 fi 59 EOF 60 chmod a+x ./AM-updater || exit 1 61 62 # ICON 63 mkdir -p icons 64 wget https://portable-linux-apps.github.io/icons/openarena.png -O ./icons/"$APP" 2> /dev/null 65 66 # LAUNCHER 67 echo "[Desktop Entry] 68 Name=OpenArena 69 Exec=$APP 70 Comment=A violent, sexy, multiplayer first person shooter based on the ioquake3 engine 71 Icon=/opt/$APP/icons/$APP 72 Type=Application 73 Terminal=false 74 Categories=Game;" > /usr/local/share/applications/"$APP"-AM.desktop