iaas-setup.sh: support default user not existing
For CNaaS machines we supply cloud-init user-data that does not create a default user, in this case the script would exit half-way through. Now it only tries to remove a user if it exists in the first place.
This commit is contained in:
parent
714506da1e
commit
f1ab4506f1
|
@ -26,10 +26,12 @@ fi
|
|||
# ===
|
||||
export LC_CTYPE=C.UTF-8
|
||||
|
||||
# Remove default user if present
|
||||
if id "$os"; then
|
||||
# Make sure there is no systemd process running as the initial cloud image user
|
||||
# # after the "enable root" step in prepare-iaas-$os. If there are any #
|
||||
# proceses still running as the specified user the "userdel" command # below
|
||||
# will fail.
|
||||
# after the "enable root" step in prepare-iaas-$os. If there are any
|
||||
# proceses still running as the specified user the "userdel" command
|
||||
# below will fail.
|
||||
#
|
||||
# Depending on how long we have waited between running the "enable root"
|
||||
# script and this one it is possible the process has timed out on its own,
|
||||
|
@ -51,14 +53,18 @@ while pgrep -u "$os" -xf "/lib/systemd/systemd --user"; do
|
|||
attempt=$((attempt + 1))
|
||||
done
|
||||
|
||||
# From this point we expect all commands to succeed
|
||||
set -e
|
||||
|
||||
# While the man page for "userdel" recommends using "deluser" we can not
|
||||
# run "deluser" with "--remove-home" without installing more than the
|
||||
# already included `perl-base` package on debian, so stick with the low
|
||||
# level utility.
|
||||
userdel --remove "$os"
|
||||
if ! userdel --remove "$os"; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# From this point we expect all commands to succeed
|
||||
set -e
|
||||
|
||||
rm /etc/sudoers.d/*
|
||||
|
||||
# Make sure en_US.UTF-8 is present in the system, expected by at least
|
||||
|
|
Loading…
Reference in a new issue