19 Commits

Author SHA1 Message Date
9ao9ai9ar
481c45397b Shell script rewrite to comply with POSIX and best practices.
The rewrite is focused on the following five areas of interest:
1. Portability. The scripts have been tested to work in recent versions
   of the following operating systems and shells: macOS, Linux (Fedora,
   Debian, Ubuntu, openSUSE, Arch, Alpine, NixOS), BSD (FreeBSD,
   OpenBSD, NetBSD, DragonFly), SunOS (Solaris, OpenIndiana), Haiku;
   bash, dash, ash, ksh, oksh, zsh, XPG4 sh, pdksh, mksh, yash, posh,
   gwsh, bosh, osh.
2. Robustness. Employ secure shell scripting techniques, incorporate
   battle-tested open source code, clear all ShellCheck warnings, and
   fail early.
3. Composability. Put (almost) everything inside functions and make the
   scripts dot source friendly.
4. Consistency. Use tput to abstract away terminal color codes, write
   templated diagnostic messages and follow conventions in the use of
   exit status and redirections.
5. Readability. Comment extensively, assign descriptive names to
   variables and functions, and use here-documents to ease reading and
   writing multi-line messages.

Known behavioral changes:
1. There are changes to the way some options are parsed and acted on.
   For example, when both the -l and -p options are specified, -l will
   be ignored; in the old behavior, the last specified option would
   take effect. Also, an old quirk where passing the argument 'list' to
   -p was equivalent to specifying the -l option has been fixed.
2. The -h, -l and -p options of updater.sh have been added to
   prefsCleaner.sh as well.
3. All temporary files are now created using mktemp and no longer
   actively deleted, so users won't find them in the working directory
   anymore in the case of error.
4. The old prefs.js cleaning logic, which relied on non-POSIX features,
   is not preserved in the rewrite.

Resolves #1855
Resolves #1446
Fixes #1810
2025-02-24 20:23:36 +08:00
earthlng
4a510a4b4c
prefsCleaner.sh v2.1
- remove group root/wheel check
2023-11-24 13:38:25 +00:00
earthlng
f54d632da5
v2.0 - improve root check 2023-10-07 10:33:49 +00:00
earthlng
b117916207
Update prefsCleaner.sh 2023-04-24 16:58:19 +00:00
earthlng
d50c772d7d
v1.8 - fix syntax error 2023-04-23 09:14:03 +00:00
Celestial Nebula
f2e4a79ca0
updater.sh/prefsCleaner.sh: Check for root and abort (#1651)
* updater.sh/prefsCleaner.sh: Check for root and abort

Check if running as root and if any files have the owner/group as root|wheel.
Abort on both.

Should (hopefully) prevent stuff like: https://github.com/arkenfox/user.js/issues/1587
Discussion: https://github.com/arkenfox/user.js/pull/1595

---------

Co-authored-by: Mohammed Anas <triallax@tutanota.com>
Co-authored-by: earthlng <earthlng@users.noreply.github.com>
2023-04-22 11:52:26 +00:00
earthlng
7135907b2f
Update prefsCleaner.sh 2022-12-10 14:35:48 +00:00
earthlng
12ca83b550
v1.6 - autoupdate 2022-12-10 14:00:23 +00:00
iTawkins
a93047e6c9
Improves usability by clarifying desired action (#1583) 2022-11-13 14:31:17 +00:00
earthlng
ecb63e82c9
Update prefsCleaner.sh 2022-07-30 12:23:27 +00:00
xfzv
ded7c01a08
Back up prefs.js to prefsjs_backups directory (#1514) 2022-07-30 12:22:32 +00:00
i-c-u-p
64bc683c3f
Made prefsCleaner.sh executable (#1416)
Changed permissions of prefsCleaner.sh from 644 to 755 to be able to run it via "./prefsCleaner.sh" with out first executing "chmod +x prefsCleaner.sh".
2022-04-08 07:03:43 +00:00
a1346054
6381b1aeb9
prefsCleaner.sh: Fix invalid regular expression (#1258) 2021-09-28 19:24:54 +00:00
a1346054
5cdea955e7
Simple maintenance improvements (#1255)
* Use direct check for existence of file

* Fix shellcheck warnings

* Unify codestyle in scripts

* Trim excess whitespace
2021-09-27 15:23:12 +00:00
earthlng
9018577a3e
v1.4 (#1189)
- add -s parameter to start immediately / skip prompt / run non-interactive

This is useful if the user wants to automate the process of updating the user.js and cleaning prefs.

- fQuit: error messages to stderr
- fFF_check: info msg to stderr

Better support for suppressing/redirecting stdout while still showing any error messages in the console, useful for example with `prefsCleaner.sh -s >/dev/null`
2021-06-07 11:18:40 +00:00
earthlng
f61d4a0d38
Update prefsCleaner.sh 2020-09-15 11:55:28 +00:00
earthlng
cd9fc110b0
v1.2
look for `lock` file instead of `webappsstore.sqlite-shm` to detect if firefox is running or not (with this profile)

see https://github.com/ghacksuserjs/ghacks-user.js/pull/405#issuecomment-581447586 and follow-up comments.

Thanks @atomGit for reporting the issue and @rusty-snake for confirming it.
2020-02-10 16:47:17 +00:00
claustromaniac
71adc43d17 v1.1 regex fix (#409) 2018-04-25 22:56:54 +02:00
claustromaniac
b4f1b4dbbf prefsCleaner.sh (for Linux/Mac) (#405)
Port of the prefsCleaner.bat for anything(?) with a bash shell.
2018-04-24 14:47:50 +02:00