From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-1" (verified OK)) by huchra.bufferbloat.net (Postfix) with ESMTPS id C83D121F247 for ; Mon, 8 Sep 2014 00:20:04 -0700 (PDT) Received: from hms-beagle.home.lan ([93.194.233.219]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MWCKz-1Xt9dA2ADx-00XHyU; Mon, 08 Sep 2014 09:20:01 +0200 From: Sebastian Moeller Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Mon, 8 Sep 2014 09:19:59 +0200 References: <257d4c.6a0cdbee.jhzj.mx@tumtum.plumbweb.net> To: =?iso-8859-1?Q?Dave_T=E4ht?= , cerowrt-devel Message-Id: <6F58B94D-3EF5-48D9-97D1-A0911A03B1FB@gmx.de> Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-Provags-ID: V03:K0:/9JWuktdlwwudtH4Yf+9UuWCvVMVN/6V4OEXgwDhOo7uCNzmJRV ZAu1OBDeE/oH/tbXivvCginboF2IrwVk06QDog2hmXxhLAj+cND9Dh7KcK8JzQObmfBc3/j 3Jyn2h2g8PQ2Zd2OgS9GaHeP07yoqMVRKmnhkjMTlxsQ8DxixaxD2bFxoDBNOjmLEsdsJKq /cRqphPlIVeqJ/FIAQGdA== X-UI-Out-Filterresults: notjunk:1; Subject: [Cerowrt-devel] Fwd: [OpenWrt-Devel] [PATCH] babeld: use procd to start, stop, and respawn X-BeenThere: cerowrt-devel@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development issues regarding the cerowrt test router project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Sep 2014 07:20:33 -0000 Hi Dave, hi List, I lost track of the babel thing, but is the following something we would = want (or do we have that already, I am confused ;))? Begin forwarded message: > From: Tristan Plumb > Subject: [OpenWrt-Devel] [PATCH] babeld: use procd to start, stop, and = respawn > Date: September 7, 2014 at 23:56:32 GMT+2 > To: Gabriel Kerneis , = openwrt-devel@lists.openwrt.org >=20 > Changes the babeld init script to utilize procd and adds a hotplug.d = file > to restart babeld when interfaces go up or down. >=20 > Additionally adds a patch to the babeld source is to prevent the > attempted recreation of a pidfile when babeld restarts uncleanly. This = is > also possible to do by passing -I '' on the command line, however = procd > interprets an empty argument terminating the list, and thus cannot = supply > empty arguments to programs it manages. >=20 > Signed-off-by: Tristan Plumb > --- > diff --git a/babeld/Makefile b/babeld/Makefile > index e939310..70fcd64 100644 > --- a/babeld/Makefile > +++ b/babeld/Makefile > @@ -54,6 +54,8 @@ define Package/babeld/install > $(INSTALL_CONF) ./files/babeld.config $(1)/etc/config/babeld > $(INSTALL_DIR) $(1)/etc/init.d > $(INSTALL_BIN) ./files/babeld.init $(1)/etc/init.d/babeld > + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface > + $(INSTALL_DATA) ./files/babeld.hotplug = $(1)/etc/hotplug.d/iface/25-babeld > endef >=20 > $(eval $(call BuildPackage,babeld)) > diff --git a/babeld/files/babeld.hotplug b/babeld/files/babeld.hotplug > new file mode 100644 > index 0000000..3fe674a > --- /dev/null > +++ b/babeld/files/babeld.hotplug > @@ -0,0 +1,6 @@ > +#!/bin/sh > + > +[ "$ACTION" =3D ifup ] || exit 0 > + > +/etc/init.d/babeld enabled && /etc/init.d/babeld restart > + > diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init > index 180fc7e..de8d73b 100755 > --- a/babeld/files/babeld.init > +++ b/babeld/files/babeld.init > @@ -2,9 +2,9 @@ >=20 > . /lib/functions/network.sh >=20 > +USE_PROCD=3D1 > START=3D70 >=20 > -pidfile=3D'/var/run/babeld.pid' > CONFIGFILE=3D'/var/etc/babeld.conf' > OTHERCONFIGFILE=3D"/etc/babeld.conf" > EXTRA_COMMANDS=3D"status" > @@ -197,7 +197,7 @@ babel_config_cb() { > esac > } >=20 > -start() { > +start_service() { > mkdir -p /var/lib > # Start by emptying the generated config file > >"$CONFIGFILE" > @@ -213,26 +213,17 @@ 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 -c "$OTHERCONFIGFILE" = -c "$CONFIGFILE" > + procd_set_param respawn > + procd_close_instance > } >=20 > -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 > } >=20 > status() { > - [ -f "$pidfile" ] && kill -USR1 $(cat $pidfile) > + kill -USR1 $(pidof babeld) > } > diff --git a/babeld/patches/001-no-default-pidfile.patch = b/babeld/patches/001-no-default-pidfile.patch > new file mode 100644 > index 0000000..74ac6b4 > --- /dev/null > +++ b/babeld/patches/001-no-default-pidfile.patch > @@ -0,0 +1,21 @@ > +diff --git a/babeld.c b/babeld.c > +index 656c9da..88e4aec 100644 > +--- a/babeld.c > ++++ b/babeld.c > +@@ -66,7 +66,7 @@ int resend_delay =3D -1; > + int random_id =3D 0; > + int do_daemonise =3D 0; > + const char *logfile =3D NULL, > +- *pidfile =3D "/var/run/babeld.pid", > ++ *pidfile =3D NULL, > + *state_file =3D "/var/lib/babel-state"; > +=20 > + unsigned char *receive_buffer =3D NULL; > +@@ -251,6 +251,7 @@ main(int argc, char **argv) > + break; > + case 'D': > + do_daemonise =3D 1; > ++ pidfile =3D "/var/run/babeld.pid"; > + break; > + case 'L': > + logfile =3D optarg; >=20 > --=20 > All original matter is hereby placed immediately under the public = domain. > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel