Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PREPARE/ADDHOST: allow the ues of proxyjump with ip address #50

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions addhost
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'}
Expand All @@ -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
8 changes: 6 additions & 2 deletions prepare-iaas-debian
Original file line number Diff line number Diff line change
@@ -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:"
Expand All @@ -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

Expand All @@ -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
8 changes: 6 additions & 2 deletions prepare-iaas-ubuntu
Original file line number Diff line number Diff line change
@@ -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:"
Expand All @@ -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
Expand All @@ -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