'sudo' group different between RH and Debian

When creating the rescue user, check if we are on Debian or RH based
in order to use the right sudo group

Change-Id: I894f47a1eb0ecbccbecc0900980de7ad9da72425
This commit is contained in:
Damien Rannou 2023-10-16 16:26:38 +02:00
parent 612ce753c5
commit 9aaf0ded2f

View File

@ -5,5 +5,13 @@ set -o pipefail
echo "Adding rescue user with root privileges..."
crypted_pass=$(</etc/ipa-rescue-config/ipa-rescue-password)
useradd -m rescue -G wheel -p $crypted_pass
# 'rescue' user should belong to sudo group
# on RH based it's wheel, on Debian based it's sudo
sudo_group=wheel
if [ "$(grep -Ei 'debian|ubuntu' /etc/*release)" ] ; then
sudo_group=sudo
fi
useradd -m rescue -G $sudo_group -p $crypted_pass
echo "rescue ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/rescue