Accessing library via OpenVPN on boot

I am going to build an OSMC media player using an RPi4B device.
This will be located at a friend’s home and I want it to use the video library on my home server.
So my plan is to set the RPi4 up with OSMC and OpenVPN such that it will connect to the VPN on boot.
Then I also need to mount the video source, which is an NFS share on the Ubuntu server.

This is ordinarily not a big problem except in this case I am wondering if the OSMC box will delay the mount-on-boot until the VPN connect-on-boot is ready?

I define this mount via an entry in /etc/fstab file using the IP address of the server which is only accessible when the VPN is connected.

Is there a way to synchronize the VPN connection and the mount operation such that the mount only happens after the VPN connection is up?

Or can I make OSMC itself manage the mount operation and defer until the VPN is up?

EDIT:
Additional question regarding WiFi
How can I prepare the RPi4 device running OSMC such that it will connect properly to WiFi when it arrives at the target location?
I usually do this by editing the /etc/wpasupplicant/wpasupplicant.conf file and adding the logins for the different WiFi network it will encounter.
But now when I looked into /etc/wpasupplicant/ there is no such file, instead two shellscript files action_wpa.sh and ifupdown.sh
So how can I do this on the new RPi4B OSMC device?

I asked the second question 8 years ago here and got a “no it cannot be done” reply… :frowning:

Is this really the case still? I cannot understand that because it would make it so simple to be able to configure the WiFi while setting up the device and it would just work when arriving on location.

So is it still the case that this reply in the other thread is still true?

OSMC uses connman for the network manager.

You can’t edit configuration files to “pre-configure” a wireless network with connman. The command line tool for configuring connman is connmanctl but it does not allow pre-configuration of a network that you don’t yet have available.

You can do it for a fresh installation with the OSMC installer
Alternatively you can create a file as follows:

/var/lib/connman/wifi.config:

[service_wifi]                          
Type=wifi                                          
IPv4=dhcp                                                
Name=*SSID*                     
Passphrase=*WIFIPASSWORD*

Thanks for that, very useful. I am going to send the device to my friend when it is done and hope that it will connect there 600 km away…
So having the SSID/passphrase entered there will be needed.

I have looked at my last configured RPi4B OSMC device and there is a file in a subdir, which contains connection data but unfortunately not very useful:
/var/lib/connman/wifi_e45f019ac055_626f7373656669626572_managed_psk/settings

With this content:

[wifi_e45f019ac055_626f7373656669626572_managed_psk]
Name=myhomewifi
SSID=626f7373656669626572
Frequency=5320
Favorite=true
AutoConnect=true
Modified=2023-12-11T17:17:09Z
Passphrase=**********
IPv4.method=dhcp
IPv4.DHCP.LastAddress=192.168.119.247
IPv6.method=off
IPv6.privacy=disabled

I am now preparing for creating the new OSMC device which will be WiFi only (mine are using Ethernet or WiFi depending on LAN availability)

And concerning the nfs share connection I can use a script that checks if the share is connected and if not then run the sudo mount -a command to make that happen.
Can run by cron some time after boot.

Sorry for being off topic, but given that you roam between two locations yourself and now your looking at giving remote access to an additional location, wouldn’t it make sense to look into running Plex, Jellyfin, Emby, or some other similar server software that is a bit better suited to remote access of media? I run a Plex server on the same machine I host my media and my Kodi MySQL database and just have it set to update on its own. I can just send out invites to share my library without having to do any complicated setups and it works on a whole host of devices.

1 Like

I just installed a brand new OSMC on an RPi4B 8GB unit, getting the image using Pi-Imager.
When I look inside the /var/lib/connman/ dir I find a file named settings

The file contains this:

[global]
OfflineMode=false

[Wired]
Enable=true
Tethering=false
Tethering.Freq=2412

[Bluetooth]
Enable=false
Tethering=false
Tethering.Freq=2412

[WiFi]
Enable=false
Tethering=false
Tethering.Freq=2412

So the section [WiFi ] contains an Enable item.
Do I have to set this to true also?

I want to make it such that the device will use Ethernet if plugged into that or else WiFi if that is available and configured…

No - make the wifi config file as directed above

About the way to prepare to activate WiFi on a device which is currently not at the final location:

I have a guest network here so I figured that I could test the situation before sending to the final destination. So I created a /var/lib/connman/wifi.config file containing the data for my own guest network.
Then I pulled the network cable out and restarted the OSMC box.
I had hoped that in this case it should try to connect to the guest wifi network, but it did not. No connection at all.

The only way I could get a connection was to navigate to Settings/MyOSMC, then up to Network and select Wireless and enable adapter.
Now there is a list of networks and I could navigate to my Guest network, which it connected to without me entering the password, so it seems like it has grabbed that from the file.

Now it is on WiFi, but it is my Guest network.
And I could use the VPN to connect back home to my ordinary LAN and then autofs worked fine!!! Thanks for that!

How can I set it up such that it will connect to the other site’s WiFi if started there without having to navigate to MyOSMC etc?
Is it enough to replace the content of /var/lib/connman/wifi.config with the data for that network?
I.e.Now that it is set to use WiFi, will it then look at this file if it cannot fine the last connected SSID on air?

Why can’t the user just select the network once?

Regarding connman, when I google that I see that it is some kind of light-weight network manager intended for embedded systems…
See: ConnMan - ArchWiki

But on OSMC it seems to not be handled by apt:

$ apt policy connman
connman:
  Installed: (none)
  Candidate: 1.36-2.2+deb11u2
  Version table:
     1.36-2.2+deb11u2 500
        500 https://deb.debian.org/debian bullseye/main armhf Packages
        500 https://security.debian.org bullseye-security/main armhf Packages

Note: Installed: (none)

So is it a customized non-standard connman in use on OSMC?

I am trying to extract the currenly connected wifi SSID in a reporting script but all attempts using the methods that work on other RaspberryPi and also PC Linuxes have failed.

QUESTIONS:

  1. Using the existing connman
    Is there a connman command that can show the current state of wifi including its connected SSID?

  2. Can I install another manager just for extracting the SSID?
    For example can I install iw on OSMC in order just to be able to read the SSID into a script? Or will it break connman and MyOSMC?

  3. There is no man-page for connman either on my OSMC…

$ man connman
-bash: man: command not found

Not customized per se but a package with a different name

dpkg -l | grep -i connman
ii  armv7-connman-osmc                   1.41-2                         armhf        connman for OSMC

Why not use the iw command that was shown to you before?

iw is not a network manager so no probkem to install it. If you replace connman with another network manager (which people has done that wanted pihole to run on OSMC) you have to be careful

Man pages have been removed to make the image smaller

1 Like

connmanctl services

$ which iw
$

$ apt policy iw
iw:
  Installed: (none)
  Candidate: 5.9-3
  Version table:
     5.9-3 500
        500 https://deb.debian.org/debian bullseye/main armhf Packages

Is not installed

This is exactly why I am asking. There are so many different network oriented packages around and I am sure that if I install some of them the base networking of OSMC might be compromized…

Thanks!
THAT is finally what I am looking for:

$ connmanctl services
*AO BosseGuest           wifi_d83add1d8de9_426f7373654775657374_managed_psk

With this I can extract the SSID and report it along with the other networking info!

5 seconds google versus 5 posts in this thread

1 Like