#! /bin/bash # - Take new tar file as argument DONE # - Verify argument is valid DONE # - Verify script is running as sudo DONE # - Move existing firefox to firefox.OLD DONE # - create directory for new installation DONE # - unpack tar file to new location DONE # - Optional, verify desktop file extsts helpFunction() { echo " " echo "Provides convenient means to install a new Nextcloud AppImage file." echo "Pass new AppImage file as argument and this script will update the symlinks and verify installation." echo "Must run with root privileges." echo " " echo "Usage: sudo $0 [filename]" echo " " } ## Take input and verify file and root user## filename=$(basename $1) ##Take Basename in case file in cae user is in unusual directory when calling script. projectdir="/home/mike/Software/Nextcloud" imagepath="$projectdir/apps" executablelink="/usr/local/bin" desktoppath="/usr/local/share/applications" assetspath="$projectdir/assets" version="0.2" # Start Script # echo "Nextcloud Client Update Script v$version" # Check Arguments # if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then helpFunction exit 0 fi # Check if user-provided file is valid # if ! [ -f "$1" ]; then echo "$1 not found." helpFunction exit 1 elif ! [ -f "$imagepath/$filename" ]; then echo "Moving $1 to $imagepath/" mv $1 $imagepath/ echo "Done." fi if [ -z "$filename" ] then echo " " echo "No filename given. Aborting." helpFunction exit 1 fi if [ "$USER" != "root" ]; then echo "Must be running as root to install new software. Use sudo or root user" helpFunction exit 1 fi # Argument and file checking complete...# echo "Updating Nextcloud client..." # Ensure AppImage is Executable echo "Setting $filename as executable" sudo chmod +x $imagepath/$filename echo "Done." # Ensure symlink is set echo "Setting symlink /usr/local/bin/nextcloud/" ln -fs $imagepath/$filename $executablelink/nextcloud echo "Done." # Ensure Desktop file is set if ! [ -f "$assetspath/nextcloud.desktop" ]; then echo "WARNING: nextcloud.desktop file not found!" echo "WARNING: Desktop file not set!" exit 1 fi echo "Setting nextcloud.desktop in /usr/local/share/applications and verifying permissions" ln -fs $assetspath/nextcloud.desktop $desktoppath/ chmod +x $assetspath/nextcloud.desktop echo "Done." echo "Update Complete. Done." exit 0