|
@@ -0,0 +1,117 @@
|
|
|
|
|
+#! /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 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 "Must run with root privileges."
|
|
|
|
|
+ echo " "
|
|
|
|
|
+ echo "Usage: $0 [filename]"
|
|
|
|
|
+ echo " "
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+## Take input and verify file and root user##
|
|
|
|
|
+
|
|
|
|
|
+filename=$1
|
|
|
|
|
+
|
|
|
|
|
+if [ "$filename" = "-h" ] || [ "$filename" = "--help" ]; then
|
|
|
|
|
+ helpFunction
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if ! [ -f "$filename" ]; then
|
|
|
|
|
+ echo "$1 not found."
|
|
|
|
|
+ helpFunction
|
|
|
|
|
+ exit 1
|
|
|
|
|
+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
|
|
|
|
|
+
|
|
|
|
|
+echo "$1 file found"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+## Move existing folder to .OLD and delete existing .OLD if needed ##
|
|
|
|
|
+
|
|
|
|
|
+echo "Checking for old installations"
|
|
|
|
|
+
|
|
|
|
|
+if [ -d "/opt/firefox.OLD" ]; then
|
|
|
|
|
+ read -p "firefox.OLD already exists? Should I delete it? ENTER to continue or CTRL+C to abort." input
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+echo "Deleting existing firefox.OLD folder"
|
|
|
|
|
+
|
|
|
|
|
+rm -rf /opt/firefox.OLD
|
|
|
|
|
+
|
|
|
|
|
+echo "Moving Existing firefox to firefox.OLD"
|
|
|
|
|
+
|
|
|
|
|
+mv /opt/firefox /opt/firefox.OLD
|
|
|
|
|
+
|
|
|
|
|
+echo "Making new firefox directory"
|
|
|
|
|
+
|
|
|
|
|
+mkdir /opt/firefox
|
|
|
|
|
+
|
|
|
|
|
+echo "unpacking "$filename" to /opt/firefox"
|
|
|
|
|
+
|
|
|
|
|
+## Check file type and unpack accordingly ##
|
|
|
|
|
+
|
|
|
|
|
+if [[ "$filename" == *.tar.xz ]]; then
|
|
|
|
|
+ echo "Unpacking as tar.xf file"
|
|
|
|
|
+ tar -xvf "$filename" -C "/opt/"
|
|
|
|
|
+elif [[ "$filename" == *.tar.bz2 ]]; then
|
|
|
|
|
+ echo "Unpacking as tar.bz2 file"
|
|
|
|
|
+ tar -xjvf "$filename" -C "/opt/"
|
|
|
|
|
+else
|
|
|
|
|
+ echo "WARNING: Unknown Compression Type. Aborting."
|
|
|
|
|
+ exit 1
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# ensure symlink is set
|
|
|
|
|
+
|
|
|
|
|
+ln -fs /opt/firefox/firefox /usr/local/bin/firefox
|
|
|
|
|
+echo "Symlink /usr/local/bin/firefox set."
|
|
|
|
|
+
|
|
|
|
|
+# ensure /opt permissions are set correctly
|
|
|
|
|
+
|
|
|
|
|
+chown mike:mike /opt/firefox
|
|
|
|
|
+echo "/opt/firefox permissions 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."
|
|
|
|
|
+ exit 1
|
|
|
|
|
+fi
|
|
|
|
|
+
|