#==============================================================
#
#  Abs:  Startup Script for Average Current Monitor (ACM) using
#        standard Ethernet port mapping
#
#  Name: st.cmd
#
#  Desc: The processor is an Advantech 1U server,
#        SKY-8100 S industrial pc/server.
#
#  Facility:  EED Beam Containment
#
#  Auth: 01-Apr-2024, Garth Brown (GWBROWN)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        
#
#=============================================================

# Turn on local IPMI Client support
echo "Load IPMI..."
sleep 2
modprobe ipmi_devintf
ipmitool lan print

# ========================================
# Network configuration
# ========================================
# Enable Ethernet SFP+ Top For Advantech 1U
ip addr add 192.168.14.1/24 dev eth5
ip addr add 192.168.12.1/24 dev eth6
ip addr add 192.168.11.1/24 dev eth7
ip addr add 192.168.13.1/24 dev eth8
ip addr add 192.168.10.1/24 dev eth9
ip addr add 192.168.1.1/24 dev eth10

ip link set eth5 up
ip link set eth6 up
ip link set eth7 up
ip link set eth8 up
ip link set eth9 up
ip link set eth10 up

# ==================================================================
# escalating RT priority for network kernel threads (SCHED_FIFO, 84)
# =================================================================
for PID in  $(ps -elF | grep eth[5-9] | grep -v grep | awk '{print $4}'); do chrt -f -p 84 $PID ; done
for PID in  $(ps -elF | grep eth10 | grep -v grep | awk '{print $4}'); do chrt -f -p 84 $PID ; done

# ======================================
# increasing receive buffer size to 10MB
# ======================================
sysctl -w net.core.rmem_default=10485760

# wait a bit to device become visible
sleep 2

# End of script'


