commit 500c129d484494d06ef3cffcc91f534077e5dfc3
parent 7ae034a23c7d1cfd2edcd7f5bfcdab7a08d3fcf7
Author: earthlng <earthlng@users.noreply.github.com>
Date: Sat, 18 Nov 2017 13:39:29 +0100
fix for profile detection
this should now work no matter how the script is called (including symlinks) on both Mac and Linux.
+ Storing and restoring the original working directory to prevent problems in certain circumstances.
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/updater.sh b/updater.sh
@@ -2,14 +2,22 @@
### ghacks-user.js updater for Mac/Linux
## author: @overdodactyl
-## version: 1.0
+## version: 1.1
ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
-cd "`dirname $0`"
-
echo -e "\nThis script should be run from your Firefox profile directory.\n"
+currdir=$(pwd)
+
+## get the full path of this script (greadlink for Mac, readlink for Linux)
+scriptfullpath=$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")
+
+## change directory to the Firefox profile directory
+cd "$(dirname "${scriptfullpath}")"
+
+echo -e "Updating the user.js for Firefox profile:\n$(pwd)\n"
+
if [ -e user.js ]; then
echo "Your current user.js file for this profile will be backed up and the latest ghacks version from github will take its place."
echo -e "\nIf currently using the ghacks user.js, please compare versions:"
@@ -42,3 +50,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
else
echo "Process aborted"
fi
+
+## change directory back to the original working directory
+cd "${currdir}"