2020-08-06 05:16:11 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# This script load/unload centec kernel modules
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: platform-modules-e530-24x2c
|
|
|
|
# Required-Start:
|
|
|
|
# Required-Stop:
|
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
|
|
|
# Default-Start: S
|
|
|
|
# Default-Stop: 0 6
|
|
|
|
# Short-Description: Load Centec kernel modules
|
|
|
|
### END INIT INFO
|
|
|
|
|
2021-05-01 12:37:07 -05:00
|
|
|
function install_python_api_package()
|
|
|
|
{
|
|
|
|
device="/usr/share/sonic/device"
|
|
|
|
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
|
|
|
|
|
|
|
|
rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
|
|
|
|
fi
|
|
|
|
}
|
2020-08-06 05:16:11 -05:00
|
|
|
|
|
|
|
function load_kernel_modules()
|
|
|
|
{
|
2021-05-01 12:37:07 -05:00
|
|
|
hwaddr=`fw_printenv ethaddr | awk -F = '{print $2}'`
|
|
|
|
if [ "$hwaddr" != "" ]; then
|
|
|
|
ifconfig eth0 hw ether $hwaddr
|
|
|
|
fi
|
2020-08-06 05:16:11 -05:00
|
|
|
depmod -a
|
2021-10-25 17:36:55 -05:00
|
|
|
modprobe ctc-i2c-mux-pca954x
|
2020-08-06 05:16:11 -05:00
|
|
|
modprobe centec_e530_24x2c_platform
|
2021-05-01 12:37:07 -05:00
|
|
|
modprobe fan-ctc5236
|
2020-08-06 05:16:11 -05:00
|
|
|
modprobe dal
|
|
|
|
modprobe tun
|
|
|
|
modprobe tap
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_kernel_modules()
|
|
|
|
{
|
|
|
|
modprobe -r tap
|
|
|
|
modprobe -r tun
|
|
|
|
modprobe -r dal
|
2021-05-01 12:37:07 -05:00
|
|
|
modprobe -r fan-ctc5236
|
2020-08-06 05:16:11 -05:00
|
|
|
modprobe -r centec_e530_24x2c_platform
|
2021-10-25 17:36:55 -05:00
|
|
|
modprobe -r ctc-i2c-mux-pca954x
|
2020-08-06 05:16:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "Load Centec kernel modules... "
|
|
|
|
|
|
|
|
load_kernel_modules
|
2021-05-01 12:37:07 -05:00
|
|
|
install_python_api_package
|
2020-08-06 05:16:11 -05:00
|
|
|
|
|
|
|
echo "done."
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
echo -n "Unload Centec kernel modules... "
|
|
|
|
|
|
|
|
remove_kernel_modules
|
|
|
|
|
|
|
|
echo "done."
|
|
|
|
;;
|
|
|
|
|
|
|
|
force-reload|restart)
|
|
|
|
echo "Not supported"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Usage: /etc/init.d/platform-modules-e530-24x2c {start|stop}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|