#!/bin/sh APP=wps-office REPO="ivan-hc/WPS-Office-appimage" # 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* /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove chmod a+x /opt/$APP/remove # DOWNLOAD THE ARCHIVE mkdir tmp cd ./tmp version=$(curl -Ls https://api.github.com/repos/$REPO/releases | jq '.' | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) wget $version echo "$version" >> /opt/$APP/version cd .. mv ./tmp/*mage ./$APP chmod a+x /opt/$APP/$APP rmdir ./tmp # LINK ln -s /opt/$APP/$APP /usr/local/bin/$APP # SCRIPT TO UPDATE THE PROGRAM cat >> /opt/$APP/AM-updater << 'EOF' #!/usr/bin/env bash APP=wps-office REPO="ivan-hc/WPS-Office-appimage" version0=$(cat /opt/$APP/version) version=$(curl -Ls https://api.github.com/repos/$REPO/releases | jq '.' | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) if [ $version = $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 wget $version if ls . | grep mage; then cd .. if test -f ./tmp/*mage; then rm ./version fi echo $version >> ./version mv --backup=t ./tmp/*mage ./$APP chmod a+x /opt/$APP/$APP rm -R -f ./tmp ./*~ fi notify-send "$APP is updated!" fi EOF chmod a+x /opt/$APP/AM-updater # ICONS cd /opt/$APP mkdir icons mv $(./$APP --appimage-extract usr/share/icons/hicolor/128x128/apps/*.png) ./icons/ 2> /dev/null for file in ./icons/*.png; do mv -- "$file" "${file%%.png}" done # LAUNCHERS mv $(./$APP --appimage-extract opt/kingsoft/wps-office/desktops) . 2> /dev/null cd desktops for f in * ; do mv $f AM-$APP-$f; done sed -i "s#Icon=#Icon=/opt/$APP/icons/#g" * sed -i "s#/usr/bin/##g" ./* sed -i "s#Exec=#Exec=$APP #g" ./* sed -i 's/wps-office wps %F/wps-office %F/g' ./*prometheus.desktop sed -i "s/WPS [0-9]*/WPS OFFICE/g" ./*prometheus.desktop cd .. mv ./desktops/* /usr/share/applications/ 2> /dev/null rm -R -f /opt/$APP/squashfs-root rm -R -f /opt/$APP/desktops