|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Copyright (c) 2025 Andy Binder <[email protected]> |
| 4 | +# |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions |
| 7 | +# are met: |
| 8 | +# |
| 9 | +# 1. Redistributions of source code must retain the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer. |
| 11 | +# |
| 12 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 13 | +# notice, this list of conditions and the following disclaimer in the |
| 14 | +# documentation and/or other materials provided with the distribution. |
| 15 | +# |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 17 | +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 20 | +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 22 | +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 23 | +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 24 | +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 25 | +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | +# SUCH DAMAGE. |
| 27 | + |
| 28 | +# Service wrapper for starting/restarting frr service |
| 29 | +# This wrapper is needed to react on specific service interactions through watchfrr. |
| 30 | +# Startup details with watchfrr enabled (default): |
| 31 | +# 1. "service frr start" calls "service frr start watchfrr" |
| 32 | +# 2. watchfrr once started calls "service frr restart all" |
| 33 | +# 3. "restart all" need to loop the list of $frr_daemons to start each |
| 34 | +# of then |
| 35 | +# 4. vtysh -b is executed to load boot startup configuration |
| 36 | + |
| 37 | +ACTION="$1" |
| 38 | +COMMAND="$2" |
| 39 | + |
| 40 | +/usr/sbin/service frr "$ACTION" "$COMMAND" |
| 41 | +SERVICE_EXIT_CODE=$? |
| 42 | + |
| 43 | +# If frr starts/restarts ospfd, e.g. on process error (parameter: start/restart ospfd) |
| 44 | +if [ "$2" = "ospfd" ]; then |
| 45 | + logger -t frr_wrapper "WATCHFRR - OSPFD - Starting CARP event handler now" |
| 46 | + /usr/local/opnsense/scripts/frr/carp_event_handler |
| 47 | +fi |
| 48 | +# If frr starts up (parameter: restart all) |
| 49 | +if [ "$2" = "all" ]; then |
| 50 | + ( |
| 51 | + /usr/bin/logger -t frr_wrapper "WATCHFRR - STARTUP - Starting CARP event handler now" |
| 52 | + /usr/local/opnsense/scripts/frr/carp_event_handler |
| 53 | + ) & |
| 54 | +fi |
| 55 | +exit $SERVICE_EXIT_CODE |
0 commit comments