Sunday, April 29, 2018

systemd and rc.local

Once again while in systemd land I discovered something, how to re-re-enable rc.local. Granted, from what I’ve read rc.local should really go the way of the dodo but I don’t feel like writing the new systemd stuff.

Link here.

To summarize it up:

The solution 

As you can see from above, The unit file have no [Install] section. As such Systemd can not enable it. First we need to create a file:

sudo vi /etc/systemd/system/rc-local.service

Then add the following content to it.

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Save and close the file. Make sure /etc/rc.local file is executable.

sudo chmod +x /etc/rc.local

After that, enable the service on system boot:

sudo systemctl enable rc-local

Output:

Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /etc/systemd/system/rc-local.service.

Now start the service and check its status:

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

No comments:

Post a Comment

Current Audible Reading List

Title You Never Forget Your First: A Biography of George Washington A Self-Made Man: The Politica...