appimagehelper
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=appimagehelper 6 SITE="https://gitlab.com/posktomten/appimagehelper" 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="https://bin.ceicer.com/appimagehelper/bin/appimagehelper-x86_64.AppImage" 16 wget "$version" || exit 1 17 wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync 18 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 19 cd .. 20 mv ./tmp/*mage ./"$APP" 21 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null 22 rm -R -f ./tmp || exit 1 23 echo "$version" > ./version 24 chmod a+x ./"$APP" || exit 1 25 26 # LINK TO PATH 27 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 28 29 # LAUNCHER & ICON 30 ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop 31 ./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon 32 COUNT=0 33 while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink 34 if [ -L ./"$APP".desktop ]; then 35 LINKPATH="$(readlink ./"$APP".desktop | sed 's|^\./||' 2>/dev/null)" 36 ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop 37 fi 38 if [ -L ./DirIcon ]; then 39 LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" 40 ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon 41 fi 42 [ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break 43 COUNT=$((COUNT + 1)) 44 done 45 sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop 46 mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null 47 rm -R -f ./squashfs-root