Skip to content

Commit

Permalink
Added option to fast SSH on Vagrant machine on startup
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Apr 2, 2020
1 parent 07eafa1 commit 9241a57
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 17 deletions.
34 changes: 34 additions & 0 deletions dev-tools/vagrant/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2020 Eurotech and/or its affiliates
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Eurotech - initial API and implementation
#
#******************************************************************************

set -e

destroy() {
echo 'Destroying Vagrant machine...'
vagrant destroy -f $1 || { echo 'Destroying Vagrant machine... ERROR!'; exit 1; }
echo 'Destroying Vagrant machine... DONE!'
}

print_usage_destroy(){
echo "Usage: $(basename $0) help|base-box|develop" >&2
}

if [[ "$1" == 'develop' ]]; then
destroy $1
elif [[ "$1" == 'base-box' ]]; then
destroy $1
else
print_usage_destroy
exit 1
fi
32 changes: 32 additions & 0 deletions dev-tools/vagrant/ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2020 Eurotech and/or its affiliates
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Eurotech - initial API and implementation
#
#******************************************************************************

set -e

print_usage_ssh(){
echo "Usage: $(basename $0) help|develop" >&2
}

ssh() {
echo 'SSH into Vagrant machine...'
vagrant ssh $1 || { echo 'SSH into Vagrant machine... ERROR!'; exit 1; }
echo 'SSH into Vagrant machine... DONE!'
}

if [[ "$1" == 'develop' ]]; then
ssh $1
else
print_usage_ssh
exit 1
fi
46 changes: 29 additions & 17 deletions dev-tools/vagrant/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2011, 2018 Eurotech and/or its affiliates
# Copyright (c) 2016, 2020 Eurotech and/or its affiliates
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -12,30 +12,42 @@
#
#******************************************************************************

destroy_old_machines(){
vagrant destroy -f develop
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

print_usage_start(){
echo "Usage: $(basename $0) help|base-box|develop [--ssh]" >&2
}

start_develop(){
echo 'Starting Kapua Vagrant develop machine...'

vagrant up

echo 'Starting Kapua Vagrant develop machine... DONE!'
echo "Please type 'vagrant ssh' to connect to the machine."
echo "Follow the instructions to start the Kapua components from the machine"
echo 'Starting Vagrant machine...'
vagrant up || { echo 'Starting Vagrant machine... ERROR!'; exit 1; }
echo 'Starting Vagrant machine... DONE!'
}

print_usage(){
echo "Usage: $(basename $0) help|base-box|develop" >&2
start_ssh() {
if [[ "$2" == '--ssh' ]]; then
sh ${SCRIPT_DIR}/ssh.sh $1
else
echo "Unrecognised parameter: ${1}"
print_usage_start
fi
}

if [ "$1" == 'develop' ]; then
destroy_old_machines
if [[ "$1" == 'develop' ]]; then
sh ${SCRIPT_DIR}/destroy.sh $1 || exit 1;

start_develop
elif [ "$1" == 'base-box' ]; then
sh baseBox/create.sh

if [[ -z "$2" ]]; then
echo "Please type './ssh.sh develop' to connect to the machine."
else
start_ssh $1 $2
fi

elif [[ "$1" == 'base-box' ]]; then
sh ${SCRIPT_DIR}/baseBox/create.sh
else
print_usage
print_usage_start
exit 1
fi

0 comments on commit 9241a57

Please sign in to comment.