| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #! /bin/sh
- # - 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"
- tar -xjvf "$filename" -C "/opt/"
- # ensure symlink is set
- ln -fs /opt/firefox/firefox /usr/local/bin/firefox
|