0

好吧,我试图使标题具有描述性,但是如果您错过了它,我想知道 <<<<<<< HEADbash 脚本中的含义。

尝试运行有问题的脚本会出现错误:

./rftest2: line 8: syntax error near unexpected token `<<<'
./rftest2: line 8: `<<<<<<< HEAD'

如果需要更多信息,这是整个脚本(来自https://github.com/fabianomathilde/RouteFlow/blob/master/rftest/rftest2

#!/bin/bash

if [ "$EUID" != "0" ]; then
  echo "You must be root to run this script."
  exit 1
fi

<<<<<<< HEAD
ACTION=""
case "$1" in
--pox)
    ACTION="POX"
    ;;
--nox)
    ACTION="NOX"
    ;;
--floodlight)
    ACTION="FLOODLIGHT"
    ;;
--reset)
    ACTION="RESET"
    ;;
*)
    echo "Invalid argument: $1"
    echo "Options: "
    echo "    --pox: run using POX"
    echo "    --nox: run using NOX"
    echo "    --floodlight: run using Floodlight"
    echo "    --reset: stop running and clear data from previous executions"
    exit
    ;;
esac

=======
SCRIPT_NAME="rftest2"
>>>>>>> upstream/master
LXCDIR=/var/lib/lxc
MONGODB_CONF=/etc/mongodb.conf
MONGODB_PORT=27017
CONTROLLER_PORT=6633
RF_HOME=..
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
export PYTHONPATH=$PYTHONPATH:$RF_HOME

cd $RF_HOME

wait_port_listen() {
    port=$1
    while ! `nc -z localhost $port` ; do
        echo -n .
        sleep 1
    done
}

echo_bold() {
    echo -e "\033[1m${1}\033[0m"
}

kill_process_tree() {
    top=$1
    pid=$2

    children=`ps -o pid --no-headers --ppid ${pid}`

    for child in $children
    do
        kill_process_tree 0 $child
    done

    if [ $top -eq 0 ]; then
        kill -9 $pid &> /dev/null
    fi
}

reset() {
    init=$1;
    if [ $init -eq 1 ]; then
        echo_bold "-> Starting $SCRIPT_NAME";
    else
        echo_bold "-> Stopping child processes...";
        kill_process_tree 1 $$
    fi

    ovs-vsctl del-br dp0 &> /dev/null;
    ovs-vsctl emer-reset &> /dev/null;

    echo_bold "-> Stopping and resetting LXC VMs...";
    lxc-shutdown -n rfvmA;
    lxc-shutdown -n rfvmB;
    lxc-shutdown -n rfvmC;
    lxc-shutdown -n rfvmD;

    echo_bold "-> Deleting (previous) run data...";
    mongo db --eval "
        db.getCollection('rftable').drop(); 
        db.getCollection('rfconfig').drop(); 
        db.getCollection('rfstats').drop(); 
        db.getCollection('rfclient<->rfserver').drop(); 
        db.getCollection('rfserver<->rfproxy').drop();
    "

    rm -rf /var/lib/lxc/rfvmA/rootfs/opt/rfclient;
    rm -rf /var/lib/lxc/rfvmB/rootfs/opt/rfclient;
    rm -rf /var/lib/lxc/rfvmC/rootfs/opt/rfclient;
    rm -rf /var/lib/lxc/rfvmD/rootfs/opt/rfclient;
}
reset 1
trap "reset 0; exit 0" INT

<<<<<<< HEAD
if [ "$ACTION" != "RESET" ]; then
    echo_bold "-> Starting MongoDB..."
    mkdir $HOME/db
    mongod --quiet --dbpath $HOME/db --logpath /dev/null &
    wait_port_listen $MONGODB_PORT

    echo_bold "-> Starting the virtual machines..."
    # Create the rfclient dir
    mkdir /var/lib/lxc/rfvmA/rootfs/opt/rfclient
    mkdir /var/lib/lxc/rfvmB/rootfs/opt/rfclient
    mkdir /var/lib/lxc/rfvmC/rootfs/opt/rfclient
    mkdir /var/lib/lxc/rfvmD/rootfs/opt/rfclient

    # Copy the rfclient executable
    cp build/rfclient /var/lib/lxc/rfvmA/rootfs/opt/rfclient/rfclient
    cp build/rfclient /var/lib/lxc/rfvmB/rootfs/opt/rfclient/rfclient
    cp build/rfclient /var/lib/lxc/rfvmC/rootfs/opt/rfclient/rfclient
    cp build/rfclient /var/lib/lxc/rfvmD/rootfs/opt/rfclient/rfclient

    cp /usr/lib/libmongoclient.a /var/lib/lxc/rfvmA/rootfs/usr/lib
    cp /usr/lib/libmongoclient.so /var/lib/lxc/rfvmA/rootfs/usr/lib
    cp /usr/lib/libmongoclient.a /var/lib/lxc/rfvmB/rootfs/usr/lib
    cp /usr/lib/libmongoclient.so /var/lib/lxc/rfvmB/rootfs/usr/lib
    cp /usr/lib/libmongoclient.a /var/lib/lxc/rfvmC/rootfs/usr/lib
    cp /usr/lib/libmongoclient.so /var/lib/lxc/rfvmC/rootfs/usr/lib
    cp /usr/lib/libmongoclient.a /var/lib/lxc/rfvmD/rootfs/usr/lib
    cp /usr/lib/libmongoclient.so /var/lib/lxc/rfvmD/rootfs/usr/lib

    # We need to start the VMs with different sleep times to guarantee their order.
    # This is a known Routeflow limitation, and we plan to eliminate it in the future.
    echo "#!/bin/sh" > /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
    echo "sleep 10" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
    echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
    echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh

    echo "#!/bin/sh" > /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
    echo "sleep 15" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
    echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
    echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh

    echo "#!/bin/sh" > /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
    echo "sleep 20" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
    echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
    echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh

    echo "#!/bin/sh" > /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
    echo "sleep 25" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
    echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
    echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh

    chmod +x /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
    chmod +x /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
    chmod +x /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
    chmod +x /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh

    lxc-start -n rfvmA -d
    lxc-start -n rfvmB -d
    lxc-start -n rfvmC -d
    lxc-start -n rfvmD -d

    echo_bold "-> Starting the management network (br0)..."
    ovs-vsctl add-br br0
    ovs-vsctl add-port br0 rfvmA.0 
    ovs-vsctl add-port br0 rfvmB.0 
    ovs-vsctl add-port br0 rfvmC.0 
    ovs-vsctl add-port br0 rfvmD.0
    ifconfig br0 up
    ifconfig br0 192.169.1.1

    echo_bold "-> Starting the controller ($ACTION) and RFPRoxy..."
    case "$ACTION" in
    POX)
        cd pox
        ./pox.py --no-cli log.level --=INFO topology openflow.topology openflow.discovery rfproxy rfstats &
        cd - &> /dev/null
        ;;
    NOX)
        cd nox/build/src
        ./nox_core -i ptcp:$CONTROLLER_PORT rfproxy --verbose="rfproxy:ANY:INFO" &
        cd - &> /dev/null
        ;;
    FLOODLIGHT)
        cd floodlight
        ant run_floodlight &
        cd - &> /dev/null
        ;;
    esac
    wait_port_listen $CONTROLLER_PORT

    echo_bold "-> Starting RFServer..."
    ./rfserver/rfserver.py rftest/rftest2config.csv &

    echo_bold "-> Starting the control plane network (dp0 VS)..."
    ovs-vsctl add-br dp0
    ovs-vsctl add-port dp0 rfvmA.1
    ovs-vsctl add-port dp0 rfvmA.2
    ovs-vsctl add-port dp0 rfvmA.3
    ovs-vsctl add-port dp0 rfvmA.4
    ovs-vsctl add-port dp0 rfvmB.1
    ovs-vsctl add-port dp0 rfvmB.2
    ovs-vsctl add-port dp0 rfvmB.3
    ovs-vsctl add-port dp0 rfvmC.1
    ovs-vsctl add-port dp0 rfvmC.2
    ovs-vsctl add-port dp0 rfvmC.3
    ovs-vsctl add-port dp0 rfvmD.1
    ovs-vsctl add-port dp0 rfvmD.2
    ovs-vsctl add-port dp0 rfvmD.3
    ovs-vsctl add-port dp0 rfvmD.4
    ovs-vsctl set Bridge dp0 other-config:datapath-id=7266767372667673
    ovs-vsctl set-controller dp0 tcp:127.0.0.1:$CONTROLLER_PORT
    ifconfig dp0 up

    echo_bold "---"
    echo_bold "This test is up and running."
    echo_bold "Start Mininet:"
    echo_bold "  $ sudo mn --custom ~/mininet/custom/topo-4sw-4host.py --topo=rftopo"
    echo_bold "    --controller=remote --ip=10.0.2.2 --port=$CONTROLLER_PORT"
    echo_bold "Replace ADDRESS with the address of this host's interface connected "
    echo_bold "to the Mininet VM."
    echo_bold "Then try pinging everything:"
    echo_bold "  > pingall"
    echo_bold "You can stop this test by pressing CTRL+C."
    echo_bold "---"
    wait
fi
=======
echo_bold "-> Setting up the management bridge (lxcbr0)..."
ifconfig lxcbr0 192.169.1.1 up

echo_bold "-> Setting up MongoDB..."
sed -i "/bind_ip/c\bind_ip = 127.0.0.1,192.169.1.1" $MONGODB_CONF
service mongodb restart
wait_port_listen $MONGODB_PORT

echo_bold "-> Configuring the virtual machines..."
# Create the rfclient dir
mkdir /var/lib/lxc/rfvmA/rootfs/opt/rfclient
mkdir /var/lib/lxc/rfvmB/rootfs/opt/rfclient
mkdir /var/lib/lxc/rfvmC/rootfs/opt/rfclient
mkdir /var/lib/lxc/rfvmD/rootfs/opt/rfclient

# Copy the rfclient executable
cp build/rfclient /var/lib/lxc/rfvmA/rootfs/opt/rfclient/rfclient
cp build/rfclient /var/lib/lxc/rfvmB/rootfs/opt/rfclient/rfclient
cp build/rfclient /var/lib/lxc/rfvmC/rootfs/opt/rfclient/rfclient
cp build/rfclient /var/lib/lxc/rfvmD/rootfs/opt/rfclient/rfclient

# We sleep for a few seconds to wait for the interfaces to go up
echo "#!/bin/sh" > /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
echo "sleep 3" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh

echo "#!/bin/sh" > /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
echo "sleep 3" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh

echo "#!/bin/sh" > /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
echo "sleep 3" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh

echo "#!/bin/sh" > /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
echo "sleep 3" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
echo "/etc/init.d/quagga start" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh
echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh

chmod +x /var/lib/lxc/rfvmA/rootfs/root/run_rfclient.sh
chmod +x /var/lib/lxc/rfvmB/rootfs/root/run_rfclient.sh
chmod +x /var/lib/lxc/rfvmC/rootfs/root/run_rfclient.sh
chmod +x /var/lib/lxc/rfvmD/rootfs/root/run_rfclient.sh

echo_bold "-> Starting the virtual machines..."
lxc-start -n rfvmA -d
lxc-start -n rfvmB -d
lxc-start -n rfvmC -d
lxc-start -n rfvmD -d

echo_bold "-> Starting the controller and RFPRoxy..."
cd pox
./pox.py --no-cli log.level --=INFO topology openflow.topology openflow.discovery rfproxy rfstats &
cd -
wait_port_listen $CONTROLLER_PORT

echo_bold "-> Starting RFServer..."
./rfserver/rfserver.py rftest/rftest2config.csv &

echo_bold "-> Starting the control plane network (dp0 VS)..."
ovs-vsctl add-br dp0
ovs-vsctl add-port dp0 rfvmA.1
ovs-vsctl add-port dp0 rfvmA.2
ovs-vsctl add-port dp0 rfvmA.3
ovs-vsctl add-port dp0 rfvmA.4
ovs-vsctl add-port dp0 rfvmB.1
ovs-vsctl add-port dp0 rfvmB.2
ovs-vsctl add-port dp0 rfvmB.3
ovs-vsctl add-port dp0 rfvmC.1
ovs-vsctl add-port dp0 rfvmC.2
ovs-vsctl add-port dp0 rfvmC.3
ovs-vsctl add-port dp0 rfvmD.1
ovs-vsctl add-port dp0 rfvmD.2
ovs-vsctl add-port dp0 rfvmD.3
ovs-vsctl add-port dp0 rfvmD.4
ovs-vsctl set Bridge dp0 other-config:datapath-id=7266767372667673
ovs-vsctl set-controller dp0 tcp:127.0.0.1:$CONTROLLER_PORT

echo_bold "---"
echo_bold "This test is up and running."
echo_bold "Start Mininet:"
echo_bold "  $ mn --custom ~/mininet/custom/topo-4sw-4host.py --topo=rftopo"
echo_bold "    --controller=remote --ip=ADDRESS --port=$CONTROLLER_PORT"
echo_bold "Replace ADDRESS with the address of this host's interface connected "
echo_bold "to the Mininet VM."
echo_bold "Then try pinging everything:"
echo_bold "  > pingall"
echo_bold "You can stop this test by pressing CTRL+C."
echo_bold "---"
wait

>>>>>>> upstream/master
exit 0
4

1 回答 1

9

该文件已从版本控制系统(可能是 Git)中签出,并且本地更改和服务器上的更改之间存在冲突,因为两者是同步的。“<<<< HEAD”行和“======”之间的部分来自源代码管理中的“官方”文件,从那里到另一个标记的部分带有“>>>>”是本地版本。

因此,这些部分代表了脚本应该做什么的替代愿景,您确实需要进行更改的开发人员来编辑文件并解决冲突(并可能重新检查他的更改。)

于 2013-06-10T14:18:42.250 回答