Skip to content

Commit

Permalink
Conditionalize Avahi Service Start and Installation (openthread#2280)
Browse files Browse the repository at this point in the history
Ensure the Avahi daemon is installed and started only when
OTBR_MDNS == "avahi". This prevents multiple mDNS stacks from
running especially in container environments.
  • Loading branch information
kevinanderson1 committed May 10, 2024
1 parent 72ae1f1 commit 7c1f16c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ install_packages_apt()
sudo apt-get install --no-install-recommends -y libdbus-1-dev

# mDNS
sudo apt-get install --no-install-recommends -y libavahi-client3 libavahi-common-dev libavahi-client-dev avahi-daemon
sudo apt-get install --no-install-recommends -y libavahi-client3 libavahi-common-dev libavahi-client-dev

if [[ ${OTBR_MDNS} == "avahi" ]]; then
sudo apt-get install --no-install-recommends -y avahi-daemon
fi

(MDNS_RESPONDER_SOURCE_NAME=mDNSResponder-1790.80.10 \
&& MDNS_RESPONDER_PATCH_PATH=$(realpath "$(dirname "$0")"/../third_party/mDNSResponder) \
&& cd /tmp \
Expand Down
17 changes: 13 additions & 4 deletions script/server
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ startup()
if have systemctl; then
systemctl is-active rsyslog || sudo systemctl start rsyslog || die 'Failed to start rsyslog!'
systemctl is-active dbus || sudo systemctl start dbus || die 'Failed to start dbus!'
systemctl is-active avahi-daemon || sudo systemctl start avahi-daemon || die 'Failed to start avahi!'
sudo service mdns status || sudo service mdns start || echo "service mdns is not available!"
if [[ ${OTBR_MDNS} == "avahi" ]]; then
systemctl is-active avahi-daemon || sudo systemctl start avahi-daemon || die 'Failed to start avahi!'
fi
without WEB_GUI || systemctl is-active otbr-web || sudo systemctl start otbr-web || die 'Failed to start otbr-web!'
systemctl is-active otbr-agent || sudo systemctl start otbr-agent || die 'Failed to start otbr-agent!'
elif have service; then
sudo service rsyslog status || sudo service rsyslog start || die 'Failed to start rsyslog!'
sudo service dbus status || sudo service dbus start || die 'Failed to start dbus!'
# Tolerate the mdns failure as it is installed for only CI docker.
sudo service mdns status || sudo service mdns start || echo "service mdns is not available!"
sudo service avahi-daemon status || sudo service avahi-daemon start || die 'Failed to start avahi!'
if [[ ${OTBR_MDNS} == "avahi" ]]; then
sudo service avahi-daemon status || sudo service avahi-daemon start || die 'Failed to start avahi!'
fi
sudo service otbr-agent status || sudo service otbr-agent start || die 'Failed to start otbr-agent!'
without WEB_GUI || sudo service otbr-web status || sudo service otbr-web start || die 'Failed to start otbr-web!'
else
Expand All @@ -73,14 +78,18 @@ shutdown()
if have systemctl; then
systemctl is-active rsyslog && sudo systemctl stop rsyslog || echo 'Failed to stop rsyslog!'
systemctl is-active dbus && sudo systemctl stop dbus || echo 'Failed to stop dbus!'
systemctl is-active avahi-daemon && sudo systemctl stop avahi-daemon || echo 'Failed to stop avahi!'
if [[ ${OTBR_MDNS} == "avahi" ]]; then
systemctl is-active avahi-daemon && sudo systemctl stop avahi-daemon || echo 'Failed to stop avahi!'
fi
without WEB_GUI || systemctl is-active otbr-web && sudo systemctl stop otbr-web || echo 'Failed to stop otbr-web!'
systemctl is-active otbr-agent && sudo systemctl stop otbr-agent || echo 'Failed to stop otbr-agent!'
elif have service; then
sudo service rsyslog status && sudo service rsyslog stop || echo 'Failed to stop rsyslog!'
sudo service dbus status && sudo service dbus stop || echo 'Failed to stop dbus!'
sudo service mdns status && sudo service mdns stop || echo "service mdns is not available!"
sudo service avahi-daemon status && sudo service avahi-daemon stop || echo 'Failed to stop avahi!'
if [[ ${OTBR_MDNS} =="avahi" ]]; then
sudo service avahi-daemon status && sudo service avahi-daemon stop || echo 'Failed to stop avahi!'
fi
sudo service otbr-agent status && sudo service otbr-agent stop || echo 'Failed to stop otbr-agent!'
without WEB_GUI || sudo service otbr-web status && sudo service otbr-web stop || echo 'Failed to stop otbr-web!'
else
Expand Down

0 comments on commit 7c1f16c

Please sign in to comment.