Wednesday, December 24, 2014

systemd

After recently upgrading an ancient system, I realized that my custom init scripts don't quite start in the same (kludged) order now that my Fedora box is using systemd.  So, a quick update is in order.

Jumping into man systemd and systemctl isn't particularly enlightening.

Helpful sites are:
http://www.linux.com/learn/tutorials/788613-understanding-and-using-systemd
man systemd.service



Create /usr/lib/systemd/system/[thingy].service.  This is the master holding place for configs and init.

To get things to start automatically at boot, symlink:
ln -s /usr/lib/systemd/system/[thing].service /etc/systemd/system/[thing].service

Edit /usr/lib/systemd/system/[thingy].service:

[Unit]
Description=Network Stuff
After=syslog.target network.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/[thingy] start

[Install]
WantedBy=multi-user.target


For a more persistent service:

[Unit]
Description=Network Stuff
After=syslog.target network.target

[Service]
Type=forking   (could be simple if the process does not fork)
ExecStart=/usr/local/sbin/[thingy] start
PIDFile=/var/run/blah.pid

[Install]
WantedBy=multi-user.target




To activate:

systemctl daemon-reload
systemctl enable [thingy]

To see status:

systemctl list-unit-files --type=service
systemctl status [thingy]


No comments: