diff --git a/bootstrap.sh b/bootstrap.sh index 086380cd7dd9aaa9e3a2113acf0c8661a7f6a024..9ae40adf0a7007fcea3eb49f6c59270ed61986e4 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -8,8 +8,27 @@ else host=$1 fi +prepareNode() +{ + ssh "root@${host}" "bash -s" -- "$host" <prepare-node.sh +} + +getControl() +{ + ssh "root@${host}" "bash -s" -- <get-control.sh + scp "./control-shell.sh" "root@${host}:/oas/bin/control-shell.sh" +} + +setup() +{ + ssh -t "root@${host}" "CONTROL=bootstrap /bin/bash --init-file /oas/bin/control-shell.sh" +} + if [ -z "$2" ] then - ssh "root@${host}" "bash -s" -- "$host" <prepare-node.sh + prepareNode + getControl + setup +else + $2 fi -ssh "root@${host}" "bash -s" -- <get-control.sh diff --git a/control-shell.sh b/control-shell.sh new file mode 100755 index 0000000000000000000000000000000000000000..5eb9ed4dc80a206c4cad716c12ac4ddcf12341cd --- /dev/null +++ b/control-shell.sh @@ -0,0 +1,15 @@ +#!/bin/bash +if [ "$CONTROL" == "bootstrap" ] +then + echo "Bootstrapping cluster..." + command="/control/bin/control setup" +else + echo "Starting control shell..." + command="/bin/bash --init-file /control/.bashrc" +fi +docker run --rm -it \ + -v /oas:/oas \ + -v /oas/local/control:/control/local \ + --name oas-control \ + docker.greenhost.net/openappstack/control \ + $command diff --git a/control.sh b/control.sh index 93b407d429ed4eccfc41ebd91f422b6dd48483e1..1ecb24788ff66bc82887cb5f69d53500baa28614 100755 --- a/control.sh +++ b/control.sh @@ -8,9 +8,4 @@ else host=$1 fi -ssh -t "root@${host}" "docker run --rm -it \ - -v /oas:/oas \ - -v /oas/local/control:/control/local \ - --name oas-control \ - docker.greenhost.net/openappstack/control \ - /bin/bash" +ssh -t "root@${host}" "/oas/bin/control-shell.sh" diff --git a/get-control.sh b/get-control.sh index 8fcc7df5681651b2461a785e4b00b8911a205351..e68516283ed2a06e10c059c2cdb56790f23267eb 100644 --- a/get-control.sh +++ b/get-control.sh @@ -4,7 +4,7 @@ hostname=$(hostname) configDir="/oas/config" sshKeyFile="${configDir}/ssh_key" -mkdir -p "/oas/local/control" +mkdir -p "/oas/local/control" "/oas/bin" # Set up ssh access from local control container. if ! [ -f "$sshKeyFile" ]