From 34db87f39afe22f69c40e39275fbb8f25b8e93ca Mon Sep 17 00:00:00 2001 From: Ho Kim Date: Fri, 23 Sep 2022 18:58:40 +0000 Subject: [PATCH] Fix order bug in bootstrapper --- templates/bootstrap/bootstrap.sh | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/templates/bootstrap/bootstrap.sh b/templates/bootstrap/bootstrap.sh index 4f77da63..727df8ef 100755 --- a/templates/bootstrap/bootstrap.sh +++ b/templates/bootstrap/bootstrap.sh @@ -113,6 +113,23 @@ function spawn_node() { exit 1 fi + # Update SSH ListenAddress + "$CONTAINER_RUNTIME" exec "$name" sed -i \ + "s/^\(ListenAddress\) .*\$/\1 $node_ip/g" \ + /etc/ssh/sshd_config + + # Restart SSH daemon + while [ ! $( + "$CONTAINER_RUNTIME" exec -it $name ps -s 1 | + awk '{print $4}' | + tail -n 1 | + grep '^systemd' + ) ]; do + sleep 1 + done + "$CONTAINER_RUNTIME" exec "$name" \ + systemctl restart sshd 2>/dev/null || true + # Get SSH configuration while :; do # Get SSH port @@ -135,23 +152,6 @@ function spawn_node() { then break fi - - # Update SSH ListenAddress - "$CONTAINER_RUNTIME" exec "$name" sed -i \ - "s/^\(ListenAddress\) .*\$/\1 $node_ip/g" \ - /etc/ssh/sshd_config - - # Restart SSH daemon - while [ ! $( - "$CONTAINER_RUNTIME" exec -it $name ps -s 1 | - awk '{print $4}' | - tail -n 1 | - grep '^systemd' - ) ]; do - sleep 1 - done - "$CONTAINER_RUNTIME" exec "$name" \ - systemctl restart sshd 2>/dev/null || true done # Save as environment variable