1

I have init script which works fine. On a good day It will do all the following;

/etc/init.d/my-good-script.sh {start|stop|status|info|check|config|timetravel}

Now since systemd is the new norm, I want to translate my-good-script.sh into a Systemd Service File

I found an online example like the following;

[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/usr/sbin/postfix start
ExecReload=/usr/sbin/postfix reload
ExecStop=/usr/sbin/postfix stop

[Install]
WantedBy=multi-user.target

Followed it and was able to do;

systemctl {start|stop|status} my-good-script

But I am not very sure how to do;

systemctl {info|check|config|timetravel} my-good-script

Is this even possible or what is the workaround?

1 Answer 1

1

No, custom service actions are not supported. Instead these should be done as an external script, just a plain old /usr/bin/my-script-ctl that accepts the necessary subcommands.


If you wrote the daemon/service itself, then certain things, e.g. "current status", can be done using systemd's built-in functions. For example, the sd_notify() C function will pass a short line that will be shown in systemctl status yourservice (live examples: systemd-timesyncd, systemd-udevd, org.cups.cupsd).

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (...)
   Active: active (running) since ...
   Status: "Synchronized to time server 81.29.25.50:123 (2.arch.pool.ntp.org)."

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .