filezilla
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=filezilla 6 SITE="https://filezilla-project.org" 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=$(wget -q https://filezilla-project.org/download.php?platform=linux32 -O - | tr '">< ' '\n' | grep -i "^http.*filezilla.*linux.*tar" | head -1) 16 wget "$version" || exit 1 17 [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z 18 [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.* 19 [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip 20 cd .. 21 if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi 22 rm -R -f ./tmp || exit 1 23 echo "$version" > ./version 24 chmod a+x ./bin/$APP || exit 1 25 26 # LINK TO PATH 27 echo '#!/bin/sh 28 HERE="$(dirname "$(readlink -f "${0}")")" 29 export PATH="${HERE}"/bin/:"${PATH}" 30 export LD_LIBRARY_PATH="${HERE}"/lib/:"${LD_LIBRARY_PATH}" 31 export XDG_DATA_DIRS="${HERE}"/usr/share/:"${HERE}"/usr/share/filezilla/:"${XDG_DATA_DIRS}" 32 exec "${HERE}"/bin/filezilla' > ./"$APP" 33 chmod a+x ./"$APP" 34 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 35 36 # SCRIPT TO UPDATE THE PROGRAM 37 cat >> ./AM-updater << 'EOF' 38 #!/bin/sh 39 set -u 40 APP=filezilla 41 SITE="https://filezilla-project.org" 42 version0=$(cat "/opt/$APP/version") 43 version=$(wget -q https://filezilla-project.org/download.php?platform=linux32 -O - | tr '">< ' '\n' | grep -i "^http.*filezilla.*linux.*tar" | head -1) 44 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 45 if [ "$version" != "$version0" ]; then 46 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 47 notify-send "A new version of $APP is available, please wait" 48 wget "$version" || exit 1 49 [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z 50 [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.* 51 [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip 52 cd .. 53 if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi 54 chmod a+x ./bin/"$APP" || exit 1 55 echo "$version" > ./version 56 rm -R -f ./tmp ./*~ 57 notify-send "$APP is updated!" 58 else 59 echo "Update not needed!" 60 fi 61 EOF 62 chmod a+x ./AM-updater || exit 1 63 64 # ICON 65 mkdir -p icons 66 wget https://portable-linux-apps.github.io/icons/filezilla.png -O ./icons/"$APP" 2> /dev/null 67 68 # LAUNCHER 69 echo "[Desktop Entry] 70 Name=FileZilla 71 GenericName=FTP client 72 GenericName[da]=FTP-klient 73 GenericName[de]=FTP-Client 74 GenericName[fr]=Client FTP 75 Comment=Download and upload files via FTP, FTPS and SFTP 76 Comment[da]=Download og upload filer via FTP, FTPS og SFTP 77 Comment[de]=Dateien über FTP, FTPS und SFTP übertragen 78 Comment[fr]=Transférer des fichiers via FTP, FTPS et SFTP 79 Exec=filezilla 80 Terminal=false 81 Icon=/opt/$APP/icons/$APP 82 Type=Application 83 Categories=Network;FileTransfer; 84 Version=1.0" > /usr/local/share/applications/"$APP"-AM.desktop