Не работает /etc/rc.local на Debian 9

Оказывается, его тупо нет, и просто создать файл /etc/rc.local недостаточно.

https://www.itechlounge.net/2017/10/linux-how-to-add-rc-local-in-debian-9/

On Debian 9, the traditional “rc.local” has been deprecated. For traditional Linux users and administrators, there is a way to get it back using SystemD. See the procedure below :

1. Edit the non-existing file “rc-local.service”:

nano /etc/systemd/system/rc-local.service

1.1. Add the following content to “/etc/systemd/system/rc-local.service”:

[Unit]
Description=/etc/rc.local
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
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

2. Edit the “rc.local” file:

nano /etc/rc.local

2.1. Append the generic content below and save the file:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0

3. Change permissions :

chmod +x /etc/rc.local

4. Enable the “rc-local” script on boot:

systemctl enable rc-local

5. Start the “rc-local” script :

systemctl start rc-local.service

6. Check if any error occurred while starting the service:

systemctl status rc-local.service

You may now append anything you’d like to the traditional “rc.local”.

Leave a Reply

Your email address will not be published. *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>