#!/bin/bash ACTION="$1" DEST_DOWNLOAD=$HOME"/Applications/" DEST_FILE="freecad-appimage" APPIMAGE="Freecad.AppImage" URL="http://lliurex.net/recursos/" DESKTOP_ORIG="/usr/share/zero-lliurex-freecad/freecad-appimage.desktop" DESKTOP_DEST=$HOME"/.local/share/applications/" MIME_DEST=$HOME"/.local/share/mime/" LINK_PATH=$HOME"/.local/bin/" case $ACTION in getStatus) if [ -s ${DEST_DOWNLOAD}"/"${DEST_FILE} ] then echo 0 else echo 1 fi ;; download) if ! [ -d ${DEST_DOWNLOAD} ] then mkdir ${DEST_DOWNLOAD} fi cd ${DEST_DOWNLOAD} if [ -s ${DEST_DOWNLOAD}"/"${APPIMAGE} ] then rm -f ${DEST_DOWNLOAD}"/"${APPIMAGE} fi wget ${URL}${APPIMAGE} -O ${DEST_DOWNLOAD}${DEST_FILE} if ! [ -s ${DEST_DOWNLOAD}${DEST_FILE} ] then exit 1 fi ;; installPackage) echo "Preparing FreeCAD Appimage..." chmod +x ${DEST_DOWNLOAD}${DEST_FILE} if ! [ -d ${LINK_PATH} ] then mkdir ${LINK_PATH} fi if ! [ -e ${LINK_PATH}${DEST_FILE} ] then ln -s ${DEST_DOWNLOAD}${DEST_FILE} ${LINK_PATH}${DEST_FILE} fi if ! [ -d ${DESKTOP_DEST} ] then mkdir ${DESKTOP_DEST} fi if ! [ -d ${DESKTOP_DEST}"packages" ] then mkdir ${DESKTOP_DEST}"packages" fi if ! [ -d ${MIME_DEST} ] then mkdir ${MIME_DEST} fi if ! [ -d ${MIME_DEST}"packages" ] then mkdir ${MIME_DEST}"packages" fi cp $DESKTOP_ORIG $DESKTOP_DEST sleep 15 update-mime-database $MIME_DEST >/dev/null 2>/dev/null || true update-desktop-database $DESKTOP_DEST >/dev/null 2>/dev/null || true sed -i "s#%%HOME%%#$HOME#" ${DESKTOP_DEST}"/freecad-appimage.desktop" chmod +x ${DESKTOP_DEST}"/freecad-appimage.desktop" echo ${DEST_FILE}" is now available at appimage-manager" ;; remove) echo "Removing files..." if [ -s ${DEST_DOWNLOAD}${DEST_FILE} ] then rm -f ${DEST_DOWNLOAD}${DEST_FILE} fi if [ -s ${DEST_DOWNLOAD}${DEST_FILE} ] then exit 1 fi ;; esac exit 0