El 22/06/16 a las 09:00, Dhionel Díaz escribió: > El 21/06/16 a las 16:36, Ferenc Wágner escribió: >> Christoph Berg <m...@debian.org> writes: >> >>> Re: Dhionel Díaz 2016-06-21 >>> <0c44f8f5-4d46-60e7-2bc3-d16956869...@cenditel.gob.ve> >>> >>>>> What about depending on inetd | systemd-sysv and invoking update-inetd >>>>> only if systemd is not running? >>> >>> Doesn't that fail if the system is switched to/from systemd after the >>> package was already installed? >> >> Sure it does. But if you do both, one (probably inetd, coming later) >> will fail to bind if systemd manages the socket and also starts inetd. >> Hmm, maybe you could have the csync2.socket conflict with inet.service >> to avoid this failure mode... That would serve csync2 via inetd instead >> of systemd, which is inefficient, but maybe acceptable. >> >>>>> Don't forget to depend on update-inetd as well. >>>> >>>> Looks reasonable, in the following days I'll be sending a patch along >>>> those lines. In a brief exploration I haven't found if there is a >>>> recommended approach to detect systemd, do you think a test on the exit >>>> status of 'stat -c %N /proc/1/exe | grep systemd' would be appropriate? >>> >>> The canonical test is "test -d /run/systemd/system". >> >> Which is also more portable than using /proc. Not that you could find >> systemd where procsfs isn't supported... >> > What about enabling only one of the options at install time? In that > way, the conflicts can be avoided. > > In case of a switch to systemd the daemon could still be handled by > inetd with the same configuration placed at install time, because the > socket unit would remain disabled. I don't know the details of a switch > to systemd, but I think that it would also be feasible to switch the > daemon to systemd socket activation as part of that process, if that is > considered appropriate. I'm not sure about the case of a switch to > sysv-init, though. Would systemd remain as a sysv service in that case? >
Attached you will find a patch that implements the approach described above; the socket unit is not enabled at install time, in order to avoid conflicts. I hope the patch can be useful. Regards, -- Dhionel Díaz Centro Nacional de Desarrollo e Investigación en Tecnologías Libres Ministerio del Poder Popular para Educación Universitaria, Ciencia y Tecnología
diff -Nru csync2-2.0-8-g175a01c/debian/control csync2-2.0-8-g175a01c/debian/control --- csync2-2.0-8-g175a01c/debian/control 2016-06-20 06:06:38.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/control 2016-07-26 09:15:06.000000000 -0400 @@ -11,6 +11,7 @@ automake, bison, dh-autoreconf, + dh-systemd, flex, libmysqlclient-dev, libpq-dev, @@ -28,7 +29,8 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, netbase (>= 4.25), - openbsd-inetd | inet-superserver + adduser, + openbsd-inetd | inet-superserver | systemd-sysv Suggests: sqlite3 Description: cluster synchronization tool CSYNC2 synchronizes files in a cluster using the rsync-algorithm. diff -Nru csync2-2.0-8-g175a01c/debian/cron.d csync2-2.0-8-g175a01c/debian/cron.d --- csync2-2.0-8-g175a01c/debian/cron.d 2016-06-20 06:06:38.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/cron.d 2016-07-26 09:04:01.000000000 -0400 @@ -19,4 +19,4 @@ # along with this program; if not, write to the Free Software # Foundation # -# 0 4 * * * root csync2 -cr / ; csync2 -T <my-hostname> <peer-hostname> +# 0 4 * * * csync2 csync2 -cr / ; csync2 -T <my-hostname> <peer-hostname> diff -Nru csync2-2.0-8-g175a01c/debian/install csync2-2.0-8-g175a01c/debian/install --- csync2-2.0-8-g175a01c/debian/install 2016-06-20 06:06:38.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/install 2016-07-26 09:04:01.000000000 -0400 @@ -1 +1,3 @@ csync2.cfg etc +debian/systemd/csync2.socket lib/systemd/system +debian/systemd/csync2@.service lib/systemd/system diff -Nru csync2-2.0-8-g175a01c/debian/postinst csync2-2.0-8-g175a01c/debian/postinst --- csync2-2.0-8-g175a01c/debian/postinst 2016-06-20 06:06:38.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/postinst 2016-07-26 14:36:08.000000000 -0400 @@ -20,12 +20,25 @@ case "$1" in configure) - if ! grep -q -s "^csync2" /etc/inetd.conf ; then + if command -v update-inetd >/dev/null 2>&1 && ! grep -q -s "^csync2" /etc/inetd.conf ; then update-inetd --remove '^csync2' - update-inetd --group OTHER --add \ - 'csync2\t\tstream\ttcp\tnowait\troot\t/usr/sbin/csync2\tcsync2 -i -l' + if [ -d /run/systemd/system ] ; then + update-inetd --group OTHER --add \ + '#<off># csync2\t\tstream\ttcp\tnowait\tcsync2\t/usr/sbin/csync2\tcsync2 -i -l' + else + update-inetd --group OTHER --add \ + 'csync2\t\tstream\ttcp\tnowait\tcsync2\t/usr/sbin/csync2\tcsync2 -i -l' + fi fi + adduser --quiet --system --group \ + --home /var/lib/csync2 --no-create-home \ + csync2 + if ! dpkg-statoverride --list /var/lib/csync2 >/dev/null 2>&1 + then + chown -R csync2:csync2 /var/lib/csync2 + chmod -R u=rwX,g=rX,o= /var/lib/csync2 + fi ;; diff -Nru csync2-2.0-8-g175a01c/debian/prerm csync2-2.0-8-g175a01c/debian/prerm --- csync2-2.0-8-g175a01c/debian/prerm 2016-06-20 06:06:38.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/prerm 2016-07-26 14:36:27.000000000 -0400 @@ -20,9 +20,11 @@ case "$1" in remove|upgrade|deconfigure) - update-inetd --remove '^csync2' - if [ -f /var/run/inetd.pid ] ; then - kill -s HUP $(cat /var/run/inetd.pid) + if command -v update-inetd >/dev/null 2>&1 ; then + update-inetd --remove '^csync2' + if [ -f /var/run/inetd.pid ] ; then + kill -s HUP $(cat /var/run/inetd.pid) + fi fi ;; failed-upgrade) diff -Nru csync2-2.0-8-g175a01c/debian/rules csync2-2.0-8-g175a01c/debian/rules --- csync2-2.0-8-g175a01c/debian/rules 2016-07-13 05:55:09.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/rules 2016-07-26 11:54:03.000000000 -0400 @@ -5,7 +5,7 @@ CFLAGS = $(shell dpkg-buildflags --get CFLAGS) -I$(shell pg_config --includedir) %: - dh $@ --with autotools_dev,autoreconf + dh $@ --with autotools_dev,autoreconf,systemd override_dh_auto_configure: dh_auto_configure \ @@ -23,3 +23,6 @@ override_dh_installchangelogs: dh_installchangelogs rm debian/csync2/usr/share/doc/csync2/ChangeLog + +override_dh_systemd_enable: + dh_systemd_enable --no-enable csync2.socket diff -Nru csync2-2.0-8-g175a01c/debian/systemd/csync2@.service csync2-2.0-8-g175a01c/debian/systemd/csync2@.service --- csync2-2.0-8-g175a01c/debian/systemd/csync2@.service 1969-12-31 20:00:00.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/systemd/csync2@.service 2016-07-26 14:46:44.000000000 -0400 @@ -0,0 +1,9 @@ +[Unit] +Description=csync2 asynchronous file synchronization +Documentation=man:csync2 + +[Service] +User=csync2 +Group=csync2 +ExecStart=-/usr/sbin/csync2 -i -l +StandardInput=socket diff -Nru csync2-2.0-8-g175a01c/debian/systemd/csync2.socket csync2-2.0-8-g175a01c/debian/systemd/csync2.socket --- csync2-2.0-8-g175a01c/debian/systemd/csync2.socket 1969-12-31 20:00:00.000000000 -0400 +++ csync2-2.0-8-g175a01c/debian/systemd/csync2.socket 2016-07-26 09:04:01.000000000 -0400 @@ -0,0 +1,9 @@ +[Unit] +Description=csync2 asynchronous file synchronization socket + +[Socket] +ListenStream=30865 +Accept=true + +[Install] +WantedBy=sockets.target
signature.asc
Description: OpenPGP digital signature