blob: 5eba28c7c3ea69cfdad4d8040cbdf5ad92eddd4e [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"
Girish Gowdraab7ea552020-01-07 13:25:15 +053017APPARGS="-pcie -d"
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000018PID_FILE="root_dev_mgmt_pid"
Shad Ansarid0eaf752018-08-16 00:26:12 +000019USER="root"
20GROUP="root"
21
22# Include functions
23set -e
24. /lib/lsb/init-functions
25
26start() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000027 /opt/bcm68620/svk_init.sh
28 sleep 10
Shad Ansarid0eaf752018-08-16 00:26:12 +000029 printf "Starting '$NAME'... "
Girish Gowdraab7ea552020-01-07 13:25:15 +053030 touch /var/log/$NAME.log
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000031 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR
Girish Gowdraab7ea552020-01-07 13:25:15 +053032 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
Shad Ansarid0eaf752018-08-16 00:26:12 +000033 printf "done\n"
34}
35
36#We need this function to ensure the whole process tree will be killed
37killtree() {
38 local _pid=$1
39 local _sig=${2-TERM}
40 for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
41 killtree ${_child} ${_sig}
42 done
43 kill -${_sig} ${_pid}
44}
45
46stop() {
47 printf "Stopping '$NAME'... "
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000048 [ -z `cat /tmp/$PID_FILE 2>/dev/null` ] || \
49 while test -d /proc/$(cat /tmp/$PID_FILE); do
50 killtree $(cat /tmp/$PID_FILE) 15
Shad Ansarid0eaf752018-08-16 00:26:12 +000051 sleep 0.5
52 done
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000053 [ -z `cat /tmp/$PID_FILE 2>/dev/null` ] || rm /tmp/$PID_FILE
Shad Ansarid0eaf752018-08-16 00:26:12 +000054 printf "done\n"
55}
56
57status() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000058 status_of_proc -p /tmp/$PID_FILE $APPDIR/$APPBIN $NAME && exit 0 || exit $?
Shad Ansarid0eaf752018-08-16 00:26:12 +000059}
60
61case "$1" in
62 start)
63 start
64 ;;
65 stop)
66 stop
67 ;;
68 restart)
69 stop
70 start
71 ;;
72 status)
73 status
74 ;;
75 *)
76 echo "Usage: $NAME {start|stop|restart|status}" >&2
77 exit 1
78 ;;
79esac
80
81exit 0