Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | ### BEGIN INIT INFO |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 4 | # Provides: dev_mgmt_daemon |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 5 | # 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 Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 13 | NAME="dev_mgmt_daemon" |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 14 | PATH="/broadcom:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" |
| 15 | APPDIR="/broadcom" |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 16 | APPBIN="dev_mgmt_daemon" |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 17 | USER="root" |
| 18 | GROUP="root" |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 19 | PORT_SPEED_FILE="$APPDIR/port_speed.soc" |
| 20 | TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config.ini" |
| 21 | OLT_MODEL=`cat /sys/devices/virtual/dmi/id/board_name` |
Thiyagarajan Subramani | 3e8bfd9 | 2021-04-26 15:07:14 +0530 | [diff] [blame^] | 22 | PRODUCT_NAME= |
| 23 | |
| 24 | # phoenix - wait for onlp driver to load |
| 25 | if [ "$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 |
| 35 | fi |
| 36 | |
Girish Gowdra | fc10f0d | 2020-11-30 13:06:35 -0800 | [diff] [blame] | 37 | if [ "$OLT_MODEL" = "ASXvOLT16" ]; then |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 38 | Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'` |
Girish Gowdra | fc10f0d | 2020-11-30 13:06:35 -0800 | [diff] [blame] | 39 | [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini" |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 40 | APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE" |
Girish Gowdra | fc10f0d | 2020-11-30 13:06:35 -0800 | [diff] [blame] | 41 | elif [ "$OLT_MODEL" = "ASGvOLT64" ]; then |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 42 | Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'` |
Girish Gowdra | fc10f0d | 2020-11-30 13:06:35 -0800 | [diff] [blame] | 43 | [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini" |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 44 | 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 Subramani | 3e8bfd9 | 2021-04-26 15:07:14 +0530 | [diff] [blame^] | 46 | elif [ "$OLT_MODEL" = "RLT-3200G" ] || [ "$OLT_MODEL" = "RLT-3200X" ] || [ "$OLT_MODEL" = "RLT-1600G" ] || [ "$OLT_MODEL" = "RLT-1600X" ]; then |
| 47 | APPARGS="-pcie -d" |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 48 | else |
| 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" |
| 52 | fi |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 53 | |
Girish Gowdra | 3a43976 | 2020-01-28 15:21:31 +0530 | [diff] [blame] | 54 | # Include functions |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 55 | set -e |
| 56 | . /lib/lsb/init-functions |
| 57 | |
| 58 | start() { |
Thiyagarajan Subramani | 3e8bfd9 | 2021-04-26 15:07:14 +0530 | [diff] [blame^] | 59 | 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 Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 65 | sleep 10 |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 66 | printf "Starting '$NAME'... " |
Girish Gowdra | 3a43976 | 2020-01-28 15:21:31 +0530 | [diff] [blame] | 67 | touch /var/log/$NAME.log |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 68 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 69 | export USER=$USER |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 70 | 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 Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 71 | sleep 2 && [ -z `pidof $NAME 2>/dev/null` ] || pidof $NAME > /var/run/$NAME.pid |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 72 | printf "done\n" |
| 73 | } |
| 74 | |
| 75 | #We need this function to ensure the whole process tree will be killed |
| 76 | killtree() { |
| 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 | |
| 85 | stop() { |
| 86 | printf "Stopping '$NAME'... " |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 87 | [ -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 Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 93 | printf "done\n" |
| 94 | } |
| 95 | |
| 96 | status() { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 97 | status_of_proc -p /var/run/$NAME.pid $APPDIR/$APPBIN $NAME && exit 0 || exit $? |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | case "$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 | ;; |
| 118 | esac |
| 119 | |
| 120 | exit 0 |