|
|
@@ -0,0 +1,109 @@
|
|
|
+#! /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##
|
|
|
+
|
|
|
+projectdir="/home/mike/Software/KeePassXC"
|
|
|
+imagepath="$projectdir/apps"
|
|
|
+executablelink="/usr/local/bin"
|
|
|
+desktoppath="/usr/local/share/applications"
|
|
|
+assetspath="$projectdir/assets"
|
|
|
+version="0.1"
|
|
|
+
|
|
|
+# Start Script #
|
|
|
+
|
|
|
+echo "KeePassXC Update Script v$version"
|
|
|
+
|
|
|
+
|
|
|
+# Check Arguments #
|
|
|
+
|
|
|
+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
+ helpFunction
|
|
|
+ exit 0
|
|
|
+fi
|
|
|
+
|
|
|
+# Check if user is root #
|
|
|
+if [ "$USER" != "root" ]; then
|
|
|
+ echo "Must be running as root to install new software. Use sudo or root user"
|
|
|
+ helpFunction
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+# Check if user-provided file is valid #
|
|
|
+if [ -z "$1" ]; then
|
|
|
+ echo " "
|
|
|
+ echo "No filename given. Aborting."
|
|
|
+ helpFunction
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+# Check if the string is a valid file #
|
|
|
+if ! [ -f "$1" ]; then
|
|
|
+ echo "$1 not found."
|
|
|
+ helpFunction
|
|
|
+ exit 1
|
|
|
+else
|
|
|
+ # Set filename now that we have a good file #
|
|
|
+ filename=$(basename $1) ##Take Basename in case file in cae user is in unusual directory when calling script.
|
|
|
+fi
|
|
|
+
|
|
|
+# Move file if necessare #
|
|
|
+if ! [ -f "$imagepath/$filename" ]; then
|
|
|
+ echo "Moving $1 to $imagepath/"
|
|
|
+ mv $1 $imagepath/
|
|
|
+ echo "Done."
|
|
|
+fi
|
|
|
+
|
|
|
+# Argument and file checking complete...#
|
|
|
+
|
|
|
+echo "Updating KeePassXC 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/keepass
|
|
|
+echo "Done."
|
|
|
+
|
|
|
+
|
|
|
+# Ensure Desktop file is set
|
|
|
+
|
|
|
+if ! [ -f "$assetspath/keepassxc.desktop" ]; then
|
|
|
+ echo "WARNING: keepassxc.desktop file not found!"
|
|
|
+ echo "WARNING: Desktop file not set!"
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+echo "Setting keepassxc.desktop in /usr/local/share/applications and verifying permissions"
|
|
|
+ln -fs $assetspath/keepassxc.desktop $desktoppath/
|
|
|
+chmod +x $assetspath/keepassxc.desktop
|
|
|
+echo "Done."
|
|
|
+
|
|
|
+echo "Update Complete. Done."
|
|
|
+exit 0
|