On Sat, 13 Dec 2014 21:00:56 -0800, Russ Allbery wrote: >> Can you provide me a sample systemd service init file, that correspond >> to init.d script please? I.e., the corresponding file for systemd to >> replace /etc/init.d/service. > > Take a look at the lbcd package in Debian. It has an init script, a > systemd unit, and an upstart configuration, all of the same (simple) > daemon, so it's easy to compare them.
Thanks Russ. So the next question is how do you install it? I took a deep look at the lbcd package in Debian, and for the best of my guesses, come up with this: ~~~ diff --git a/debian/control b/debian/control index 82f8edc..f05634a 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: dbab Section: net Priority: optional Maintainer: Tong Sun <[email protected]> -Build-Depends: debhelper (>= 9), ruby-ronn (>= 0.7.3) +Build-Depends: debhelper (>= 9), dh-systemd, ruby-ronn (>= 0.7.3) Standards-Version: 3.9.6 Homepage: https://github.com/suntong001/dbab Vcs-Git: https://github.com/suntong001/dbab.git diff --git a/debian/rules b/debian/rules index 79fd842..df98b29 100755 --- a/debian/rules +++ b/debian/rules @@ -5,4 +5,4 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ --parallel --with systemd diff --git a/src/Makefile b/src/Makefile index cef854c..592f742 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,6 +8,12 @@ docdir = ${prefix}/share/doc/dbab bindir = ${exec_prefix}/sbin etcdir = ${DESTDIR}/etc astdir = ${etcdir}/dbab +ssddir = ${etcdir}/systemd + +# Install the systemd unit file if systemd support was detected. +if HAVE_SYSTEMD +systemdsystemunit_DATA = systemd/dbab.service +endif man: cat README.md | ronn > assets/dbab-svr.8 @@ -23,12 +29,14 @@ install: $(INSTALL) -m 755 -d $(etcdir) $(INSTALL) -m 755 -d $(etcdir)/init.d $(INSTALL) -m 755 -d $(astdir) + $(INSTALL) -m 755 -d $(ssddir) $(INSTALL) -m 755 bin/dbab-get-list $(bindir) $(INSTALL) -m 755 bin/dbab-add-list $(bindir) $(INSTALL) -m 755 bin/dbab-chk-list $(bindir) $(INSTALL) -m 755 bin/dbab-svr $(bindir) $(INSTALL) -m 755 bin/dbab $(etcdir)/init.d +# $(INSTALL) -m 755 assets/dbab.service $(ssddir) $(INSTALL) -m 644 assets/dbab-svr.8 $(mandir)/man8 $(INSTALL) -m 644 assets/dbab-add-list.1 $(mandir)/man1 ~~~ But will either get: ~~~ W: dbab: executable-not-elf-or-script etc/systemd/dbab.service E: dbab: systemd-no-service-for-init-script dbab ~~~ or Makefile:14: *** missing separator (did you mean TAB instead of 8 spaces?). Stop. depending if I put in that "if" statement in Makefile. here is my dbab.service file: ~~~ $ cat dbab.service # systemd configuration for dbab. -*- conf -*- [Unit] Description=Dnsmasq-Based Ad-Blocker Documentation=man:dbab-svr(8) Documentation=http://sfxpt.wordpress.com/2014/11/30/use-new-dbab-to-set- proxy-automatically/ [Service] ExecStart=/usr/sbin/dbab-srv Type=forking [Install] WantedBy=multi-user.target ~~~ Once again, for the purpose of adding that single systemd configuration file, - do I need to add the dh-systemd to Build-Depends and use `dh $@ --parallel --with systemd`? - and how to fix the executable-not-elf-or-script and systemd-no-service- for-init-script error? Thanks -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: https://lists.debian.org/[email protected]

