#!/bin/bash

RCLOCAL_PATH="/etc/rc.d/rc.local"

_install() {
    # symble link
    if [[ ! -L /etc/rc.local ]]; then
        rm -f /etc/rc.local
        ln -s rc.d/rc.local /etc/rc.local
    fi

    # mkdir /etc/rc.local.d
    if [[ ! -d /etc/rc.local.d ]];then
        rm -rf /etc/rc.local.d
        mkdir -p /etc/rc.local.d/
    fi

    cp -f $BASEDIR/configs/rclocal/commonlib.sh /etc/rc.local.d/
    chmod a+x /etc/rc.local.d/*

    if [[ ! -e $BASEDIR/configs/rclocal/rc.local.default ]]; then
        PRINT_ERR "[ERROR] File $rc_local_file Not Found."
        return 1
    else
        cp -f $BASEDIR/configs/rclocal/rc.local.default $RCLOCAL_PATH
        chmod +x /etc/rc.d/rc.local
    fi

    if [[ $BFFLAG = 1 ]];then
        cat > /etc/rc.local.d/003-bf.sh << EOF
echo 1 > /sys/module/bonding/parameters/arp_broadcast_mode
echo 300 > /proc/sys/net/ovs/ovs_upcall_limit_rate
EOF
        cat >>/etc/rc.d/rc.local << EOF
/sbin/ethtool -L net2 combined 4
/sbin/ethtool -L net3 combined 4
EOF
    fi
}

_check() {
    _check="PASS"

    if [[ ! -L /etc/rc.local ]]; then
        _check="FAIL"
        PRINT_ERR "[ERROR] /etc/rc.local Not Symble Link."
    fi

    if [[ ! -d /etc/rc.local.d ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] /etc/rc.local.d Not Found."
    fi

}
