3

I'm writing a daemon to manage my Java app on a headless Ubuntu 16.04 box using jsvc and this (probably pre-systemd) tutorial, and got as far as running update-rc.d mydaemon enable, receiving the error

update-rc.d: error: mydaemon Default-Start contains no runlevels, aborting

Having Googled around a bit this appears to have something to do with the (fairly?) recent move to systemd, which I have confirmed is running with pidof systemd.

How do I achieve the same starting-at-boot behaviour as update-rc.d (and more importantly stopping the service via /etc/init.d/mydaemon stop rather than just killing the process as the Java app needs to clean up). And are systemd and update-rc.d different systems, or does systemd just change how the latter works?

4

I don't have a Ubuntu 16.04 to test this on, or provide you with many details, but systemd has a compatibility feature to allow older /etc/init.d scripts to continue working. Instead of using update-rc.d to enable your daemon, use the systemd native command equivalent:

sudo systemctl enable mydaemon

If this still produces the same error, add the missing lines to the starting set of comments in your script:

# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6

between the ### BEGIN INIT INFO and ### END INIT INFO lines, and try again. See the LSB core description for these lines. You can also explicitly start the daemon with

sudo systemctl start mydaemon

and ask for its status with

sudo systemctl status -l mydaemon

See man systemd-sysv-generator for the compatibility feature. See this wiki for converting System V or upstart scripts like yours to native systemd Units.

  • Ah thank you. I'd inadvertantly done this as I'd made a new systemd script in /usr/systemd but still came up with these errors. I figured since the systemd script referenced the systemv one, that's why it was causing the errors and so I added these lines in the systemv script. Didn't realise systemd was automatically converting systemv scripts into systemd ones. – Luke Moll Sep 3 '16 at 18:18
  • see wiki.debian.org/LSBInitScripts – nick fox Feb 14 '18 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.