[systemd-devel] How to get used to systemd vs init
Ronny Chevalier
chevalier.ronny at gmail.com
Tue Jun 23 16:45:05 PDT 2015
On Wed, Jun 24, 2015 at 1:37 AM, Chad <ccolumbu at gmail.com> wrote:
> Oh, wait this is the reverse of what I want/need (systemd-sysv-generator
> goes from init.d to systemd, I need from systemd to init.d).
> I have a nagios script that runs something like:
> /etc/init.d/httpd status
> It then reads the output and makes sure httpd is running, if not it takes
> action depending on the service.
> I use that method for tons of services.
> I don't want to have to re-write the modules to use:
> systemctl status httpd
> If I did that then I will not be able to rsync the scripts/configs around
> and would have to maintain 2 versions of the code.
> I was wondering if there was an easy way to create a /etc/init.d/httpd
> script that called something like this inside:
> #!/bin/bash
> systemctl $1 $0
> I know it is not that simple ($0 for example is the full path
> /etc/init.d/httpd not just the httpd), which is why I am hoping there is a
> tool for this.
>
If you just want to know if a service is active you can use:
systemctl is-active httpd
If $? equals 0 then the service is active, else it is not :)
If you make your script use this I don't see why you would have to
maintain multiple versions, if your intention is to use systemd
everywhere.
More information about the systemd-devel
mailing list