Start script to start a mount and VPN

I wish to make a start script, you know, like an init.d script.
I have tried this before on other systems, and it worked.
It seems I can not create a init.d-like script on a Raspberry Pi with OSMC and get that to run at boot.

Can anyone please help out?

OSMC will respect init.d scripts, but we recommend systemd units.


hmm… I tried with init scripts. Does not work. It just does not execute at boot, AT ALL.
Would you please be so kind to give a step by step instruction?
It should be a script that should be started after the network interface comes up.

If you’re only familiar with legacy sysv init scripts I’d suggest you take a little time to read up on systemd services, here is some documentation for it, check the examples near the bottom:

There is quite a lot of good documentation for systemd on the internet and while it might seem strange and new once you start to get the hang of it it really does make sense, and in particular it’s much easier to write a service unit from scratch as there is no “boilerplate” code needed like there is with traditional sysv init scripts that are often 80% boilerplate, 20% code to do what you want. In fact a systemd service unit is not really a script at all, just the name of a program or script to run and a few options.

We can point you in the right general direction but it’s a bit much (in terms of time) to expect us to work out step by step instructions for you to achieve some arbitrary goal…

Actually, I read a similar document, and tried this also.
Wrote a script. However, it does not run at boot. That’s why I am confused. How can we debug that?

Paste the systemd unit file you wrote and I will see if there is any obvious problem with it.

Did you remember to enable the service after creating it ?

To start my vpn on boot all I did was edit the rc.local file. You can find it in /etc/ directory. I used Putty to ssh into my apple tv and then ran “sudo nano /etc/rc.local”

This is what I put in the file to make it start using a vpn connected to the US midwest.

sleep 10
sudo openvpn /home/osmc/vpn-config/USMidwest.ovpn

Hope that helps.