Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # firefox_upgrade - program to upgrade firefox quantum
- error_exit()
- {
- echo "$1" 1>&2
- exit 1
- }
- firefox_path=""
- firefox_file=""
- # parsing path and filename
- if [ $# -ne 1 ]; then
- error_exit "usage: $0 firefox_quantum_path"
- else
- firefox_path="$1"
- firefox_file="${firefox_path##*/}"
- fi
- # checking if input is a valid file
- if [ ! -f "$firefox_path" ]; then
- error_exit "Invalid file! Aborting."
- fi
- # removing previous install, if existent
- firefox_bin="/opt/firefox"
- if [ -e "$firefox_bin" ]; then
- rm -rf $firefox_bin
- else
- echo "$firefox_bin doesn't exist."
- fi
- # removing previous symlink, if existent
- firefox_link="/usr/bin/firefox-quantum"
- if [ -f "$firefox_link" ]; then
- rm $firefox_link
- else
- echo "$firefox_link doesn't exist."
- fi
- # copying the tar to /opt
- rsync -ah --progress $firefox_path /opt/$firefox_file
- # unpacking the tar if successfully changed directory
- if cd /opt; then
- tar -jxvf $firefox_file
- else
- error_exit "Could not change directory! Aborting."
- fi
- # if unpack was successful, set permissions, create symlink, and remove tar
- if [ "$?" = "0" ]; then
- chmod 755 /opt/firefox
- ln -s /opt/firefox/firefox /usr/bin/firefox-quantum
- rm $firefox_file
- else
- error_exit "Could not extract file! Aborting."
- fi
- exit 0
Add Comment
Please, Sign In to add comment