Replacement for rc.local
rc.local is a very convenient method of firing off a process when the system is booted. It is being phased out.
To replace it you can do the following:
create a file named /usr/lib/systemd/system/StartupService.serviceĀ
[Service]
Type=forking
TimeoutSec=0
RemainAfterExit=yes
ExecStart=/usr/local/sbin/StartupScript start
[Unit]
Description=rc.local replacement
CondidtionFileIsExecutable=/usr/local/sbin/StartupScript
After=network-online.target
Wants=network-online.target
[Install]
WantedBy=multi-user.target
replace /usr/local/sbin/StartupScript with whatever binary or script you want to run on boot
now execute:
systemctl enable StartupService
The lines:
After=network-online.target
Wants=network-online.target
causes it to wait to start the targeted script until after the network is started
This was tested on Fedora 33