mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-07 17:33:45 +02:00
auto update based on version number
This commit is contained in:
parent
6ee25c2bf5
commit
512d62d70c
1 changed files with 25 additions and 4 deletions
29
updater.sh
Normal file → Executable file
29
updater.sh
Normal file → Executable file
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
### ghacks-user.js updater for Mac/Linux
|
### ghacks-user.js updater for Mac/Linux
|
||||||
## author: @overdodactyl
|
## author: @overdodactyl
|
||||||
## version: 1.2
|
## version: 1.3
|
||||||
|
|
||||||
ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
|
ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
|
||||||
|
updater="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh"
|
||||||
|
|
||||||
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
|
||||||
|
|
||||||
currdir=$(pwd)
|
currdir=$(pwd)
|
||||||
|
|
||||||
|
@ -19,6 +19,27 @@ 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}")"
|
||||||
|
|
||||||
|
## Check if there's a newer version of the updater script available
|
||||||
|
online_version="$(curl -s ${updater} | sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p')"
|
||||||
|
path_to_script="$(dirname "${sfp}")/updater.sh"
|
||||||
|
current_version="$(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$path_to_script")"
|
||||||
|
|
||||||
|
if (( $(echo "$online_version > $current_version" | bc -l) )); then
|
||||||
|
echo -e "There is a new updater script available online. It will replace this one and be executed.\n"
|
||||||
|
mv updater.sh old_updater.sh
|
||||||
|
curl -O ${updater} && echo -e "\nThe latest updater script has been downloaded\n"
|
||||||
|
# make new file executable
|
||||||
|
chmod +x updater.sh
|
||||||
|
|
||||||
|
# execute new updater script
|
||||||
|
./updater.sh
|
||||||
|
|
||||||
|
# exit script
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
||||||
|
|
||||||
echo -e "Updating the user.js for Firefox profile:\n$(pwd)\n"
|
echo -e "Updating the user.js for Firefox profile:\n$(pwd)\n"
|
||||||
|
|
||||||
if [ -e user.js ]; then
|
if [ -e user.js ]; then
|
||||||
|
@ -55,4 +76,4 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## change directory back to the original working directory
|
## change directory back to the original working directory
|
||||||
cd "${currdir}"
|
cd "${currdir}"
|
Loading…
Add table
Reference in a new issue