mirror of
https://github.com/arkenfox/user.js.git
synced 2025-04-30 05:53:38 +02:00
Implement the the auto-update flag from updater.sh
This commit is contained in:
parent
835c3556c9
commit
064830e907
1 changed files with 35 additions and 3 deletions
|
@ -17,6 +17,17 @@ if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
||||||
## change directory to the Firefox profile directory
|
## change directory to the Firefox profile directory
|
||||||
cd "$(dirname "${sfp}")"
|
cd "$(dirname "${sfp}")"
|
||||||
|
|
||||||
|
## download method priority: curl -> wget
|
||||||
|
DOWNLOAD_METHOD=''
|
||||||
|
if command -v curl >/dev/null; then
|
||||||
|
DOWNLOAD_METHOD='curl --max-redirs 3 -so'
|
||||||
|
elif command -v wget >/dev/null; then
|
||||||
|
DOWNLOAD_METHOD='wget --max-redirect 3 --quiet -O'
|
||||||
|
else
|
||||||
|
echo -e "This script requires curl or wget.\nProcess aborted"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
fQuit() {
|
fQuit() {
|
||||||
## change directory back to the original working directory
|
## change directory back to the original working directory
|
||||||
cd "${currdir}"
|
cd "${currdir}"
|
||||||
|
@ -79,11 +90,32 @@ fStart() {
|
||||||
fQuit 0 "All done!"
|
fQuit 0 "All done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## returns the version number of a prefsCleaner.sh file
|
||||||
|
get_prefsCleaner_version() {
|
||||||
|
echo "$(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$1")"
|
||||||
|
}
|
||||||
|
|
||||||
|
## updates the prefsCleaner.sh file based on the latest public version
|
||||||
|
update_prefsCleaner() {
|
||||||
|
declare -r tmpfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/prefsCleaner.sh')"
|
||||||
|
[ -z "${tmpfile}" ] && echo -e "Error! Could not download updater.sh" && return 1 # check if download failed
|
||||||
|
|
||||||
|
if [[ $(get_prefsCleaner_version "$SCRIPT_FILE") == $(get_prefsCleaner_version "${tmpfile}") ]]; then
|
||||||
|
echo -e "There is no update available"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
mv "${tmpfile}" "$SCRIPT_FILE"
|
||||||
|
chmod u+x "$SCRIPT_FILE"
|
||||||
|
"$SCRIPT_FILE" "$@" -d
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
echo " ╔══════════════════════════╗"
|
echo " ╔══════════════════════════╗"
|
||||||
echo " ║ prefs.js cleaner ║"
|
echo " ║ prefs.js cleaner ║"
|
||||||
echo " ║ by claustromaniac ║"
|
echo " ║ by claustromaniac ║"
|
||||||
echo " ║ v1.5 ║"
|
echo " ║ v1.6 ║"
|
||||||
echo " ╚══════════════════════════╝"
|
echo " ╚══════════════════════════╝"
|
||||||
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
||||||
echo "It will remove any entries from prefs.js that also exist in user.js."
|
echo "It will remove any entries from prefs.js that also exist in user.js."
|
||||||
|
@ -100,7 +132,7 @@ do
|
||||||
;;
|
;;
|
||||||
u)
|
u)
|
||||||
download_file
|
download_file
|
||||||
update_updater
|
update_prefsCleaner
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -112,7 +144,7 @@ select option in Start Update Help Exit; do
|
||||||
;;
|
;;
|
||||||
Update)
|
Update)
|
||||||
download_file
|
download_file
|
||||||
update_updater
|
update_prefsCleaner
|
||||||
;;
|
;;
|
||||||
Help)
|
Help)
|
||||||
fUsage
|
fUsage
|
||||||
|
|
Loading…
Add table
Reference in a new issue