Skip to content

Commit

Permalink
add some check in docker-machine-cluster.sh and swarm.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
alainivars committed Jun 28, 2019
1 parent 2014775 commit 2dce218
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 33 deletions.
44 changes: 30 additions & 14 deletions utils2devops/bin/docker-machine-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Just a quick script to create and destroy a local docker-machine-cluster
#

echo "started..."
count=0
actions=()

Expand All @@ -25,23 +24,40 @@ fi

while [ "$1" != "" ]; do
case $1 in
-c | --create ) shift
count=$1
actions=(create_nodes)
;;
-d | --destroy ) shift
actions=(destroy_nodes)
count=$1
;;
-h | --help ) actions=(usage)
exit
;;
* ) actions=(usage)
exit 1
-c | --create )
shift
if [ -z "$1" ]
then
echo "You must give a number of node to create"
exit 1
else
count=$1
fi
actions=(create_nodes)
;;
-d | --destroy )
shift
actions=(destroy_nodes)
if [ -z "$1" ]
then
echo "You must give a number of node to destroy"
exit 1
else
count=$1
fi
;;
-h | --help )
actions=(usage)
exit
;;
* )
actions=(usage)
exit 1
esac
shift
done

echo "started..."
let nodes=manager_count+worker_count

if [ -z "${DOCKER_MACHINE_DRIVER}" ]; then
Expand Down
60 changes: 41 additions & 19 deletions utils2devops/bin/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Just a quick script to create and destroy a local swarm
#

echo "started..."
manager_count=0
worker_count=0
worker=
Expand Down Expand Up @@ -34,28 +33,51 @@ fi

while [ "$1" != "" ]; do
case $1 in
-c | --create ) #shift
actions=(create_swarm_nodes)
;;
-r | --remove ) #shift
manager_count=$1
actions=(remove_swarm_nodes)
;;
-m | --count_master ) shift
manager_count=$1
;;
-w | --count_worker ) shift
worker_count=$1
;;
-h | --help ) actions=(usage)
exit
;;
* ) actions=(usage)
exit 1
-c | --create )
actions=(create_swarm_nodes)
;;
-r | --remove )
if [ -z "$1" ]
then
echo "You must give a number of node to remove"
exit 1
else
manager_count=$1
fi
actions=(remove_swarm_nodes)
;;
-m | --count_master )
shift
if [ -z "$1" ]
then
echo "You must give a number of manager to create"
exit 1
else
manager_count=$1
fi
;;
-w | --count_worker )
shift
if [ -z "$1" ]
then
echo "You must give a number of worker to create"
exit 1
else
worker_count=$1
fi
;;
-h | --help )
actions=(usage)
exit
;;
* )
actions=(usage)
exit 1
esac
shift
done

echo "started..."
let nodes=manager_count+worker_count

if [ -z "${DOCKER_MACHINE_DRIVER}" ]; then
Expand Down

0 comments on commit 2dce218

Please sign in to comment.