Wednesday, August 12, 2009

[Dynamips] script สำหรับ start process dynamips

vi dynamips.sh

#!/usr/local/bin/bash
# Script for start dynamips process

DYNAMIPS_BIN=/usr/local/bin/dynamips
WORKDIR=/dynamips/cache
PORT_START=3600
NUM_PROC=12

case "$1" in
start)
cd $WORKDIR
i=0
while [ $i -ne $NUM_PROC ]
do
(( PORT = $PORT_START + $i ))
echo "Start dynamips hypervisor port $PORT "
nice $DYNAMIPS_BIN -H $PORT -l /dev/null > /dev/null 2>&1 &
(( i = i + 1 ))
done
exit 0
;;
stop)
echo "Stop dynamips all process .."
pkill -9 dynamips
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` {start|stop|restart}" >&2
exit 64
;;
esac

No comments: