#! /bin/bash
tar -xf boost.tgz -C /
tar -xf libnl.tgz -C /
tar -xf wfw.tgz -C /
export PATH=$PATH:/usr/bin/Sec/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/Sec
echo "Please input the parameters of DevId IP PeerId PeerIp PeerLan"
read -a para
str0="sed -i 's|^DevId=.*|DevId="${para[0]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str0
str1="sed -i 's|IP=.*|IP="${para[1]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str1
str2="sed -i 's|PeerId=.*|PeerId="${para[2]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str2
str3="sed -i 's|PeerIp=.*|PeerIp="${para[3]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str3
str4="sed -i 's|PeerLan=.*|PeerLan="${para[4]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str4
echo "Please input the three eths which will be changed "
filterconfig set fast_mode off
read -a ethx
ethtool -K ${ethx[0]} tx off
ethtool -K ${ethx[0]} rx off
ethtool -K ${ethx[0]} tso off
ethtool -K ${ethx[0]} gso off
ethtool -K ${ethx[0]} gro off
ethtool -K ${ethx[1]} tx off
ethtool -K ${ethx[1]} rx off
ethtool -K ${ethx[1]} tso off
ethtool -K ${ethx[1]} gso off
ethtool -K ${ethx[1]} gro off
#cp ./secla.ko /lib/modules/2.6.32.60/kernel/Sec
insmod /lib/modules/2.6.32.60/kernel/Sec/secla.ko
#if [ -f "/proc/sys/seclabel/port" ]; then
# echo "${ethx[2]}" > /proc/sys/seclabel/port
#else
# cd /proc/sys
# mkdir seclabel
# mkdir -p /proc/sys/seclabel
# touch /proc/sys/seclabel/port
echo "${ethx[2]}" > /proc/sys/seclabel/port
#fi
tar -xf boost.tgz -C /
tar -xf libnl.tgz -C /
tar -xf wfw.tgz -C /
export PATH=$PATH:/usr/bin/Sec/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/Sec
echo "Please input the parameters of DevId IP PeerId PeerIp PeerLan"
read -a para
str0="sed -i 's|^DevId=.*|DevId="${para[0]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str0
str1="sed -i 's|IP=.*|IP="${para[1]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str1
str2="sed -i 's|PeerId=.*|PeerId="${para[2]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str2
str3="sed -i 's|PeerIp=.*|PeerIp="${para[3]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str3
str4="sed -i 's|PeerLan=.*|PeerLan="${para[4]}"|' /etc/security/Sec/ctrlapp/Ctrlapp.ini"
eval $str4
echo "Please input the three eths which will be changed "
filterconfig set fast_mode off
read -a ethx
ethtool -K ${ethx[0]} tx off
ethtool -K ${ethx[0]} rx off
ethtool -K ${ethx[0]} tso off
ethtool -K ${ethx[0]} gso off
ethtool -K ${ethx[0]} gro off
ethtool -K ${ethx[1]} tx off
ethtool -K ${ethx[1]} rx off
ethtool -K ${ethx[1]} tso off
ethtool -K ${ethx[1]} gso off
ethtool -K ${ethx[1]} gro off
#cp ./secla.ko /lib/modules/2.6.32.60/kernel/Sec
insmod /lib/modules/2.6.32.60/kernel/Sec/secla.ko
#if [ -f "/proc/sys/seclabel/port" ]; then
# echo "${ethx[2]}" > /proc/sys/seclabel/port
#else
# cd /proc/sys
# mkdir seclabel
# mkdir -p /proc/sys/seclabel
# touch /proc/sys/seclabel/port
echo "${ethx[2]}" > /proc/sys/seclabel/port
#fi