start_hp4.sh 1.09 KB
Newer Older
1 2 3
#!/bin/bash

cd /opt
4
script_path=/opt/hp4-ctrl/vibrant-eval/remote-scripts
5 6 7 8 9 10

# get and configure interfaces
hname="$(hostname | tr "." " " | awk '{print $1}')"

if [ "$hname" == "node-0" ]
then
11
  sudo $script_path/s0_get_ifaces.sh
12 13
elif [ "$hname" == "node-1" ]
then
14
  sudo $script_path/s1_get_ifaces.sh
15 16
elif [ "$hname" == "node-2" ]
then
17
  sudo $script_path/s2_get_ifaces.sh
18 19
elif [ "$hname" == "node-3" ]
then
20
  sudo $script_path/s3_get_ifaces.sh
21 22
elif [ "$hname" == "node-4" ]
then
23
  sudo $script_path/s4_get_ifaces.sh
24 25 26
fi

# start simple switch with hp4
27
ifacescommand=( sudo $script_path/iface_setup.sh )
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
hp4command=( sudo nohup /opt/bmv2/targets/simple_switch/simple_switch )

ifaces=(iface0 iface1 iface2 iface3 iface4)

for i in `seq 0 4`; do
  if [ -s ${ifaces[$i]} ]
  then
    ifacescommand+=( "$(cat ${ifaces[$i]})" )
    hp4command+=( -i "$i@$(cat ${ifaces[$i]})" )
  fi
done

echo "${ifacescommand[@]}"
"${ifacescommand[@]}"

hp4command+=( /opt/hp4-src/hp4/hp4.json )

echo "${hp4command[@]}"
"${hp4command[@]}" 2> /dev/null &
sleep 5
David Hancock's avatar
David Hancock committed
48
sudo sh -c "nohup ${script_path}/prep_hp4.sh > prep_hp4.out 2> /dev/null &"