Merge pull request #13047 from AFOliveira/fix/factory-reset-packaged-path-20260923
Pin factory-reset elevation to the packaged command
This commit is contained in:
3 files changed
+87
-1
No files matched your search
@@ -29,17 +29,25 @@
|
||||
set -euo pipefail
|
||||
|
||||
PROVISIONING_DIR=/var/lib/omarchy/provisioning
|
||||
PACKAGED_PATH=/usr/bin/omarchy-system-factory-reset
|
||||
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
|
||||
TOP_MNT=/run/omarchy-system-factory-reset/top
|
||||
NEXT_NAME=@omarchy-reset-next
|
||||
LOG_FILE=/var/log/omarchy-system-factory-reset.log
|
||||
|
||||
# Never replace a newer checkout reset with a different installed implementation.
|
||||
if ! /usr/bin/cmp -s -- "${BASH_SOURCE[0]}" "$PACKAGED_PATH"; then
|
||||
echo "Factory reset differs from the installed command. Install the matching Omarchy package before resetting." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Self-elevate so the menu entry (and a bare shell invocation) need no sudo
|
||||
# prefix. The caller's gum theme vars are forwarded as `env` arguments rather
|
||||
# than via `sudo -E`, so styling survives even under an env_reset sudoers.
|
||||
# Always elevate the packaged copy, including when invoked from a dev checkout.
|
||||
if (( EUID != 0 )); then
|
||||
mapfile -t gum_env < <(env | grep '^GUM_' || true)
|
||||
exec sudo env "${gum_env[@]}" "$0" "$@"
|
||||
exec sudo env "${gum_env[@]}" "$PACKAGED_PATH" "$@"
|
||||
fi
|
||||
|
||||
export PATH="$OMARCHY_PATH/bin:$PATH"
|
||||
|
||||
Reference in new issue
Block a user