#!/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_3=r_3-r3 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_3.disk ] ; then echo "$0: some .disk file exists in this directory!" echo " launch "$0 clean" first" exit 1 fi vstart $r_1 --eth0=A --eth1=G --new --exec=$EXEC waitfinish $r_1 vstart $r_3 --eth0=C --eth1=G --new --exec=$EXEC waitfinish $r_3 ;; restart) ############## CREATE THE HOSTS FROM SCRATCH if [ -e $r_1.disk ] || [ -e $r_3.disk ] ; then echo "$0: some .disk file does not exist!" echo " launch "$0 start" instead" exit 1 fi vstart $r_1 --eth0=A --eth1=G --exec=$EXEC waitfinish $r_1 vstart $r_3 --eth0=C --eth1=G --exec=$EXEC waitfinish $r_3 ;; halt) vhalt $r_1 & vhalt $r_3 & ;; crash) vcrash $r_1 & vcrash $r_3 & ;; clean) rm -f $r_1.disk rm -f $r_3.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.1.1 netmask 255.255.255.0 up /sbin/ifconfig eth1 100.1.0.9 netmask 255.255.255.252 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.8/30 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 eth1 redistribute connected !End of ripconf ! ! EOF ## NOBGP ## ZEBRAOK cat > /etc/zebra/daemons <