updater.sh v2.0 (#543)
* lots of new arguments `usage: ./updater.sh [-h] [-p PROFILE] [-u] [-d] [-s] [-n] [-b] [-c] [-v] [-r] [-o OVERRIDE]` Args can be written separately or together. Examples: ```txt ./updater.sh -sdc ./updater.sh -sd -o relaxed.js ./updater.sh -s -d ``` Deprecated arguments still work (for now!)
This commit is contained in:
parent
b182946ae4
commit
62351bfbf5
393
updater.sh
393
updater.sh
@ -2,16 +2,24 @@
|
|||||||
|
|
||||||
## ghacks-user.js updater for macOS and Linux
|
## ghacks-user.js updater for macOS and Linux
|
||||||
|
|
||||||
## version: 1.5
|
## version: 2.0
|
||||||
## Author: Pat Johnson (@overdodactyl)
|
## Author: Pat Johnson (@overdodactyl)
|
||||||
## Additional contributors: @earthlng, @ema-pe
|
## Additional contributors: @earthlng, @ema-pe
|
||||||
|
|
||||||
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in check_for_update() )
|
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in update_updater() )
|
||||||
|
|
||||||
|
readonly currdir=$(pwd)
|
||||||
|
|
||||||
|
sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
|
||||||
|
if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
||||||
|
readonly SCRIPT_DIR=$(dirname "${sfp}")
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Base variables #
|
# Base variables #
|
||||||
#########################
|
#########################
|
||||||
update_pref=${1:--ask}
|
|
||||||
|
# Colors used for printing
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
BBLUE='\033[1;34m'
|
BBLUE='\033[1;34m'
|
||||||
@ -20,86 +28,143 @@ ORANGE='\033[0;33m'
|
|||||||
CYAN='\033[0;36m'
|
CYAN='\033[0;36m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Argument defaults
|
||||||
|
UPDATE="check"
|
||||||
|
CONFIRM="yes"
|
||||||
|
OVERRIDE="user-overrides.js"
|
||||||
|
BACKUP="multiple"
|
||||||
|
COMPARE=false
|
||||||
|
SKIPOVERRIDE=false
|
||||||
|
VIEW=false
|
||||||
|
PROFILE_PATH=false
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Working directory #
|
# Working directory #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
# get current directory
|
set_wd () {
|
||||||
currdir=$(pwd)
|
declare -r macdir=~/Library/Application\ Support/Firefox/Profiles/
|
||||||
## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
|
declare -r nixdir=~/.mozilla/firefox/
|
||||||
sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
|
local ff_profile
|
||||||
## fallback for Macs without coreutils
|
if [ "$PROFILE_PATH" = false ]; then
|
||||||
if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
ff_profile="$SCRIPT_DIR"
|
||||||
## store the Firefox profile directory
|
elif [ "$PROFILE_PATH" = "list" ]; then
|
||||||
ff_profile="$(dirname "${sfp}")"
|
local firefox_dir=""
|
||||||
|
if [ -d "$macdir" ]; then
|
||||||
|
firefox_dir=$macdir
|
||||||
|
elif [ -d $nixdir ]; then
|
||||||
|
firefox_dir=$nixdir
|
||||||
|
else
|
||||||
|
echo -e ${RED}"Error: Sorry, -l is not supported for your OS"${NC}
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $(find "$firefox_dir" -maxdepth 1 -type d | wc -l) == "2" ]; then
|
||||||
|
ff_profile=$(ls -d "$firefox_dir"*)
|
||||||
|
else
|
||||||
|
echo -e ${GREEN}"The following profiles were found:\n"${ORANGE}
|
||||||
|
ls -d "$firefox_dir"*
|
||||||
|
echo -e ${RED}"\nWhich profile would you like to update?"${NC}
|
||||||
|
read -p ""
|
||||||
|
echo -e ""
|
||||||
|
ff_profile=$REPLY
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ff_profile="$PROFILE_PATH"
|
||||||
|
fi
|
||||||
|
cd "$ff_profile"
|
||||||
|
}
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# File Handeling #
|
# Arguments #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
# Download method priority: curl -> wget -> pearl
|
usage() {
|
||||||
DOWNLOAD_METHOD="not_pearl"
|
echo -e ${BLUE}"\nUsage: $0 [-h] [-p PROFILE] [-u] [-d] [-s] [-n] [-b] [-c] [-v] [-r] [-o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
|
||||||
if [[ $(command -v "curl") ]] > /dev/null 2>&1; then
|
echo -e "Optional Arguments:"
|
||||||
DOWNLOAD_TO_FILE="curl -O"
|
echo -e "\t-h,\t\t Show this help message and exit."
|
||||||
elif [[ $(command -v "wget") ]] > /dev/null 2>&1; then
|
echo -e "\t-p PROFILE,\t Path to your Firefox profile (if different than the dir of this script)"
|
||||||
DOWNLOAD_TO_FILE="wget"
|
echo -e "\t\t\t IMPORTANT: if the path include spaces, wrap the entire argument in quotes."
|
||||||
elif [[ $(command -v "perl") ]]; then
|
echo -e "\t-l, \t\t Choose your Firefox profile from a list"
|
||||||
DOWNLOAD_METHOD="perl"
|
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
||||||
|
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
||||||
|
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
||||||
|
echo -e "\t-b,\t\t Only keep one backup of each file."
|
||||||
|
echo -e "\t-c,\t\t Create a diff file comparing old and new user.js within userjs_diffs. "
|
||||||
|
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
||||||
|
echo -e "\t\t\t If used with -p, paths should be relative to PROFILE or absolute paths"
|
||||||
|
echo -e "\t\t\t If given a directory, all files inside will be appended recursively."
|
||||||
|
echo -e "\t\t\t You can pass multiple files or directories by passing a comma separated list."
|
||||||
|
echo -e "\t\t\t\t Note: If a directory is given, only files inside ending in the extension .js are appended"
|
||||||
|
echo -e "\t\t\t\t IMPORTANT: do not add spaces between files/paths. Ex: -o file1.js,file2.js,dir1"
|
||||||
|
echo -e "\t\t\t\t IMPORTANT: if any files/paths include spaces, wrap the entire argument in quotes."
|
||||||
|
echo -e "\t\t\t\t\t Ex: -o \"override folder\" "
|
||||||
|
echo -e "\t-n,\t\t Do not append any overrides, even if user-overrides.js exists."
|
||||||
|
echo -e "\t-v,\t\t Open the resulting user.js file."
|
||||||
|
echo -e "\t-r,\t\t Only download user.js to a temporary file and open it."
|
||||||
|
echo -e
|
||||||
|
echo -e "Deprecated Arguments (they still work for now):"
|
||||||
|
echo -e "\t-donotupdate,\t Use instead -d"
|
||||||
|
echo -e "\t-update,\t Use instead -u"
|
||||||
|
echo -e
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
legacy_argument () {
|
||||||
|
echo -e ${ORANGE}"\nWarning: command line arguments have changed."
|
||||||
|
echo -e "$1 has been deprecated and may not work in the future.\n"
|
||||||
|
echo -e "Please view the new options using the -h argument."${NC}
|
||||||
|
}
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# File Handling #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# Download method priority: curl -> wget
|
||||||
|
DOWNLOAD_METHOD=""
|
||||||
|
if [[ $(command -v "curl") ]]; then
|
||||||
|
DOWNLOAD_METHOD="curl"
|
||||||
|
elif [[ $(command -v "wget") ]]; then
|
||||||
|
DOWNLOAD_METHOD="wget"
|
||||||
else
|
else
|
||||||
echo -e ${RED}"This script requires curl, wget or perl to be installed.\nProcess aborted"${NC}
|
echo -e ${RED}"This script requires curl or wget.\nProcess aborted"${NC}
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download files
|
# Download files
|
||||||
download_file () {
|
download_file () {
|
||||||
mkdir -p userjs_temps
|
declare -r url=$1
|
||||||
cd userjs_temps
|
declare -r tf=$(mktemp)
|
||||||
url=$1
|
local dlcmd=""
|
||||||
|
|
||||||
if [ $DOWNLOAD_METHOD = "not_pearl" ]; then
|
if [ $DOWNLOAD_METHOD = "curl" ]; then
|
||||||
$DOWNLOAD_TO_FILE ${url}
|
dlcmd="curl -o $tf"
|
||||||
else
|
else
|
||||||
http_url=${url/https/http}
|
dlcmd="wget -O $tf"
|
||||||
# Variables from the shell are available in Perl's %ENV hash
|
|
||||||
# Need to export shell variable so it is visible to subprocesses
|
|
||||||
export http_url
|
|
||||||
|
|
||||||
perl -e '
|
|
||||||
use File::Fetch;
|
|
||||||
my $ff = File::Fetch->new(uri => $ENV{http_url});
|
|
||||||
my $where = $ff->fetch() or die $ff->error;
|
|
||||||
my $where = $ff->fetch( to => "." );
|
|
||||||
'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ..
|
$dlcmd "${url}" &>/dev/null && echo "$tf" || echo "" # return the temp-filename (or empty string on error)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Backup a file into userjs_backups
|
open_file () { #expects one argument: file_path
|
||||||
# Replace current version of a file with new one in userjs_temps
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
backup_file () {
|
open "$1"
|
||||||
filename=$1
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||||
mkdir -p userjs_backups
|
xdg-open "$1"
|
||||||
mv $filename "userjs_backups/${filename}.backup.$(date +"%Y-%m-%d_%H%M")"
|
else
|
||||||
mv "userjs_temps/${filename}" $filename
|
echo -e ${RED}"Error: Sorry, opening files is not supported for your OS."${NC}
|
||||||
echo -e "Status: ${GREEN}${filename} has been backed up and replaced with the latest version!${NC}"
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#########################
|
|
||||||
# Initiation #
|
|
||||||
#########################
|
|
||||||
|
|
||||||
initiate () {
|
show_banner () {
|
||||||
echo -e
|
echo -e
|
||||||
echo -e
|
echo -e
|
||||||
echo -e ${BBLUE}" ############################################################################"
|
echo -e ${BBLUE}" ############################################################################"
|
||||||
echo -e " #### ####"
|
echo -e " #### ####"
|
||||||
echo -e " #### ghacks user.js ####"
|
echo -e " #### ghacks user.js ####"
|
||||||
echo -e " #### Hardening the Privacy and Security Settings of Firefox ####"
|
echo -e " #### Hardening the Privacy and Security Settings of Firefox ####"
|
||||||
echo -e " #### Maintained by @Thorin-Oakenpants and @earthlng ####" ####"
|
echo -e " #### Maintained by @Thorin-Oakenpants and @earthlng ####"
|
||||||
echo -e " #### Updater for macOS and Linux by @overdodactyl ####" ####"
|
echo -e " #### Updater for macOS and Linux by @overdodactyl ####"
|
||||||
echo -e " #### ####"
|
echo -e " #### ####"
|
||||||
echo -e " ############################################################################"${NC}
|
echo -e " ############################################################################"${NC}
|
||||||
echo -e
|
echo -e
|
||||||
@ -107,23 +172,6 @@ initiate () {
|
|||||||
echo -e "Documentation for this script is available here: ${CYAN}https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts${NC}\n"
|
echo -e "Documentation for this script is available here: ${CYAN}https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts${NC}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmation () {
|
|
||||||
download_file "https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js" &>/dev/null
|
|
||||||
echo -e "Please observe the following information:"
|
|
||||||
echo -e "\tFirefox profile: ${ORANGE}$(pwd)${NC}"
|
|
||||||
echo -e "\tAvailable online: ${ORANGE}$(get_userjs_version userjs_temps/user.js)${NC}"
|
|
||||||
echo -e "\tCurrently using: ${ORANGE}$(get_userjs_version user.js)\n${NC}\n"
|
|
||||||
|
|
||||||
echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}"
|
|
||||||
read -p "" -n 1 -r
|
|
||||||
echo -e "\n"
|
|
||||||
|
|
||||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
|
||||||
echo -e ${RED}"Process aborted"${NC}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Update updater.sh #
|
# Update updater.sh #
|
||||||
@ -131,9 +179,7 @@ confirmation () {
|
|||||||
|
|
||||||
# Returns the version number of a updater.sh file
|
# Returns the version number of a updater.sh file
|
||||||
get_updater_version () {
|
get_updater_version () {
|
||||||
filename=$1
|
echo $(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$1")
|
||||||
version_regex='5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p'
|
|
||||||
echo "$(sed -n "$version_regex" "${ff_profile}/${filename}")"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update updater.sh
|
# Update updater.sh
|
||||||
@ -142,32 +188,27 @@ get_updater_version () {
|
|||||||
# -donotupdate: New version will not be looked for and update will not occur
|
# -donotupdate: New version will not be looked for and update will not occur
|
||||||
# -update: Check for update, if available, execute without asking
|
# -update: Check for update, if available, execute without asking
|
||||||
update_updater () {
|
update_updater () {
|
||||||
update_pref="$(echo $update_pref | tr '[A-Z]' '[a-z]')"
|
if [ $UPDATE = "no" ]; then
|
||||||
if [ $update_pref = "-donotupdate" ]; then
|
return 0 # User signified not to check for updates
|
||||||
# User signified not to check for updates
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_file "https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh" &>/dev/null
|
declare -r tmpfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')
|
||||||
|
|
||||||
if [[ $(get_updater_version updater.sh) < $(get_updater_version userjs_temps/updater.sh) ]]; then
|
if [[ $(get_updater_version "${SCRIPT_DIR}/updater.sh") < $(get_updater_version "${tmpfile}") ]]; then
|
||||||
if [ $update_pref != "-update" ]; then
|
if [ $UPDATE = "check" ]; then
|
||||||
echo -e "There is a newer version of updater.sh available. ${RED}Download and execute Y/N?${NC}"
|
echo -e "There is a newer version of updater.sh available. ${RED}Update and execute Y/N?${NC}"
|
||||||
read -p "" -n 1 -r
|
read -p "" -n 1 -r
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
# Update available, but user chooses not to update
|
return 0 # Update available, but user chooses not to update
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# No update available
|
return 0 # No update available
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
# Backup current updater, execute latest version
|
mv "${tmpfile}" "${SCRIPT_DIR}/updater.sh"
|
||||||
backup_file updater.sh
|
chmod u+x "${SCRIPT_DIR}/updater.sh"
|
||||||
chmod +x updater.sh
|
"${SCRIPT_DIR}/updater.sh" "$@ -d"
|
||||||
./updater.sh -donotupdate
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,28 +219,178 @@ update_updater () {
|
|||||||
|
|
||||||
# Returns version number of a user.js file
|
# Returns version number of a user.js file
|
||||||
get_userjs_version () {
|
get_userjs_version () {
|
||||||
filename=$1
|
echo "$(sed -n '4p' "$1")"
|
||||||
echo "$(sed -n "4p" "${ff_profile}/${filename}")"
|
}
|
||||||
|
|
||||||
|
add_override () {
|
||||||
|
input=$1
|
||||||
|
if [ -f "$input" ]; then
|
||||||
|
echo "" >> user.js
|
||||||
|
cat "$input" >> user.js
|
||||||
|
echo -e "Status: ${GREEN}Override file appended:${NC} ${input}"
|
||||||
|
elif [ -d "$input" ]; then
|
||||||
|
FSAVEIFS=$IFS
|
||||||
|
IFS=$'\n\b' # Set IFS
|
||||||
|
FILES="${input}"/*.js
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
add_override "$f"
|
||||||
|
done
|
||||||
|
IFS=$SAVEIFS # restore $IFS
|
||||||
|
else
|
||||||
|
echo -e "${ORANGE}Warning: Could not find override file:${NC} ${input}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_comments () { # expects 2 arguments: from-file and to-file
|
||||||
|
sed -e 's/^[[:space:]]*\/\/.*$//' -e '/^\/\*/,/\*\//d' -e '/^[[:space:]]*$/d' -e 's/);[[:space:]]*\/\/.*/);/' "$1" > "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Applies latest version of user.js and any custom overrides
|
# Applies latest version of user.js and any custom overrides
|
||||||
update_userjs () {
|
update_userjs () {
|
||||||
backup_file user.js
|
declare -r newfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
if [ -e user-overrides.js ]; then
|
|
||||||
cat user-overrides.js >> user.js
|
echo 'Please observe the following information:'
|
||||||
echo -e "Status: ${GREEN}Your user-overrides.js customizations have been applied!${NC}"
|
echo -e "\tFirefox profile: ${ORANGE}$(pwd)${NC}"
|
||||||
|
echo -e "\tAvailable online: ${ORANGE}$(get_userjs_version $newfile)${NC}"
|
||||||
|
echo -e "\tCurrently using: ${ORANGE}$(get_userjs_version user.js)\n${NC}\n"
|
||||||
|
|
||||||
|
if [ $CONFIRM = "yes" ]; then
|
||||||
|
echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}"
|
||||||
|
read -p "" -n 1 -r
|
||||||
|
echo -e "\n"
|
||||||
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
|
echo -e ${RED}"Process aborted"${NC}
|
||||||
|
rm $newfile
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Copy a version of user.js to diffs folder for later comparison
|
||||||
|
if [ "$COMPARE" = true ]; then
|
||||||
|
mkdir -p userjs_diffs
|
||||||
|
cp user.js userjs_diffs/past_user.js
|
||||||
|
fi
|
||||||
|
|
||||||
|
# backup user.js
|
||||||
|
mkdir -p userjs_backups
|
||||||
|
local bakname="userjs_backups/user.js.backup.$(date +"%Y-%m-%d_%H%M")"
|
||||||
|
if [ $BACKUP = "single" ]; then
|
||||||
|
bakname="userjs_backups/user.js.backup"
|
||||||
|
fi
|
||||||
|
cp user.js "$bakname"
|
||||||
|
|
||||||
|
mv "${newfile}" user.js
|
||||||
|
echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}"
|
||||||
|
|
||||||
|
# apply overrides
|
||||||
|
if [ "$SKIPOVERRIDE" = false ]; then
|
||||||
|
while IFS=',' read -ra FILE; do
|
||||||
|
add_override "$FILE"
|
||||||
|
done <<< "$OVERRIDE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create diff
|
||||||
|
if [ "$COMPARE" = true ]; then
|
||||||
|
pastuserjs=userjs_diffs/past_user.js
|
||||||
|
past_nocomments=userjs_diffs/past_userjs.txt
|
||||||
|
current_nocomments=userjs_diffs/current_userjs.txt
|
||||||
|
|
||||||
|
remove_comments $pastuserjs $past_nocomments
|
||||||
|
remove_comments user.js $current_nocomments
|
||||||
|
|
||||||
|
diffname="userjs_diffs/diff_$(date +"%Y-%m-%d_%H%M").txt"
|
||||||
|
diff=$(diff -w -B -U 0 $past_nocomments $current_nocomments)
|
||||||
|
if [ ! -z "$diff" ]; then
|
||||||
|
echo "$diff" > "$diffname"
|
||||||
|
echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}"
|
||||||
|
else
|
||||||
|
echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created."${NC}
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm $past_nocomments $current_nocomments $pastuserjs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$VIEW" = true ]; then
|
||||||
|
open_file "${PWD}/user.js"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Execute #
|
# Execute #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
## change directory to the Firefox profile directory
|
if [ $# != 0 ]; then
|
||||||
cd "$ff_profile"
|
readonly legacy_lc=$(echo $1 | tr '[A-Z]' '[a-z]')
|
||||||
|
# Display usage if first argument is -help or --help
|
||||||
|
if [ $1 = '--help' ] || [ $1 = '-help' ]; then
|
||||||
|
usage
|
||||||
|
elif [ $legacy_lc = '-donotupdate' ]; then
|
||||||
|
UPDATE="no"
|
||||||
|
legacy_argument $1
|
||||||
|
elif [ $legacy_lc = '-update' ]; then
|
||||||
|
UPDATE="yes"
|
||||||
|
legacy_argument $1
|
||||||
|
else
|
||||||
|
while getopts ":hp:ludsno:bcvr" opt; do
|
||||||
|
case $opt in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
PROFILE_PATH=${OPTARG}
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
PROFILE_PATH="list"
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
UPDATE="yes"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
UPDATE="no"
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
CONFIRM="no"
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
SKIPOVERRIDE=true
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
OVERRIDE=${OPTARG}
|
||||||
|
;;
|
||||||
|
b)
|
||||||
|
BACKUP="single"
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
COMPARE=true
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
VIEW=true
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
|
mv $tfile "${tfile}.js"
|
||||||
|
echo -e ${ORANGE}"Warning: user.js was saved to temporary file ${tfile}.js"${NC}
|
||||||
|
open_file "${tfile}.js"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo -e ${RED}"\n Error! Invalid option: -$OPTARG"${NC} >&2
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo -e ${RED}"Error! Option -$OPTARG requires an argument."${NC} >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
initiate
|
show_banner
|
||||||
update_updater
|
update_updater
|
||||||
confirmation && update_userjs
|
set_wd # changes directory to the Firefox profile (or script-dir)
|
||||||
rm -rf userjs_temps
|
update_userjs
|
||||||
|
|
||||||
cd "${currdir}"
|
cd "${currdir}"
|
||||||
|
Loading…
Reference in New Issue
Block a user