blob: 6500ac7a5a79bb69a4b84eafa13f024a1e899660 [file] [log] [blame]
Shad Ansarid0eaf752018-08-16 00:26:12 +00001#!/bin/sh
2
3### BEGIN INIT INFO
Girish Gowdraab7ea552020-01-07 13:25:15 +05304# Provides: dev_mgmt_daemon
Shad Ansarid0eaf752018-08-16 00:26:12 +00005# Required-Start: $local_fs $network $syslog
6# Required-Stop: $network $local_fs $syslog
7# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: Broadcom BAL core daemon
10# Description: Broadcom BAL core daemon
11### END INIT INFO
12
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000013NAME="dev_mgmt_daemon"
Shad Ansarid0eaf752018-08-16 00:26:12 +000014PATH="/broadcom:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
15APPDIR="/broadcom"
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000016APPBIN="dev_mgmt_daemon"
Shad Ansarid0eaf752018-08-16 00:26:12 +000017USER="root"
18GROUP="root"
Jason Huangdc83ba72020-11-16 22:08:43 +080019PORT_SPEED_FILE="$APPDIR/port_speed.soc"
20TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config.ini"
21OLT_MODEL=`cat /sys/devices/virtual/dmi/id/board_name`
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053022PRODUCT_NAME=
23
Thiyagarajan Subramania2c2c5a2021-05-18 14:47:52 +053024# RLT-3200G-W - wait for onlp driver to load
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053025if [ "$OLT_MODEL" = "Default string" ]; then
26 RETRY_COUNT=0
27 while [ -z "$PRODUCT_NAME" ]
28 do
29 PRODUCT_NAME=$(onlpd -s | grep Part | awk '{print $3}')
30 echo "RETRY_COUNT=$RETRY_COUNT, product name=$PRODUCT_NAME"
31 sleep 1
32 RETRY_COUNT=$((RETRY_COUNT+1))
33 done
34 OLT_MODEL=$PRODUCT_NAME
35fi
36
Girish Gowdrafc10f0d2020-11-30 13:06:35 -080037if [ "$OLT_MODEL" = "ASXvOLT16" ]; then
Jason Huangdc83ba72020-11-16 22:08:43 +080038 Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
Girish Gowdrafc10f0d2020-11-30 13:06:35 -080039 [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
Jason Huangdc83ba72020-11-16 22:08:43 +080040 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
Girish Gowdrafc10f0d2020-11-30 13:06:35 -080041elif [ "$OLT_MODEL" = "ASGvOLT64" ]; then
Jason Huangdc83ba72020-11-16 22:08:43 +080042 Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
Girish Gowdrafc10f0d2020-11-30 13:06:35 -080043 [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
Jason Huangdc83ba72020-11-16 22:08:43 +080044 Port_25G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_25 " '{print $2}'`
45 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053046elif [ "$OLT_MODEL" = "RLT-3200G" ] || [ "$OLT_MODEL" = "RLT-3200X" ] || [ "$OLT_MODEL" = "RLT-1600G" ] || [ "$OLT_MODEL" = "RLT-1600X" ]; then
47 APPARGS="-pcie -d"
Jason Huangdc83ba72020-11-16 22:08:43 +080048else
49 Port_100G_SPEED="100000"
50 Port_25G_SPEED="25000"
51 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
52fi
Shad Ansarid0eaf752018-08-16 00:26:12 +000053
Girish Gowdra3a439762020-01-28 15:21:31 +053054# Include functions
Shad Ansarid0eaf752018-08-16 00:26:12 +000055set -e
56. /lib/lsb/init-functions
57
58start() {
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053059 if [ "$OLT_MODEL" = "ASGvOLT64" ] || [ "$OLT_MODEL" = "ASXvOLT16" ]; then
60 /opt/bcm68620/svk_init.sh
61 elif [ "$OLT_MODEL" = "RLT-3200G" ] || [ "$OLT_MODEL" = "RLT-3200X" ] || [ "$OLT_MODEL" = "RLT-1600G" ] || [ "$OLT_MODEL" = "RLT-1600X" ]; then
62 /opt/bcm68650/svk_init.sh
63 fi
64
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000065 sleep 10
Shad Ansarid0eaf752018-08-16 00:26:12 +000066 printf "Starting '$NAME'... "
Girish Gowdra3a439762020-01-28 15:21:31 +053067 touch /var/log/$NAME.log
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000068 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR
Jason Huang09b73ea2020-01-08 17:52:05 +080069 export USER=$USER
Girish Gowdraab7ea552020-01-07 13:25:15 +053070 start-stop-daemon --verbose --start --chuid "$USER:$GROUP" --background --no-close --chdir "$APPDIR" --exec "$APPBIN" -- $APPARGS < /dev/tty1 >> /var/log/$NAME.log 2>&1 || true
Jason Huang09b73ea2020-01-08 17:52:05 +080071 sleep 2 && [ -z `pidof $NAME 2>/dev/null` ] || pidof $NAME > /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000072 printf "done\n"
73}
74
75#We need this function to ensure the whole process tree will be killed
76killtree() {
77 local _pid=$1
78 local _sig=${2-TERM}
79 for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
80 killtree ${_child} ${_sig}
81 done
82 kill -${_sig} ${_pid}
83}
84
85stop() {
86 printf "Stopping '$NAME'... "
Jason Huang09b73ea2020-01-08 17:52:05 +080087 [ -z "`pidof $NAME`" ] ||
88 for p in "`pidof $NAME`";do
89 killtree $p 15
90 sleep 0.5
91 done
92 rm -f /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000093 printf "done\n"
94}
95
96status() {
Jason Huang09b73ea2020-01-08 17:52:05 +080097 status_of_proc -p /var/run/$NAME.pid $APPDIR/$APPBIN $NAME && exit 0 || exit $?
Shad Ansarid0eaf752018-08-16 00:26:12 +000098}
99
100case "$1" in
101 start)
102 start
103 ;;
104 stop)
105 stop
106 ;;
107 restart)
108 stop
109 start
110 ;;
111 status)
112 status
113 ;;
114 *)
115 echo "Usage: $NAME {start|stop|restart|status}" >&2
116 exit 1
117 ;;
118esac
119
120exit 0