#!/bin/bash #### VARIABILI SCRIPTNAME=`echo $0 | awk -vFS='/' '{print $NF}'` EXEC=/hosthome${PWD#$HOME}${0#'.'} waitfinish() { SEMAPHORE=$1.boot touch $SEMAPHORE while [ -f $SEMAPHORE ]; do sleep 2 done sleep 2 } notifyfinish() { rm $1.boot } r_1=r_1-r1 r_2=r_2-r2 r_3=r_3-r3 r_4=r_4-r4 r_5=r_5-r5 if ! [ `uname -r|tail -c 3` = "um" ]; then # only realhost takes arguments case "$1" in start) ############## CREATE THE HOSTS FROM SCRATCH if [ -e $r_1.disk ] || [ -e $r_2.disk ] || [ -e $r_3.disk ] || [ -e $r_4.disk ] || [ -e $r_5.disk ] ; then echo "$0: some .disk file exists in this directory!" echo " launch "$0 clean" first" exit 1 fi vstart $r_1 --eth3=A --eth2=E --eth1=G --eth0=H --new --exec=$EXEC waitfinish $r_1 vstart $r_2 --eth2=B --eth0=E --eth1=F --new --exec=$EXEC waitfinish $r_2 vstart $r_3 --eth3=C --eth0=F --eth1=G --eth2=I --new --exec=$EXEC waitfinish $r_3 vstart $r_4 --eth1=D --eth3=H --eth2=I --eth0=L --new --exec=$EXEC waitfinish $r_4 vstart $r_5 --eth0=L --new --exec=$EXEC waitfinish $r_5 ;; restart) ############## CREATE THE HOSTS FROM SCRATCH if [ -e $r_1.disk ] || [ -e $r_2.disk ] || [ -e $r_3.disk ] || [ -e $r_4.disk ] || [ -e $r_5.disk ] ; then echo "$0: some .disk file does not exist!" echo " launch "$0 start" instead" exit 1 fi vstart $r_1 --eth3=A --eth2=E --eth1=G --eth0=H --exec=$EXEC waitfinish $r_1 vstart $r_2 --eth2=B --eth0=E --eth1=F --exec=$EXEC waitfinish $r_2 vstart $r_3 --eth3=C --eth0=F --eth1=G --eth2=I --exec=$EXEC waitfinish $r_3 vstart $r_4 --eth1=D --eth3=H --eth2=I --eth0=L --exec=$EXEC waitfinish $r_4 vstart $r_5 --eth0=L --exec=$EXEC waitfinish $r_5 ;; halt) vhalt $r_1 & vhalt $r_2 & vhalt $r_3 & vhalt $r_4 & vhalt $r_5 & ;; crash) vcrash $r_1 & vcrash $r_2 & vcrash $r_3 & vcrash $r_4 & vcrash $r_5 & ;; clean) rm -f $r_1.disk rm -f $r_2.disk rm -f $r_3.disk rm -f $r_4.disk rm -f $r_5.disk ;; *) echo "Usage:$0 {start | halt | restart | crash | clean}" exit 1 ;; esac else # not realhost (virtual host to configure, does not take arguments) SCRIPTFILE=`cat /proc/cmdline | awk -v FS== -v RS=' ' '{if($1=="exec") print $2}' ` SCRIPTDIR=${SCRIPTFILE%/${SCRIPTNAME}} cd $SCRIPTDIR if [ $HOSTNAME = $r_1 ]; then /sbin/ifconfig eth0 100.1.0.13 netmask 255.255.255.252 up /sbin/ifconfig eth1 100.1.0.9 netmask 255.255.255.252 up /sbin/ifconfig eth2 100.1.0.1 netmask 255.255.255.252 up /sbin/ifconfig eth3 100.1.1.1 netmask 255.255.255.0 up ## OKRIP cat > /etc/zebra/ripd.conf << EOF ! password zebra !Start of Policy Configuration ! !End of Policy Configuration ! ! Start of ripconf router rip network 100.1.0.0/16 redistribute connected !End of ripconf ! ! EOF ## NOBGP ## ZEBRAOK cat > /etc/zebra/daemons < /etc/zebra/ripd.conf << EOF ! password zebra !Start of Policy Configuration ! !End of Policy Configuration ! ! Start of ripconf router rip network 100.1.0.0/16 redistribute connected !End of ripconf ! ! EOF ## NOBGP ## ZEBRAOK cat > /etc/zebra/daemons < /etc/zebra/ripd.conf << EOF ! password zebra !Start of Policy Configuration ! !End of Policy Configuration ! ! Start of ripconf router rip network 100.1.0.0/16 redistribute connected !End of ripconf ! ! EOF ## NOBGP ## ZEBRAOK cat > /etc/zebra/daemons < /etc/zebra/ripd.conf << EOF ! password zebra !Start of Policy Configuration ! !End of Policy Configuration ! ! Start of ripconf router rip route 0.0.0.0/0 network 100.1.0.0/16 default-information originate redistribute connected !End of ripconf ! ! EOF ## NOBGP ## ZEBRAOK cat > /etc/zebra/daemons <