2019-01-29 22:27:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
ip="${1}"
|
2023-11-29 11:10:34 +00:00
|
|
|
ssh_proxy="${2}"
|
2019-01-29 22:27:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-11-29 11:10:34 +00:00
|
|
|
if [[ -n "${ssh_proxy}" ]]; then
|
|
|
|
proxyjump="-o ProxyJump=${ssh_proxy}"
|
|
|
|
fi
|
2019-01-29 22:27:56 +00:00
|
|
|
set -x
|
|
|
|
|
2022-11-14 11:41:57 +00:00
|
|
|
# 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 user while logged in as that same user:
|
|
|
|
# ===
|
|
|
|
# userdel: user ubuntu is currently used by process 44063
|
|
|
|
# ===
|
2023-11-29 11:10:34 +00:00
|
|
|
ssh "ubuntu@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-enable-root.sh
|
|
|
|
ssh "root@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-setup.sh
|