ironic-python-agent-builder/dib/ironic-python-agent-ramdisk/static/usr/local/bin/ironic-python-agent-create-rescue-user.sh
Damien Rannou 9aaf0ded2f '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
2023-10-18 15:55:06 +02:00

18 lines
457 B
Bash
Executable File

#!/bin/bash
set -eux
set -o pipefail
echo "Adding rescue user with root privileges..."
crypted_pass=$(</etc/ipa-rescue-config/ipa-rescue-password)
# '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