blob: 109e34f276a7af12de94c023741adce4172f8c12 [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`
22if [ $OLT_MODEL = "ASXvOLT16" ]; then
23 Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
24 [ $Port_100G_SPEED = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
25 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
26elif [ $OLT_MODEL = "ASGvOLT64" ]; then
27 Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
28 [ $Port_100G_SPEED = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
29 Port_25G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_25 " '{print $2}'`
30 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
31else
32 Port_100G_SPEED="100000"
33 Port_25G_SPEED="25000"
34 APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
35fi
Shad Ansarid0eaf752018-08-16 00:26:12 +000036
Girish Gowdra3a439762020-01-28 15:21:31 +053037# Include functions
Shad Ansarid0eaf752018-08-16 00:26:12 +000038set -e
39. /lib/lsb/init-functions
40
41start() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000042 /opt/bcm68620/svk_init.sh
43 sleep 10
Shad Ansarid0eaf752018-08-16 00:26:12 +000044 printf "Starting '$NAME'... "
Girish Gowdra3a439762020-01-28 15:21:31 +053045 touch /var/log/$NAME.log
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR
Jason Huang09b73ea2020-01-08 17:52:05 +080047 export USER=$USER
Girish Gowdraab7ea552020-01-07 13:25:15 +053048 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 +080049 sleep 2 && [ -z `pidof $NAME 2>/dev/null` ] || pidof $NAME > /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000050 printf "done\n"
51}
52
53#We need this function to ensure the whole process tree will be killed
54killtree() {
55 local _pid=$1
56 local _sig=${2-TERM}
57 for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
58 killtree ${_child} ${_sig}
59 done
60 kill -${_sig} ${_pid}
61}
62
63stop() {
64 printf "Stopping '$NAME'... "
Jason Huang09b73ea2020-01-08 17:52:05 +080065 [ -z "`pidof $NAME`" ] ||
66 for p in "`pidof $NAME`";do
67 killtree $p 15
68 sleep 0.5
69 done
70 rm -f /var/run/$NAME.pid
Shad Ansarid0eaf752018-08-16 00:26:12 +000071 printf "done\n"
72}
73
74status() {
Jason Huang09b73ea2020-01-08 17:52:05 +080075 status_of_proc -p /var/run/$NAME.pid $APPDIR/$APPBIN $NAME && exit 0 || exit $?
Shad Ansarid0eaf752018-08-16 00:26:12 +000076}
77
78case "$1" in
79 start)
80 start
81 ;;
82 stop)
83 stop
84 ;;
85 restart)
86 stop
87 start
88 ;;
89 status)
90 status
91 ;;
92 *)
93 echo "Usage: $NAME {start|stop|restart|status}" >&2
94 exit 1
95 ;;
96esac
97
98exit 0