Merge pull request #26 from eest/patlu-iaas-missing-default-user

This commit is contained in:
Fredrik Thulin 2023-01-26 09:06:39 +01:00 committed by GitHub
commit 73f3626176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,22 +26,24 @@ fi
# === # ===
export LC_CTYPE=C.UTF-8 export LC_CTYPE=C.UTF-8
# Make sure there is no systemd process running as the initial cloud image user # Remove default user if present
# # after the "enable root" step in prepare-iaas-$os. If there are any # if id "$os"; then
# proceses still running as the specified user the "userdel" command # below # Make sure there is no systemd process running as the initial cloud image user
# 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
# Depending on how long we have waited between running the "enable root" # below will fail.
# script and this one it is possible the process has timed out on its own, #
# so run this command before doing "set -e" in case there is no process # Depending on how long we have waited between running the "enable root"
# to match. # script and this one it is possible the process has timed out on its own,
pkill -u "$os" -xf "/lib/systemd/systemd --user" # so run this command before doing "set -e" in case there is no process
# to match.
pkill -u "$os" -xf "/lib/systemd/systemd --user"
# Make sure the process has gone away before continuing # Make sure the process has gone away before continuing
sleep_seconds=1 sleep_seconds=1
attempt=1 attempt=1
max_attempts=10 max_attempts=10
while pgrep -u "$os" -xf "/lib/systemd/systemd --user"; do while pgrep -u "$os" -xf "/lib/systemd/systemd --user"; do
if [ $attempt -gt $max_attempts ]; then if [ $attempt -gt $max_attempts ]; then
echo "failed waiting for systemd process to exit, please investigate" echo "failed waiting for systemd process to exit, please investigate"
exit 1 exit 1
@ -49,16 +51,20 @@ while pgrep -u "$os" -xf "/lib/systemd/systemd --user"; do
echo "systemd process still running as '$os' user, this is attempt $attempt out of $max_attempts, sleeping for $sleep_seconds seconds..." echo "systemd process still running as '$os' user, this is attempt $attempt out of $max_attempts, sleeping for $sleep_seconds seconds..."
sleep $sleep_seconds sleep $sleep_seconds
attempt=$((attempt + 1)) attempt=$((attempt + 1))
done done
# 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.
if ! userdel --remove "$os"; then
exit 1
fi
fi
# From this point we expect all commands to succeed # From this point we expect all commands to succeed
set -e 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"
rm /etc/sudoers.d/* rm /etc/sudoers.d/*
# Make sure en_US.UTF-8 is present in the system, expected by at least # Make sure en_US.UTF-8 is present in the system, expected by at least