I apologize if there is a similar post but if there is I couldn’t find anything relevant.
I would like to run a script at boot to turn osmc into a router/gw like I’m doing on my ubuntu vm, and add a few static routes as well when the system boots.
I’m however failing to find a place that runs the script when the system boots.
I tried /etc/rc.local by that doesn’t work.
In ubuntu I have a symbolic link SXX_Script in /etc/rc2.d/ and that works just fine but in OSMC that doesn’t work cause I think rc is not really implemented as I noticed scripts are run still by systemctl
example restarting transmission (which has entries in rc*.d):
sudo /etc/init.d/transmission-daemon restart
[ ok ] Restarting transmission-daemon (via systemctl): transmission-daemon.service.
Transmission for example starts at boot but is it started by the script in rc*.d or is it something else starting it at system boot?
Thanks for your help in advance.
Well I fixed it, the main problem is my script was that it was running too early and the routes weren’t being added because the network wasn’t up yet I think. (command “sleep 10” to delay it fixed that).
in the mean while I found out how to use systemctl (couple of useful links):
I now got it working with both rc.local and by creating it’s own sevice file.
You can create a service by
- Creating a file “script.service” in “/etc/systemd/system/”
- Enter the following in “script.service” for example:
After = remote-fs.target network-online.target
- Run the command “sudo systemctl enable script.service” to enable auto-start at boot or “sudo systemctl disable script.service” to disable it from auto-starting at boot.
Please Note: If you are running a shell script make sure you have #!/bin/sh as the first line of your script or it won’t start.