#!/bin/bash


VEID=$1
NUMS=$2

IP_BASE=194.87.38

Usage() {
    echo 'Usage: ve-stop <VEID> [<COUNT>]'
    echo '       Shutdown <COUNT> (default 1) VEs, starting with given VEID'
    exit 1
}

case "$VEID" in
  [1-9]*)
      : ;;
  *)
      Usage ;;
esac

case "$NUMS" in
   [0-9]*)
       :;;
   *)
       NUMS=1
       ;;
esac

if [ "$VEID" -lt 1 -o "$VEID" -gt 254 ]; then
    Usage
fi

while [ "$NUMS" -gt 0 -a "$VEID" -lt 255 ]
do
    (envutil --kill $VEID ; veroot-setup --umount $VEID) &
    VEID=$[VEID + 1]
    NUMS=$[NUMS - 1]
done

exit 0
