Update after.sh
This commit is contained in:
parent
b465b0519a
commit
3e835129ef
1 changed files with 2 additions and 9 deletions
11
after.sh
11
after.sh
|
|
@ -11,17 +11,11 @@ USERNAME=$(awk -F: '$3 >= 1000 && $3 < 60000 && $6 ~ /^\/home\// {print $1; exit
|
|||
|
||||
USER_HOME="/home/$USERNAME"
|
||||
|
||||
# ─────────────────────────────────────
|
||||
# NO PASSWORD SETUP
|
||||
# ─────────────────────────────────────
|
||||
# ─────────────────────────────────────
|
||||
# Temporarily enable passwordless sudo
|
||||
# ─────────────────────────────────────
|
||||
|
||||
SUDOERS_FILE="/etc/sudoers.d/00_$USERNAME"
|
||||
SUDOERS_BACKUP="${SUDOERS_FILE}.backup"
|
||||
|
||||
cp "$SUDOERS_FILE" "$SUDOERS_BACKUP"
|
||||
SUDOERS_FILE="/etc/sudoers.d/99-install-script"
|
||||
|
||||
printf '%s ALL=(ALL:ALL) NOPASSWD: ALL\n' "$USERNAME" > "$SUDOERS_FILE"
|
||||
chmod 440 "$SUDOERS_FILE"
|
||||
|
|
@ -29,8 +23,7 @@ chmod 440 "$SUDOERS_FILE"
|
|||
visudo -c || exit 1
|
||||
|
||||
cleanup() {
|
||||
mv "$SUDOERS_BACKUP" "$SUDOERS_FILE"
|
||||
rm -f /etc/sudoers.d/99-install-script
|
||||
rm -f "$SUDOERS_FILE"
|
||||
visudo -c
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
|
|
|||
Loading…
Reference in a new issue