i3
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=i3 6 SITE="Samueru-sama/i3-AppImage" 7 8 # CREATE DIRECTORIES AND ADD REMOVER 9 [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" && 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 version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{} ]/\n/g' | grep -oi 'https.*continuous.*i3.*86_64.*mage$' | head -1) 15 wget "$version" || exit 1 16 #wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync 17 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 18 cd .. 19 mv ./tmp/*mage ./"$APP" 20 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null 21 rm -R -f ./tmp || exit 1 22 echo "$version" > ./version 23 chmod a+x ./"$APP" || exit 1 24 25 # LINK TO PATH 26 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 27 28 # SCRIPT TO UPDATE THE PROGRAM 29 cat >> ./AM-updater << 'EOF' 30 #!/bin/sh 31 APP=i3 32 SITE="Samueru-sama/i3-AppImage" 33 if [ -z "$APP" ]; then exit 1; fi 34 version0=$(cat "/opt/$APP/version") 35 version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{} ]/\n/g' | grep -oi 'https.*continuous.*i3.*86_64.*mage$' | head -1) 36 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 37 if [ "$version" != "$version0" ]; then 38 notify-send "A new version of $APP is available, please wait" 39 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 40 wget "$version" || exit 1 41 cd .. 42 mv --backup=t ./tmp/*"$APP"* ./"$APP" || exit 1 43 echo "$version" > ./version 44 rm -R -f ./tmp ./*~ 45 chmod a+x ./"$APP" || exit 1 46 notify-send "$APP is updated!" 47 else 48 echo "Update not needed!" 49 fi 50 EOF 51 chmod a+x ./AM-updater || exit 1