Merge pull request #50 from SUNET/kano-sshproxyjump

PREPARE/ADDHOST: allow the ues of proxyjump with ip address
This commit is contained in:
Johan Wassberg 2023-11-29 12:53:05 +01:00 committed by GitHub
commit ecedda68e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

15
addhost
View file

@ -13,11 +13,12 @@ function usage() {
echo " <host> can be an IP number, or something that resolves to one"
}
while getopts "bhn:" this; do
while getopts "bhnp:" this; do
case "${this}" in
h) usage; exit 0;;
b) cmd_do_bootstrap="yes" ;;
n) cmd_fqdn="${OPTARG}" ; shift ;;
p) cmd_proxy="${OPTARG}" ; shift ;;
*) echo "Unknown option ${this}"; echo ""; usage; exit 1;;
esac
done
@ -36,6 +37,10 @@ if test -z "$cmd_hostname"; then
exit 1
fi
if [[ -n $cmd_proxy ]]; then
proxyjump="-o ProxyJump=${cmd_proxy}"
fi
test -f cosmos.conf && . ./cosmos.conf
_remote=${remote:='ro'}
@ -57,8 +62,8 @@ fi
if [ "$cmd_do_bootstrap" = "yes" ]; then
cosmos_deb=$(find apt/ -maxdepth 1 -name 'cosmos_*.deb' | sort -V | tail -1)
scp "$cosmos_deb" apt/bootstrap-cosmos.sh root@"$cmd_hostname":
ssh root@"$cmd_hostname" ./bootstrap-cosmos.sh "$cmd_fqdn" "$rrepo" "$rtag"
ssh root@"$cmd_hostname" cosmos update
ssh root@"$cmd_hostname" cosmos apply
scp $proxyjump "$cosmos_deb" apt/bootstrap-cosmos.sh root@"$cmd_hostname":
ssh root@"$cmd_hostname" $proxyjump ./bootstrap-cosmos.sh "$cmd_fqdn" "$rrepo" "$rtag"
ssh root@"$cmd_hostname" $proxyjump cosmos update
ssh root@"$cmd_hostname" $proxyjump cosmos apply
fi

View file

@ -1,5 +1,6 @@
#!/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:"
@ -9,6 +10,9 @@ if [[ -z "${ip}" ]]; then
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
@ -21,5 +25,5 @@ script_dir=$(dirname "$0")
# ===
# userdel: user debian is currently used by process 1082
# ===
ssh "debian@${ip}" "bash -s" < "$script_dir"/iaas-enable-root.sh
ssh "root@${ip}" "bash -s" < "$script_dir"/iaas-setup.sh
ssh "debian@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-enable-root.sh
ssh "root@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-setup.sh

View file

@ -1,5 +1,6 @@
#!/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:"
@ -10,6 +11,9 @@ if [[ -z "${ip}" ]]; then
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
@ -21,5 +25,5 @@ script_dir=$(dirname "$0")
# ===
# userdel: user ubuntu is currently used by process 44063
# ===
ssh "ubuntu@${ip}" "bash -s" < "$script_dir"/iaas-enable-root.sh
ssh "root@${ip}" "bash -s" < "$script_dir"/iaas-setup.sh
ssh "ubuntu@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-enable-root.sh
ssh "root@${ip}" ${proxyjump} "bash -s" < "$script_dir"/iaas-setup.sh