-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move RADV fastboot handling to a service script (#5108)
* New /usr/local/bin/ script to start/stop radv service
- Loading branch information
Showing
3 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
function debug() | ||
{ | ||
/usr/bin/logger $1 | ||
/bin/echo `date` "- $1" >> ${DEBUGLOG} | ||
} | ||
|
||
function check_warm_boot() | ||
{ | ||
SYSTEM_WARM_START=`$SONIC_DB_CLI STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` | ||
SERVICE_WARM_START=`$SONIC_DB_CLI STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable` | ||
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then | ||
WARM_BOOT="true" | ||
else | ||
WARM_BOOT="false" | ||
fi | ||
} | ||
|
||
function check_fast_boot () | ||
{ | ||
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then | ||
FAST_BOOT="true" | ||
else | ||
FAST_BOOT="false" | ||
fi | ||
} | ||
|
||
start() { | ||
debug "Starting ${SERVICE}$DEV service..." | ||
|
||
check_warm_boot | ||
check_fast_boot | ||
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}." | ||
debug "Fast boot flag: ${SERVICE}$DEV ${FAST_BOOT}." | ||
|
||
# start service docker | ||
/usr/bin/${SERVICE}.sh start $DEV | ||
debug "Started ${SERVICE}$DEV service..." | ||
} | ||
|
||
wait() { | ||
/usr/bin/${SERVICE}.sh wait $DEV | ||
} | ||
|
||
stop() { | ||
debug "Stopping ${SERVICE}$DEV service..." | ||
|
||
check_warm_boot | ||
check_fast_boot | ||
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}." | ||
debug "Fast boot flag: ${SERVICE}$DEV ${FAST_BOOT}." | ||
|
||
# For WARM/FAST boot do not perform service stop | ||
if [[ x"$WARM_BOOT" != x"true" ]] && [[ x"$FAST_BOOT" != x"true" ]]; then | ||
/usr/bin/${SERVICE}.sh stop $DEV | ||
debug "Stopped ${SERVICE}$DEV service..." | ||
else | ||
debug "Killing Docker radv..." | ||
/usr/bin/docker kill radv &> /dev/null || debug "Docker radv is not running ($?) ..." | ||
fi | ||
} | ||
|
||
DEV=$2 | ||
|
||
SERVICE="radv" | ||
DEBUGLOG="/tmp/radv-debug$DEV.log" | ||
NAMESPACE_PREFIX="asic" | ||
if [ "$DEV" ]; then | ||
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace | ||
SONIC_DB_CLI="sonic-db-cli -n $NET_NS" | ||
else | ||
SONIC_DB_CLI="sonic-db-cli" | ||
fi | ||
|
||
case "$1" in | ||
start|wait|stop) | ||
$1 | ||
;; | ||
*) | ||
echo "Usage: $0 {start|wait|stop}" | ||
exit 1 | ||
;; | ||
esac |