[swss.sh] fix an issue that dependent services are not read from a file (#8943)

This is due to the SERVICE variable declared after reading a file

#### Why I did it

To fix an issue that dhcp_relay does not restart with swss.

#### How I did it

Fixed in the swss.sh script

#### How to verify it

sudo systemctl restart swss
verify dhcp_relay restarts as well.
This commit is contained in:
Stepan Blyshchak 2021-10-27 05:01:30 +03:00 committed by Judy Joseph
parent a68a3a176e
commit a8235728f3

View File

@ -1,17 +1,17 @@
#!/bin/bash
DEV=$2
SERVICE="swss"
PEER="syncd"
DEBUGLOG="/tmp/swss-syncd-debug$DEV.log"
LOCKFILE="/tmp/swss-syncd-lock$DEV"
NAMESPACE_PREFIX="asic"
ETC_SONIC_PATH="/etc/sonic/"
DEPENDENT="radv"
MULTI_INST_DEPENDENT="teamd"
# Update dependent list based on other packages requirements
if [[ -f /etc/sonic/${SERVICE}_dependent ]]; then
DEPENDENT="${DEPENDENT} $(cat /etc/sonic/${SERVICE}_dependent)"
fi
if [[ -f /etc/sonic/${SERVICE}_multi_inst_dependent ]]; then
MULTI_INST_DEPENDENT="${MULTI_INST_DEPENDENT} cat /etc/sonic/${SERVICE}_multi_inst_dependent"
fi
. /usr/local/bin/asic_status.sh
function debug()
@ -20,6 +20,18 @@ function debug()
/bin/echo `date` "- $1" >> ${DEBUGLOG}
}
function read_dependent_services()
{
# Update dependent list based on other packages requirements
if [[ -f ${ETC_SONIC_PATH}/${SERVICE}_dependent ]]; then
DEPENDENT="${DEPENDENT} $(cat ${ETC_SONIC_PATH}/${SERVICE}_dependent)"
fi
if [[ -f ${ETC_SONIC_PATH}/${SERVICE}_multi_inst_dependent ]]; then
MULTI_INST_DEPENDENT="${MULTI_INST_DEPENDENT} cat ${ETC_SONIC_PATH}/${SERVICE}_multi_inst_dependent"
fi
}
function lock_service_state_change()
{
debug "Locking ${LOCKFILE} from ${SERVICE}$DEV service"
@ -267,13 +279,6 @@ stop() {
stop_peer_and_dependent_services
}
DEV=$2
SERVICE="swss"
PEER="syncd"
DEBUGLOG="/tmp/swss-syncd-debug$DEV.log"
LOCKFILE="/tmp/swss-syncd-lock$DEV"
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"
@ -282,6 +287,8 @@ else
SONIC_DB_CLI="sonic-db-cli"
fi
read_dependent_services
case "$1" in
start|wait|stop)
$1