firmware/src/packages/fff/fff-babel-bird2/files/etc/init.d/fff-bird

46 lines
1.4 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2017 OpenWrt.org
USE_PROCD=1
START=70
BIRD_BIN="/usr/sbin/bird"
BIRD_CONF="/etc/bird.conf"
BIRD_PID_FILE="/var/run/bird.pid"
start_service() {
mkdir -p /var/run
set_include_path
procd_open_instance
procd_set_param command $BIRD_BIN -f -c $BIRD_CONF -P $BIRD_PID_FILE
procd_set_param file "$BIRD_CONF"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
set_include_path
procd_send_signal fff-bird
}
set_include_path() {
# Change include file path, so bird uses the correct configuration, depending on the configuration state:
# - If test mode is active (and /tmp/bird/fff exists), switch to the temporary configuration to be tested.
# - If new settings are applied or the old settings are restored after an unsuccessful test (and /tmp/bird/fff does not exist),
# switch back to the permanent configuration (/etc/bird/fff).
mkdir -p /tmp/bird/include
if [ -d /tmp/bird/fff ]; then
echo 'include "/tmp/bird/fff/babelpeers/*.conf";' > /tmp/bird/include/babelpeers.conf
echo 'include "/tmp/bird/fff/nat-filter.conf";' > /tmp/bird/include/nat-filter.conf
else
echo 'include "/etc/bird/fff/babelpeers/*.conf";' > /tmp/bird/include/babelpeers.conf
echo 'include "/etc/bird/fff/nat-filter.conf";' > /tmp/bird/include/nat-filter.conf
fi
}