|
@@ -12,12 +12,11 @@
|
|
|
helpFunction()
|
|
helpFunction()
|
|
|
{
|
|
{
|
|
|
echo " "
|
|
echo " "
|
|
|
- echo "Provides convenient means to install a new Firefox tar file."
|
|
|
|
|
- echo "Pass new tar file as argument and this script will handle backing up the current installation and unpacking the new installation."
|
|
|
|
|
- echo "This script will prompt before deleting a previous archive."
|
|
|
|
|
|
|
+ echo "Provides convenient means to install a new firefox file."
|
|
|
|
|
+ echo "Pass new TAR or TAR.BZ file as argument and this script will unpack and update the symlinks and verify installation."
|
|
|
echo "Must run with root privileges."
|
|
echo "Must run with root privileges."
|
|
|
echo " "
|
|
echo " "
|
|
|
- echo "Usage: $0 [filename]"
|
|
|
|
|
|
|
+ echo "Usage: sudo $0 [filename]"
|
|
|
echo " "
|
|
echo " "
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -26,37 +25,63 @@ helpFunction()
|
|
|
|
|
|
|
|
## Take input and verify file and root user##
|
|
## Take input and verify file and root user##
|
|
|
|
|
|
|
|
-filename=$1
|
|
|
|
|
|
|
|
|
|
-if [ "$filename" = "-h" ] || [ "$filename" = "--help" ]; then
|
|
|
|
|
|
|
+projectname="Firefox Browser Update Script"
|
|
|
|
|
+projectdir="/home/mike/Software/firefox"
|
|
|
|
|
+imagepath="$projectdir/apps"
|
|
|
|
|
+executablelink="/usr/local/bin"
|
|
|
|
|
+desktoppath="/usr/local/share/applications"
|
|
|
|
|
+assetspath="$projectdir/assets"
|
|
|
|
|
+version="0.1"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+echo "$projectname v$version"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# Check Arguments #
|
|
|
|
|
+
|
|
|
|
|
+if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
helpFunction
|
|
helpFunction
|
|
|
exit 0
|
|
exit 0
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-if ! [ -f "$filename" ]; then
|
|
|
|
|
- echo "$1 not found."
|
|
|
|
|
|
|
+# 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
|
|
helpFunction
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-if [ -z "$filename" ]
|
|
|
|
|
-then
|
|
|
|
|
- echo " "
|
|
|
|
|
- echo "No filename given. Aborting."
|
|
|
|
|
- helpFunction
|
|
|
|
|
- exit 1
|
|
|
|
|
|
|
+# Check if any string was provided as in input #
|
|
|
|
|
+if [ -z "$1" ]; then
|
|
|
|
|
+ echo " "
|
|
|
|
|
+ echo "No filename given. Aborting."
|
|
|
|
|
+ helpFunction
|
|
|
|
|
+ exit 1
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-if [ "$USER" != "root" ]; then
|
|
|
|
|
- echo "Must be running as root to install new software. Use sudo or root user"
|
|
|
|
|
|
|
+# Check if the string is a valid file #
|
|
|
|
|
+if ! [ -f "$1" ]; then
|
|
|
|
|
+ echo "$1 not found."
|
|
|
helpFunction
|
|
helpFunction
|
|
|
exit 1
|
|
exit 1
|
|
|
|
|
+else
|
|
|
|
|
+ # Set filename now that we have a good file #
|
|
|
|
|
+ filename=$(basename $1) ##Take Basename in case file in case user is in unusual directory when calling script.
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Move file if necessary #
|
|
|
|
|
+if ! [ -f "$imagepath/$filename" ]; then
|
|
|
|
|
+ echo "Moving $1 to $imagepath/"
|
|
|
|
|
+ mv $1 $imagepath/
|
|
|
|
|
+ echo "Done."
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-echo "$1 file found"
|
|
|
|
|
|
|
+# Argument and file checking complete...#
|
|
|
|
|
|
|
|
|
|
+# Start Script #
|
|
|
|
|
|
|
|
-## Move existing folder to .OLD and delete existing .OLD if needed ##
|
|
|
|
|
|
|
+echo "Updating $projectname ..."
|
|
|
|
|
|
|
|
echo "Checking for old installations"
|
|
echo "Checking for old installations"
|
|
|
|
|
|
|
@@ -81,37 +106,48 @@ echo "unpacking "$filename" to /opt/firefox"
|
|
|
## Check file type and unpack accordingly ##
|
|
## Check file type and unpack accordingly ##
|
|
|
|
|
|
|
|
if [[ "$filename" == *.tar.xz ]]; then
|
|
if [[ "$filename" == *.tar.xz ]]; then
|
|
|
- echo "Unpacking as tar.xf file"
|
|
|
|
|
- tar -xvf "$filename" -C "/opt/"
|
|
|
|
|
|
|
+ echo "Unpacking as tar.xz file"
|
|
|
|
|
+ tar -xvf "$imagepath/$filename" -C "/opt/"
|
|
|
elif [[ "$filename" == *.tar.bz2 ]]; then
|
|
elif [[ "$filename" == *.tar.bz2 ]]; then
|
|
|
echo "Unpacking as tar.bz2 file"
|
|
echo "Unpacking as tar.bz2 file"
|
|
|
- tar -xjvf "$filename" -C "/opt/"
|
|
|
|
|
|
|
+ tar -xjvf "$imagepath/$filename" -C "/opt/"
|
|
|
else
|
|
else
|
|
|
echo "WARNING: Unknown Compression Type. Aborting."
|
|
echo "WARNING: Unknown Compression Type. Aborting."
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+#
|
|
|
|
|
|
|
|
-# ensure symlink is set
|
|
|
|
|
|
|
+#
|
|
|
|
|
+#
|
|
|
|
|
+## Ensure AppImage is Executable
|
|
|
|
|
+#
|
|
|
|
|
+#echo "Setting $filename as executable"
|
|
|
|
|
+#sudo chmod +x $imagepath/$filename
|
|
|
|
|
+#echo "Done."
|
|
|
|
|
+#
|
|
|
|
|
+#
|
|
|
|
|
|
|
|
-ln -fs /opt/firefox/firefox /usr/local/bin/firefox
|
|
|
|
|
-echo "Symlink /usr/local/bin/firefox set."
|
|
|
|
|
|
|
+# Ensure symlink is set
|
|
|
|
|
|
|
|
-# ensure /opt permissions are set correctly
|
|
|
|
|
|
|
+echo "Setting symlink /usr/local/bin/firefox"
|
|
|
|
|
+ln -fs /opt/firefox/firefox $executablelink/firefox
|
|
|
|
|
+chowm mike:mike /opt/firefox # Write permissions needed for firefox to check for updates
|
|
|
|
|
+echo "Done."
|
|
|
|
|
|
|
|
-chown mike:mike /opt/firefox
|
|
|
|
|
-echo "/opt/firefox permissions set"
|
|
|
|
|
|
|
|
|
|
-# ensure .desktop file is set
|
|
|
|
|
|
|
+# Ensure Desktop file is set
|
|
|
|
|
|
|
|
-if [ -f "firefox.desktop" ]; then
|
|
|
|
|
- echo "Setting .desktop file."
|
|
|
|
|
- ln -fs /home/mike/Software/firefox/firefox.desktop /usr/local/share/applications
|
|
|
|
|
- echo "Done."
|
|
|
|
|
-else
|
|
|
|
|
- echo ""
|
|
|
|
|
- echo "WARNING: firefox.desktop not found. Could not install desktop file."
|
|
|
|
|
- echo "Check for existence of firefox.desktop file in this folder."
|
|
|
|
|
|
|
+if ! [ -f "$assetspath/firefox.desktop" ]; then
|
|
|
|
|
+ echo "WARNING: firefox.desktop file not found!"
|
|
|
|
|
+ echo "WARNING: Desktop file not set!"
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+echo "Setting firefox.desktop in /usr/local/share/applications and verifying permissions"
|
|
|
|
|
+ln -fs $assetspath/firefox.desktop $desktoppath/
|
|
|
|
|
+chmod +x $assetspath/firefox.desktop
|
|
|
|
|
+echo "Done."
|
|
|
|
|
+
|
|
|
|
|
+echo "Update Complete. Done."
|
|
|
|
|
+exit 0
|