matrix-ops/prepare-iaas-debian
Patrik Lundin 300c4283af
Rework prepare-iaas-debian
* Log in as few times as possible to not require a lot if yubikey
  keypresses
* Make sure en_US.UTF-8 is present
* Replace `rm -rf` with userdel command
* Make sure the debian account is actually deleted
* Remove locale related warnings when running script from macOS
2022-10-10 16:17:20 +02:00

29 lines
994 B
Bash
Executable file

#!/bin/bash
ip="${1}"
if [[ -z "${ip}" ]]; then
echo "Please specify a cloud image host that the script should do the following on:"
echo " #1 enable root-login"
echo " #2 remove the default user"
echo " #3 run apt-get update and dist-upgrade without interaction"
echo " #4 reboot to start using the new kernel, updated packages etc."
exit 1
fi
set -x
# Make sure we read the additional scripts from the same directory as
# this script is located at
script_dir=$(dirname "$0")
# The reason for running two separate logins is that it is tricky to
# remove the initial debian user while logged in as that same user:
# ===
# Removing user `debian' ...
# Warning: group `debian' has no more members.
# userdel: user debian is currently used by process 12081
# /usr/sbin/deluser: `/sbin/userdel debian' returned error code 8. Exiting.
# ===
ssh "debian@${ip}" "bash -s" < "$script_dir"/debian-enable-root.sh
ssh "root@${ip}" "bash -s" < "$script_dir"/debian-setup.sh