#!/bin/sh # AM INSTALL SCRIPT VERSION 3. set -u APP=libreoffice SITE="https://www.libreoffice.org" # CREATE DIRECTORIES AND ADD REMOVER [ -n "$APP" ] && mkdir -p "/opt/$APP/icons" "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > "/opt/$APP/remove" printf '\n%s' "rm -f /usr/local/share/applications/$APP*-AM.desktop" >> "/opt/$APP/remove" chmod a+x "/opt/$APP/remove" _release_still() { lovariant="still" version=$(curl -Ls https://api.github.com/repos/ivan-hc/LibreOffice-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*continuous-still.*$edition.*mage$" | head -1) } _release_fresh() { lovariant="fresh" version=$(curl -Ls https://api.github.com/repos/ivan-hc/LibreOffice-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*continuous-fresh.*$edition.*mage$" | head -1) } # CHOOSE A VERSION read -r -p " Please choose a LibreOffice edition: - STILL is slightly older but tested longer. - FRESH includes all the latest features. - BASIC only supports English (US and GB). - STANDARD includes English (US/GB), Arabic, Chinese (Simplified and Traditional), French, German, Italian, Japanese, Korean, Portuguese (BR/PT), Russian, and Spanish. - FULL includes all supported languages. 1) Still-basic 2) Still-basic with manuals 3) Still-standard 4) Still-standard with manuals 5) Still-full 6) Still-full with manuals 7) Fresh-basic 8) Fresh-basic with manuals 9) Fresh-standard 10) Fresh-standard with manuals 11) Fresh-full 12) Fresh-full with manuals Type a number from the above list and press ENTER: " response case "$response" in 1) edition="basic-x86_64" _release_still 2>/dev/null wget "$version" ;; 2) edition="basic.help-x86_64" _release_still 2>/dev/null wget "$version" ;; 3) edition="standard-x86_64" _release_still 2>/dev/null wget "$version" ;; 4) edition="standard.help-x86_64" _release_still 2>/dev/null wget "$version" ;; 5) edition="full-x86_64" _release_still 2>/dev/null wget "$version" ;; 6) edition="full.help-x86_64" _release_still 2>/dev/null wget "$version" ;; 7) edition="basic-x86_64" _release_fresh 2>/dev/null wget "$version" ;; 8) edition="basic.help-x86_64" _release_fresh 2>/dev/null wget "$version" ;; 9) edition="standard-x86_64" _release_fresh 2>/dev/null wget "$version" ;; 10) edition="standard.help-x86_64" _release_fresh 2>/dev/null wget "$version" ;; 11) edition="full-x86_64" _release_fresh 2>/dev/null wget "$version" ;; 12) edition="full.help-x86_64" _release_fresh 2>/dev/null wget "$version" ;; ''|*) mkdir -p "/opt/$APP/tmp" ;; esac cd .. mv ./tmp/*mage ./"$APP" rm -R -f ./tmp || exit 1 echo "$version" > ./version chmod a+x ./"$APP" || exit 1 # LINK ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM cat >> "/opt/$APP/AM-updater" << 'EOF' #!/bin/sh set -u APP=libreoffice SITE="https://www.libreoffice.org" version0=$(cat "/opt/$APP/version") edition="EDITION" lovariant="LOVARIANT" version=$(curl -Ls https://api.github.com/repos/ivan-hc/LibreOffice-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*continuous-$lovariant.*$edition.*mage$" | head -1) if command -v appimageupdatetool >/dev/null 2>&1; then cd "/opt/$APP" || exit 1 appimageupdatetool -Or ./"$APP" && chmod a+x ./"$APP" && echo "$version" > ./version && exit 0 fi if [ "$version" != "$version0" ]; then mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 notify-send "A new version of $APP is available, please wait" wget "$version" || exit 1 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv --backup=t ./tmp/*mage ./"$APP" chmod a+x ./"$APP" || exit 1 echo "$version" > ./version rm -R -f ./*zs-old ./*.part ./tmp ./*~ notify-send "$APP is updated!" else echo "Update not needed!" fi EOF sed -i "s#EDITION#$edition#g; s#LOVARIANT#$lovariant#g" "/opt/$APP/AM-updater" chmod a+x "/opt/$APP/AM-updater" # ICONS cd "/opt/$APP" || exit 1 ./libreoffice --appimage-extract usr/share/icons/hicolor/scalable/apps/*.svg && mv squashfs-root/usr/share/icons/hicolor/scalable/apps/*.svg ./icons 2>/dev/null RELEASE=$(ls ./icons | head -1 | rev | cut -c 10- | rev) mv ./icons/"$RELEASE"-base* ./icons/"$APP"-base 2>/dev/null mv ./icons/"$RELEASE"-basic* ./icons/"$APP"-basic 2>/dev/null mv ./icons/"$RELEASE"-calc* ./icons/"$APP"-calc 2>/dev/null mv ./icons/"$RELEASE"-chart* ./icons/"$APP"-chart 2>/dev/null mv ./icons/"$RELEASE"-draw* ./icons/"$APP"-draw 2>/dev/null mv ./icons/"$RELEASE"-extension* ./icons/"$APP"-extension 2>/dev/null mv ./icons/"$RELEASE"-impress* ./icons/"$APP"-impress 2>/dev/null mv ./icons/"$RELEASE"-main* ./icons/"$APP"-main 2>/dev/null mv ./icons/"$RELEASE"-math* ./icons/"$APP"-math 2>/dev/null mv ./icons/"$RELEASE"-startcenter* ./icons/"$APP"-startcenter 2>/dev/null mv ./icons/"$RELEASE"-writer* ./icons/"$APP"-writer 2>/dev/null # LAUNCHERS ./libreoffice --appimage-extract opt/libreoffice*/share/xdg LAUNCHERS=$(find squashfs-root -name *.desktop -type f | xargs) for f in $LAUNCHERS ; do launcher=$(echo "$f" | sed 's:.*/::') mv "$f" ./"$APP-${launcher%.desktop}-AM.desktop" done sed -i "s# $(echo $RELEASE | cut -c 12-) # #g; s#Icon=$APP#Icon=/opt/$APP/icons/$APP#g; s#$RELEASE#$APP#g" *.desktop sed -i '/Name=LibreOffice/c\Name=LibreOffice' *startcenter-AM.desktop mv *.desktop /usr/local/share/applications/ rm -R -f ./squashfs-root