Merge pull request #250 from zorun/babeld_procd_v2
babeld: Add procd support and other fixes
This commit is contained in:
commit
28fd777e5b
2 changed files with 19 additions and 25 deletions
|
@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=babeld
|
PKG_NAME:=babeld
|
||||||
PKG_VERSION:=1.8.0
|
PKG_VERSION:=1.8.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://www.irif.univ-paris-diderot.fr/~jch/software/files/
|
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
|
||||||
PKG_MD5SUM:=eb1c66c382e9181c418ebd84e52b5af2
|
PKG_MD5SUM:=eb1c66c382e9181c418ebd84e52b5af2
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ define Package/babeld
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
SUBMENU:=Routing and Redirection
|
SUBMENU:=Routing and Redirection
|
||||||
TITLE:=A loop-free distance-vector routing protocol
|
TITLE:=A loop-free distance-vector routing protocol
|
||||||
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
|
URL:=https://www.irif.fr/~jch/software/babel/
|
||||||
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
|
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
|
||||||
DEPENDS:=@IPV6
|
DEPENDS:=@IPV6
|
||||||
endef
|
endef
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
. $IPKG_INSTROOT/lib/functions/network.sh
|
. $IPKG_INSTROOT/lib/functions/network.sh
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
START=70
|
START=70
|
||||||
|
|
||||||
pidfile='/var/run/babeld.pid'
|
|
||||||
CONFIGFILE='/var/etc/babeld.conf'
|
CONFIGFILE='/var/etc/babeld.conf'
|
||||||
OTHERCONFIGFILE="/etc/babeld.conf"
|
OTHERCONFIGFILE="/etc/babeld.conf"
|
||||||
OTHERCONFIGDIR="/tmp/babeld.d/"
|
OTHERCONFIGDIR="/tmp/babeld.d/"
|
||||||
|
@ -18,7 +18,7 @@ ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id
|
||||||
# Append a line to the configuration file
|
# Append a line to the configuration file
|
||||||
cfg_append() {
|
cfg_append() {
|
||||||
local value="$1"
|
local value="$1"
|
||||||
echo "$value" >> $CONFIGFILE
|
echo "$value" >> "$CONFIGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_append_option() {
|
cfg_append_option() {
|
||||||
|
@ -212,16 +212,16 @@ babel_config_cb() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
mkdir -p /var/lib
|
mkdir -p /var/lib
|
||||||
mkdir -p /var/etc
|
mkdir -p /var/etc
|
||||||
mkdir -p $OTHERCONFIGDIR
|
mkdir -p "$OTHERCONFIGDIR"
|
||||||
|
|
||||||
# Start by emptying the generated config file
|
# Start by emptying the generated config file
|
||||||
>"$CONFIGFILE"
|
>"$CONFIGFILE"
|
||||||
# Import dynamic config files
|
# Import dynamic config files
|
||||||
for f in $OTHERCONFIGDIR/*.conf; do
|
for f in "$OTHERCONFIGDIR"/*.conf; do
|
||||||
[ -f "$f" ] && cat $f >> $CONFIGFILE
|
[ -f "$f" ] && cat "$f" >> "$CONFIGFILE"
|
||||||
done
|
done
|
||||||
# First load the whole config file, without callbacks, so that we are
|
# First load the whole config file, without callbacks, so that we are
|
||||||
# aware of all "ignore" options in the second pass.
|
# aware of all "ignore" options in the second pass.
|
||||||
|
@ -235,26 +235,20 @@ start() {
|
||||||
config_foreach parse_old_global_options general
|
config_foreach parse_old_global_options general
|
||||||
# Parse filters separately, since we know which options we expect
|
# Parse filters separately, since we know which options we expect
|
||||||
config_foreach babel_filter filter
|
config_foreach babel_filter filter
|
||||||
|
procd_open_instance
|
||||||
# Using multiple config files is supported since babeld 1.5.1
|
# Using multiple config files is supported since babeld 1.5.1
|
||||||
/usr/sbin/babeld -D -I "$pidfile" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
|
procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
|
||||||
# Wait for the pidfile to appear
|
procd_set_param stdout 1
|
||||||
for i in 1 2
|
procd_set_param stderr 1
|
||||||
do
|
procd_set_param file "$OTHERCONFIGFILE" "$OTHERCONFIGDIR"/*.conf "$CONFIGFILE"
|
||||||
[ -f "$pidfile" ] || sleep 1
|
procd_set_param respawn
|
||||||
done
|
procd_close_instance
|
||||||
[ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
service_triggers() {
|
||||||
[ -f "$pidfile" ] && kill $(cat $pidfile)
|
procd_add_reload_trigger babeld
|
||||||
# avoid race-condition on restart: wait for
|
|
||||||
# babeld to die for real.
|
|
||||||
[ -f "$pidfile" ] && sleep 1
|
|
||||||
[ -f "$pidfile" ] && sleep 1
|
|
||||||
[ -f "$pidfile" ] && sleep 1
|
|
||||||
[ -f "$pidfile" ] && exit 42
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status() {
|
status() {
|
||||||
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
|
kill -USR1 $(pgrep -P 1 babeld)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue