diff --git a/scripts/createVm.sh b/scripts/createVm.sh index f72f8f4..54934fa 100644 --- a/scripts/createVm.sh +++ b/scripts/createVm.sh @@ -27,22 +27,62 @@ echo "${os}${osversion//./}" } -NETWORK=`findEthEthernet` +function createVm +{ + action=$1 + NETWORK=`findEthEthernet` -if [ "Shanthys-Mini.heaerieglobalsolutions.net" == "$currentHost" ] -then - HOSTMACHINE="mc02" + if [ "Shanthys-Mini.heaerieglobalsolutions.net" == "$currentHost" ] + then + HOSTMACHINE="mc02" + fi + + if [ "Agalyas-Air.heaerieglobalsolutions.net" == "$currentHost" ] + then + HOSTMACHINE="mc01" + fi + HOSTNAME_PREFIX="$REGION-$HOSTMACHINE-$VIRTUALMACHINE-`osVersion $OS $OSVERSION`-$NETWORK-$APP" + if [ "$action" == "create" ] + then + echo "create" + SEQ=`./getSeq.sh $HOSTNAME_PREFIX current++` + else + SEQ=`./getSeq.sh $HOSTNAME_PREFIX current--` + fi + echo $SEQ + HOSTNAME="$HOSTNAME_PREFIX-$SEQ" + + mkdir ~/data/$HOSTNAME + if [ "$action" == "create" ] + then + multipass launch $OSVERSION --name $HOSTNAME --memory 8G --disk 50G --cpus 8 --network en0 --mount ~/data/$HOSTNAME:/data/ + else + + multipass delete --name $HOSTNAME purge + + fi + +} + +noOfinstance=1 + +if [ "$1" != "" ] +then + noOfinstance=$1 fi -if [ "Agalyas-Air.heaerieglobalsolutions.net" == "$currentHost" ] -then - HOSTMACHINE="mc01" +action="create" +if [ "$2" != "" ] +then + action=$2 fi -HOSTNAME_PREFIX="$REGION-$HOSTMACHINE-$VIRTUALMACHINE-`osVersion $OS $OSVERSION`-$NETWORK-$APP" -SEQ=`./getSeq.sh $HOSTNAME_PREFIX` -HOSTNAME="$HOSTNAME_PREFIX-$SEQ" -mkdir ~/data/$HOSTNAME -multipass launch $OSVERSION --name $HOSTNAME --memory 8G --disk 50G --cpus 8 --network en0 --mount ~/data/$HOSTNAME:/data/ + +for i in {1..$noOfinstance}; +do + createVm $action +done + + diff --git a/scripts/getSeq.sh b/scripts/getSeq.sh index 7173b21..d7e2b19 100755 --- a/scripts/getSeq.sh +++ b/scripts/getSeq.sh @@ -2,6 +2,7 @@ mkdir -p $DIR agrc=$# seqName=default +action="next" if [ ! "$agrc" -le 0 ] then #{ @@ -10,15 +11,48 @@ #else #{ seqName=$1 + if [ "$2" != "" ] + then + action=$2 + fi #} fi fileName=$DIR/$seqName count=0 +returnCount=0 if [ -f $fileName ] then #{ + count=$(cat $fileName) - count=`expr $count + 1` + if [ "$action" == "current" ] + then + returnCount=$count + + elif [ "$action" == "current++" ] + then + returnCount=$count + count=`expr $count + 1` + elif [ "$action" == "++current" ] + then + count=`expr $count + 1` + returnCount=$count + elif [ "$action" == "--current" ] + then + count=`expr $count - 1` + returnCount=$count + elif [ "$action" == "current--" ] + then + returnCount=$count + count=`expr $count - 1` + elif [ "$action" == "previous" ] + then + count=`expr $count - 1` + returnCount=$count + else + count=`expr $count + 1` + returnCount=$count + fi #} #else #{ @@ -28,5 +62,5 @@ echo "$count" > $fileName #return $count -echo $count +echo $returnCount exit 0