From 159dc575a6cfe965e6eeaa9e9027fc627bf6069b Mon Sep 17 00:00:00 2001 From: Imuli Date: Tue, 16 Sep 2014 11:07:41 -0400 Subject: [PATCH 1/6] babeld: procd support note: dependant on openwrt commit 85fabd68, adding support for null arguments. --- babeld/files/babeld.init | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init index 21ae4be..416bbe4 100755 --- a/babeld/files/babeld.init +++ b/babeld/files/babeld.init @@ -2,9 +2,9 @@ . $IPKG_INSTROOT/lib/functions/network.sh +USE_PROCD=1 START=70 -pidfile='/var/run/babeld.pid' CONFIGFILE='/var/etc/babeld.conf' OTHERCONFIGFILE="/etc/babeld.conf" OTHERCONFIGDIR="/tmp/babeld.d/" @@ -212,7 +212,7 @@ babel_config_cb() { esac } -start() { +start_service() { mkdir -p /var/lib mkdir -p /var/etc mkdir -p $OTHERCONFIGDIR @@ -235,26 +235,18 @@ start() { config_foreach parse_old_global_options general # Parse filters separately, since we know which options we expect config_foreach babel_filter filter + procd_open_instance # Using multiple config files is supported since babeld 1.5.1 - /usr/sbin/babeld -D -I "$pidfile" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE" - # Wait for the pidfile to appear - for i in 1 2 - do - [ -f "$pidfile" ] || sleep 1 - done - [ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42) + procd_set_param command /usr/sbin/babeld -L /var/log/babeld.log -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE" + procd_set_param file "$OTHERCONFIGFILE" "$CONFIGFILE" + procd_set_param respawn + procd_close_instance } -stop() { - [ -f "$pidfile" ] && kill $(cat $pidfile) - # 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 +service_triggers() { + procd_add_reload_trigger babeld } status() { - [ -f "$pidfile" ] && kill -USR1 $(cat $pidfile) + kill -USR1 $(pgrep -P 1 babeld) } From fd424268ba0945ab6647d1fbb1674b1c85c59f82 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 9 Jan 2017 15:42:58 +0100 Subject: [PATCH 2/6] babeld: Log to the system log instead of logging to a file This avoids running out of flash or RAM space if babeld logs too much. The system log is stored on RAM by default and has a controlled size. It is still possible to tell babeld to log to a file, by using the following in /etc/config/babeld: config general option log_file "/var/log/babeld.log" Signed-off-by: Baptiste Jonglez --- babeld/files/babeld.init | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init index 416bbe4..def90b2 100755 --- a/babeld/files/babeld.init +++ b/babeld/files/babeld.init @@ -237,7 +237,9 @@ start_service() { config_foreach babel_filter filter procd_open_instance # Using multiple config files is supported since babeld 1.5.1 - procd_set_param command /usr/sbin/babeld -L /var/log/babeld.log -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE" + procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE" + procd_set_param stdout 1 + procd_set_param stderr 1 procd_set_param file "$OTHERCONFIGFILE" "$CONFIGFILE" procd_set_param respawn procd_close_instance From 669fe615c644920b88d42943fb1920695ab30e63 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 9 Jan 2017 16:05:03 +0100 Subject: [PATCH 3/6] babeld: Properly quote variables This was mostly introduced by 82d9002689 ("babeld: add support for dynamic config files"). Signed-off-by: Baptiste Jonglez --- babeld/files/babeld.init | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init index def90b2..dea207a 100755 --- a/babeld/files/babeld.init +++ b/babeld/files/babeld.init @@ -18,7 +18,7 @@ ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id # Append a line to the configuration file cfg_append() { local value="$1" - echo "$value" >> $CONFIGFILE + echo "$value" >> "$CONFIGFILE" } cfg_append_option() { @@ -215,13 +215,13 @@ babel_config_cb() { start_service() { mkdir -p /var/lib mkdir -p /var/etc - mkdir -p $OTHERCONFIGDIR + mkdir -p "$OTHERCONFIGDIR" # Start by emptying the generated config file >"$CONFIGFILE" # Import dynamic config files - for f in $OTHERCONFIGDIR/*.conf; do - [ -f "$f" ] && cat $f >> $CONFIGFILE + for f in "$OTHERCONFIGDIR"/*.conf; do + [ -f "$f" ] && cat "$f" >> "$CONFIGFILE" done # First load the whole config file, without callbacks, so that we are # aware of all "ignore" options in the second pass. From ebfb650f017fc04855b5d8697c1d017dd27f3167 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 9 Jan 2017 17:07:40 +0100 Subject: [PATCH 4/6] babeld: add dynamic config files to the procd watch list This way, "/etc/init.d/babeld reload" will detect when one of these dynamic config files has changed, and restart babeld only if that is the case. Dynamic config files where introduced by 82d9002689 ("babeld: add support for dynamic config files"). Signed-off-by: Baptiste Jonglez --- babeld/files/babeld.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init index dea207a..276e67f 100755 --- a/babeld/files/babeld.init +++ b/babeld/files/babeld.init @@ -240,7 +240,7 @@ start_service() { procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE" procd_set_param stdout 1 procd_set_param stderr 1 - procd_set_param file "$OTHERCONFIGFILE" "$CONFIGFILE" + procd_set_param file "$OTHERCONFIGFILE" "$OTHERCONFIGDIR"/*.conf "$CONFIGFILE" procd_set_param respawn procd_close_instance } From 4c963b1b85267aa3a004a97a5781ad6f28cb95fa Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 9 Jan 2017 17:11:58 +0100 Subject: [PATCH 5/6] babeld: Bump PKG_RELEASE because of procd support Signed-off-by: Baptiste Jonglez --- babeld/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babeld/Makefile b/babeld/Makefile index 3264e9c..2d781ef 100644 --- a/babeld/Makefile +++ b/babeld/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=babeld PKG_VERSION:=1.8.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://www.irif.univ-paris-diderot.fr/~jch/software/files/ From 4868ec008ee516e0c7b83782bf2743aa65398418 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 9 Jan 2017 17:12:19 +0100 Subject: [PATCH 6/6] =?UTF-8?q?babeld:=20Update=20project=20URL=20again?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Baptiste Jonglez --- babeld/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/babeld/Makefile b/babeld/Makefile index 2d781ef..45d8ba7 100644 --- a/babeld/Makefile +++ b/babeld/Makefile @@ -12,7 +12,7 @@ PKG_VERSION:=1.8.0 PKG_RELEASE:=2 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_LICENSE:=MIT @@ -23,7 +23,7 @@ define Package/babeld CATEGORY:=Network SUBMENU:=Routing and Redirection 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 DEPENDS:=@IPV6 endef