Micke Nordin
71e112e009
With this patch you can specify a ProxyJump for prepare-iaas-ubuntu, prepare-iaas-debian and addhost. Example: ./prepare-iaas-debian 89.47.191.7 hj ./addhost -b -n node1.extern.drive.test.sunet.se -p hj -- 89.47.191.7 where hj is a host defined in my .ssh/config suitable for a proxyjump to the host in question. This makes it easier to use ip addresses for these scripts which might be neccessary if dns takes a while to propagate.
30 lines
950 B
Bash
Executable file
30 lines
950 B
Bash
Executable file
#!/bin/bash
|
|
ip="${1}"
|
|
ssh_proxy="${2}"
|
|
|
|
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
|
|
|
|
if [[ -n "${ssh_proxy}" ]]; then
|
|
proxyjump="-o ProxyJump=${ssh_proxy}"
|
|
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 user while logged in as that same user:
|
|
# ===
|
|
# userdel: user ubuntu is currently used by process 44063
|
|
# ===
|
|
ssh "ubuntu@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-enable-root.sh
|
|
ssh "root@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-setup.sh
|