GENIExperimenter/Tutorials/SystematicExprCaseStudy/SmallTopoQuagga/DesignSetup: start-xorp.sh

File start-xorp.sh, 2.4 KB (added by xliu@bbn.com, 10 years ago)
Line 
1#!/usr/bin
2# =====================================================================
3#
4# This script is to generate ospf configuration for the VMs
5# that has XORP installed, and start xorp process.
6#
7# The script first to get the network configuration information,
8# such as virtual interfaces (neither eth0 nor lo), hostname, etc.
9#
10# Secondly, the script will start xorp process in the VM
11#
12#
13# Code by Xuan Liu
14# xliu@bbn.com
15#
16# June 9, 2014
17# =====================================================================
18
19
20cd /local/xorp_autostart/
21
22ABS_PATH=/local/xorp_autostart
23
24vm_info_file=$ABS_PATH/vm_info.txt
25host=echo `hostname`
26echo $host
27
28# get hostname
29hostname | sudo tee $vm_info_file > /dev/null
30# get interface information
31/sbin/ifconfig | egrep 'eth|inet addr' | sudo tee -a $vm_info_file > /dev/null
32# get timestamp
33timestamp=$(date +"%Y-%m-%d %r")
34echo $timestamp
35
36
37xorp_conf_dir=/etc/xorp
38
39if [ -d $xorp_conf_dir ]
40then
41   echo "XORP dir exist"
42else
43   echo "creating xorp dir"
44   sudo mkdir $xorp_conf_dir
45fi
46
47sudo /usr/bin/awk -f $ABS_PATH/ospfd-conf-gen.awk $vm_info_file "$timestamp" 24 | sudo tee $ABS_PATH/ospfd.conf > /dev/null
48
49sudo cp $ABS_PATH/ospfd.conf $xorp_conf_dir/.
50
51# check if xorp has been added to the group
52xorp_group=`sudo cat /etc/group | grep "xorp"`
53if [ "$xorp_group" = "" ]
54then
55   echo "Add xorp to group"
56   sudo groupadd xorp
57else
58   echo "xorp is already added to the group"
59fi
60
61
62
63# first stop current xorp process if it's running
64
65xorp_pids=`ps -ef | grep xorp_ | /usr/bin/awk '{ if ( $1 == "root" ) {print $2}}'`
66if [ "$xorp_pids" = "" ]
67then
68   echo "xorp is not running at this time"
69else
70   echo "xorp is running, stop it first"
71   ps -ef | grep xorp_ | /usr/bin/awk '{ if ( $1 == "root" ) {print "sudo kill -9 " $2}}' | sh
72fi
73
74
75# start xorp
76cd /usr/local/xorp/sbin/
77echo "XORP is starting ......"
78sudo ./xorp_rtrmgr -b $xorp_conf_dir/ospfd.conf -l /tmp/xorp_rtrmgr_log -d
79
80
81/sbin/ifconfig -a | grep eth | awk '{ if (substr($1, 4,4) != 0) { print "sudo /sbin/ifconfig " $1 " down"}}' |sh
82/sbin/ifconfig -a | grep eth | awk '{ if (substr($1, 4,4) != 0) { print "sudo /sbin/ifconfig " $1 " up"}}' |sh
83
84# Turn off the reverse path filter on ubuntu
85sudo sysctl -w net.ipv4.conf.all.rp_filter=0
86sudo sysctl -w net.ipv4.conf.default.rp_filter=0
87/sbin/ifconfig -a | grep eth | awk '{ if (substr($1, 4,4) != 0) { print "sudo sysctl -w net.ipv4.conf." $1 ".rp_filter=0"}}' | sh
88
89