updater.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. ### ghacks-user.js updater for Mac/Linux
  3. ## author: @overdodactyl
  4. ## version: 1.0
  5. ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
  6. cd "`dirname $0`"
  7. echo -e "\nThis script should be run from your Firefox profile directory.\n"
  8. if [ -e user.js ]; then
  9. echo "Your current user.js file for this profile will be backed up and the latest ghacks version from github will take its place."
  10. echo -e "\nIf currently using the ghacks user.js, please compare versions:"
  11. echo " Available online: $(curl -s ${ghacksjs} | sed -n '4p')"
  12. echo " Currently using: $(sed -n '4p' user.js)"
  13. else
  14. echo "A user.js file does not exist in this profile. If you continue, the latest ghacks version from github will be downloaded."
  15. fi
  16. echo -e "\nIf a user-overrides.js file exists in this profile, it will be appended to the user.js.\n"
  17. read -p "Continue Y/N? " -n 1 -r
  18. echo -e "\n\n"
  19. if [[ $REPLY =~ ^[Yy]$ ]]; then
  20. if [ -e user.js ]; then
  21. # backup current user.js
  22. bakfile="user.js.backup.$(date +"%Y-%m-%d_%H%M")"
  23. mv user.js "${bakfile}" && echo "Your previous user.js file was backed up: ${bakfile}"
  24. fi
  25. # download latest ghacks user.js
  26. echo "downloading latest ghacks user.js file"
  27. curl -O ${ghacksjs} && echo "ghacks user.js has been downloaded"
  28. if [ -e user-overrides.js ]; then
  29. echo "user-overrides.js file found"
  30. cat user-overrides.js >> user.js && echo "user-overrides.js has been appended to user.js"
  31. fi
  32. else
  33. echo "Process aborted"
  34. fi