#!/bin/bash

# Set hccl ip
cat /etc/rc.d/rc.local|grep "hccn_tool"
if [ $? -ne 0 ]; then
    echo "" >> /etc/rc.d/rc.local
    echo "# HCCL IP" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 0 -ip -s address 192.168.100.101 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 1 -ip -s address 192.168.101.101 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 2 -ip -s address 192.168.102.101 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 3 -ip -s address 192.168.103.101 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 4 -ip -s address 192.168.100.102 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 5 -ip -s address 192.168.101.102 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 6 -ip -s address 192.168.102.102 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    echo "hccn_tool -i 7 -ip -s address 192.168.103.102 netmask 255.255.255.0" >> /etc/rc.d/rc.local
    
    echo "" >> /etc/rc.d/rc.local
    echo "# Close device log" >> /etc/rc.d/rc.local
    echo 'su HwHiAiUser -c "/usr/local/Ascend/toolkit/bin/adc --host 127.0.0.1:22118 --log \"SetLogLevel(0)[error]\""' >> /etc/rc.d/rc.local
    echo 'su HwHiAiUser -c "/usr/local/Ascend/toolkit/bin/adc --host 127.0.0.1:22118 --log \"SetLogLevel(0)[error]\" --device 4"' >> /etc/rc.d/rc.local
fi
cat /etc/rc.d/rc.local
