# SPDX-License-Identifier: GPL-3.0-only babel_add_interface() { [ "$#" -ne "4" ] && return 1 local name="$1" local interface="$2" local type="$3" local rxcost="$4" mkdir -p /tmp/bird-babel echo "interface \"$interface\" { type $type; rxcost $rxcost; };" > /tmp/bird-babel/$name.conf return 0 } babel_delete_interface() { [ "$#" -ne "1" ] && return 1 local name="$1" # Removing peers from /etc is not necessary, as all peers are generated into /tmp on every configuration run, # which completely overwrites existing peers in /etc in the apply step. rm -f /tmp/bird-babel/$name.conf return 0 } babel_add_redistribute_filter() { return 0 } babel_remove_custom_redistribute_filters() { return 0 } babel_apply() { # error output hidden because apply might be executed without a preceding configure step. if [ -d /tmp/bird-babel ]; then rm -rf /etc/bird-babel mv /tmp/bird-babel /etc/bird-babel fi return 0 } babel_reload_implementation() { # Change include file path, so bird uses the correct configuration, depending on the configuration state: # - If test mode is active (and /tmp/bird-babel exists), switch to the temporary (/tmp) configuration to be tested. # - If new settings are applied or the old settings are restored after an unsuccessful test (and /tmp/bird-babel does not exist), # switch back to the permanent configuration (/etc). if [ -d /tmp/bird-babel ]; then echo 'include "/tmp/bird-babel/*.conf";' > /etc/bird-babel-include.conf else echo 'include "/etc/bird-babel/*.conf";' > /etc/bird-babel-include.conf fi /etc/init.d/bird reload } babel_revert() { rm -r /tmp/bird-babel }