Skip to content

Commit 7f57036

Browse files
committed
net/frr: watchfrr service handling
1 parent a5fdb9c commit 7f57036

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
# Service wrapper for restarting frr service
3+
# This wrapper is needed to react on specific service interactions through watchfrr.
4+
# Startup details with watchfrr enabled (default):
5+
# 1. "service frr start" calls "service frr start watchfrr"
6+
# 2. watchfrr once started calls "service frr restart all"
7+
# 3. "restart all" need to loop the list of $frr_daemons to start each
8+
# of then
9+
# 4. vtysh -b is executed to load boot startup configuration
10+
11+
/usr/sbin/service frr restart $1
12+
13+
# If started service is ospfd, e.g. process error
14+
if [ "$1" = "ospfd" ]; then
15+
logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now"
16+
/usr/local/opnsense/scripts/frr/carp_event_handler
17+
fi
18+
# If frr starts up
19+
if [ "$1" = "all" ]; then
20+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler in 1 sec."
21+
(
22+
sleep 1
23+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now"
24+
/usr/local/opnsense/scripts/frr/carp_event_handler
25+
) &
26+
fi
27+
exit $?
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
# Service wrapper for starting frr service
3+
# This wrapper is needed to react on specific service interactions through watchfrr.
4+
# Startup details with watchfrr enabled (default):
5+
# 1. "service frr start" calls "service frr start watchfrr"
6+
# 2. watchfrr once started calls "service frr restart all"
7+
# 3. "restart all" need to loop the list of $frr_daemons to start each
8+
# of then
9+
# 4. vtysh -b is executed to load boot startup configuration
10+
11+
/usr/sbin/service frr start $1
12+
13+
# If started service is ospfd, e.g. process error
14+
if [ "$1" = "ospfd" ]; then
15+
logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now"
16+
/usr/local/opnsense/scripts/frr/carp_event_handler
17+
fi
18+
# If frr starts up
19+
if [ "$1" = "all" ]; then
20+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler in 1 sec."
21+
(
22+
sleep 1
23+
/usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now"
24+
/usr/local/opnsense/scripts/frr/carp_event_handler
25+
) &
26+
fi
27+
exit $?

net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ frr_carp_demote="{%
1818
if not helpers.empty('OPNsense.quagga.ospf.carp_demote') %} ospfd{% endif %}{%
1919
if not helpers.empty('OPNsense.quagga.ospf6.carp_demote') %} ospf6d{% endif
2020
%}"
21-
start_postcmd='
22-
# XXX rc.d/frr declares its own post command we need to hook first
23-
start_postcmd
24-
# XXX rc.d/frr iterates through daemons so we need to hook last one
25-
if [ "${frr_daemons}" != "${frr_daemons% ${name}}" ]; then
26-
echo "Starting CARP event handler now"
27-
/usr/local/opnsense/scripts/frr/carp_event_handler
28-
fi
29-
'
21+
watchfrr_flags="-r /usr/local/opnsense/scripts/frr/frr_restart.shbB%s -s /usr/local/opnsense/scripts/frr/frr_start.shbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30"
3022
{% if OPNsense.quagga.general.enablesnmp == '1' %}
3123
zebra_flags="${zebra_flags} -M snmp"
3224
bgpd_flags="${bgpd_flags} -M snmp"

0 commit comments

Comments
 (0)