blob: 2fc2b8675713dfac53a0f89529fb95374dcfcf6c [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
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053037 APPARGS="-pcie -d"
Shad Ansarid0eaf752018-08-16 00:26:12 +000038
Girish Gowdra3a439762020-01-28 15:21:31 +053039# Include functions
Shad Ansarid0eaf752018-08-16 00:26:12 +000040set -e
41. /lib/lsb/init-functions
42
43start() {
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053044 if [ "$OLT_MODEL" = "ASGvOLT64" ] || [ "$OLT_MODEL" = "ASXvOLT16" ]; then
45 /opt/bcm68620/svk_init.sh
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053046 elif [ "$OLT_MODEL" = "RLT-3200G" ] || [ "$OLT_MODEL" = "RLT-1600G" ] || [ "$OLT_MODEL" = "RLT-1600X" ]; then
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053047 /opt/bcm68650/svk_init.sh
48 fi
49
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000050 sleep 10
Shad Ansarid0eaf752018-08-16 00:26:12 +000051 printf "Starting '$NAME'... "
Girish Gowdra3a439762020-01-28 15:21:31 +053052 touch /var/log/$NAME.log
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000053 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR
Jason Huang09b73ea2020-01-08 17:52:05 +080054 export USER=$USER
Girish Gowdraab7ea552020-01-07 13:25:15 +053055 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 +080056 sleep 2 && [ -z `pidof $NAME 2>/dev/null` ] || pidof $NAME > /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000057 printf "done\n"
58}
59
60#We need this function to ensure the whole process tree will be killed
61killtree() {
62 local _pid=$1
63 local _sig=${2-TERM}
64 for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
65 killtree ${_child} ${_sig}
66 done
67 kill -${_sig} ${_pid}
68}
69
70stop() {
71 printf "Stopping '$NAME'... "
Jason Huang09b73ea2020-01-08 17:52:05 +080072 [ -z "`pidof $NAME`" ] ||
73 for p in "`pidof $NAME`";do
74 killtree $p 15
75 sleep 0.5
76 done
77 rm -f /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000078 printf "done\n"
79}
80
81status() {
Jason Huang09b73ea2020-01-08 17:52:05 +080082 status_of_proc -p /var/run/$NAME.pid $APPDIR/$APPBIN $NAME && exit 0 || exit $?
Shad Ansarid0eaf752018-08-16 00:26:12 +000083}
84
85case "$1" in
86 start)
87 start
88 ;;
89 stop)
90 stop
91 ;;
92 restart)
93 stop
94 start
95 ;;
96 status)
97 status
98 ;;
99 *)
100 echo "Usage: $NAME {start|stop|restart|status}" >&2
101 exit 1
102 ;;
103esac
104
105exit 0