0

I'm using Debian Jessie and when I'm trying to use some script from init.d (start, stop, restart). There are functions log_failure_msg log_daemon_msg log_end_msg which should give something on standard output, but it doesn't. In older version of Debian I remember it works normally. Even if trying to use failed script, it always get the same output:

kuban@lenovo-y510p:/etc/init.d$ sudo /etc/init.d/parstart restart

[ ok ] Restarting parstart (via systemctl): parstart.service.

1

I'm trying to use some script from init.d […]

Don't run scripts in /etc/init.d/ directly.

On systemd operating systems there's no guarantee that those scripts even exist, let alone that they are what are specifying your service. Even on Debian 7, there were systemd units supplanting System 5 rc scripts; and this is more so on Debian 8. The correct commands to use are:

  • systemctl with its status, start, stop, enable, and disable subcommands
  • service
  • update-rc.d and invoke-rc.d, but only if you are a package maintainer script

This is exactly what's happening to you. Your direct invocation of the script is being replaced, via a hook inside a widely used Debian library of scripting functions, with an invocation of (in this particular case)

systemctl restart parstart.service

You can even see this in the output in front of you. It's what the (via systemctl): parstart.service means. And clearly, far from failing it is succeeding in telling systemd to restart the service.

The interactive bells and whistles inside your rc script, including coloured messages, are no longer effective. Your service is not run as a child process of systemctl. It is run as a child process of systemd and has zero connection with the terminal at which you are interactively running commands.

All of that /etc/szarp/parstart.cfg scaffolding and log message generation is entirely unnecessary with systemd, anyway. systemd provides cross-service mechanisms for enabling and disabling services, and for auto-restarting them. It logs when it starts and stops services, without need for the services to do that. By my count, that rc script is quite simply replaceable by 16 ordinary .service units, one for each service. Here's what one would look like:

[Unit]
Description=The SZARP pserver-lite server
After=network.target 

[Service]
Type=simple
ExecStart=/usr/local/bin/pserver-lite --no-daemon

[Install]
WantedBy=multi-user.target

Call that /usr/local/etc/systemd/system/pserver-lite.service, run systemctl daemon-reload, and …

  • … there's status information available with systemctl status pserver-lite.service.
  • … you enable it for running at bootstrap with systemctl enable pserver-lite.service.
  • … you can see systemd's log entries for starting and stopping it with journalctl.

It's pretty much that easy for the other 15.

Further reading

  • so there is no way to get something out on terminal during restarting, just checking status after it? – Patryk Dec 22 '15 at 21:44

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.