problem with rc.local

Sep 19, 2022 1 Replies

rc.local seems not be called anymore at boot. Annoying permissions on rc.locale are read and execute for all. rc.local can be executed from comd line by root.



running service .. service rc.local start Warning: The unit file, source configuration file or drop-ins of rc.local.service changed on disk. Run 'systemctl daemon-reload' to reload units. root@raspizw:~# systemctl daemon-reload root@raspizw:~# root@raspizw:~# service rc.local start root@raspizw:~#



But not started!!


For Raspbian (before it became RPi OS), this is the sequence that I worked out to do it, as my introduction to Systemd. Implemented as a Bash script. It convinced me that Systemd is overcomplicated and encouraged me to avoid it since.

#!/bin/bash #Enable execution of rc.local on start-up with Systemd:

chmod a+x /etc/rc.local

echo "Updating /etc/systemd/system/rc-local.service" cat > /etc/systemd/system/rc-local.service <<EOF [Unit]

Description=Runs /etc/rc.local After=multi-user.target

[Service]

Type=simple ExecStart=/etc/rc.local

[Install]

WantedBy=rc-local.target EOF

echo "Updating /etc/systemd/system/rc-local.target" cat > /etc/systemd/system/rc-local.target <<EOF [Unit] Description=Run service that runs /etc/rc.local Requires=multi-user.target After=multi-user.target AllowIsolate=yes EOF

if [ -d /etc/systemd/system/rc-local.target.wants ] ; then echo "WARNING: /etc/systemd/system/rc-local.target.wants already exists" else if mkdir /etc/systemd/system/rc-local.target.wants; then ln -s /etc/systemd/system/rc-local.service /etc/systemd/system/rc-local.target.wants/rc-local.service systemctl daemon-reload systemctl set-default rc-local.target echo "Reboot now to enable new system configuration" exit 0 else echo "Failed to set up rc.local with Systemd" exit 1 fi fi

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required