OSMC + MySQL going through a VPN to a remote server

Hi,

I’ve installed OSMC on a Pi for my siblings, which is remotly located.

My Synology NAS at my home have a VPN server and the PI is connecting on it through VPN. I have access to every from my NAS to the Pi, this is zorking great.

At my place on my local network, I have a PI on OSMC too, and a computer with Kodi. I’m using a synchronized database on my NAS with mySQL/MariaDB.

Unfortunatly, I can’t connect to the database with the remote PI, because the configuration file advancedsettings.xml launchs at startup, before the VPN connection is activated.

Is there any solution to delay the advancedsettings.xml a little later to wait for the VPN connexion ?

Advancedsettings.xml below,

Thank’s

<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <name>KODI-video</name>
    <host>192.168.X.XXX</host>
    <port>XXXX</port>
    <user>xxxx</user>
    <pass>xxxx</pass>
  </videodatabase>
  <musicdatabase>
    <type>mysql</type>
    <name>KODI-music</name>
    <host>192.168.X.XXX</host>
    <port>XXXX</port>
    <user>xxxx</user>
    <pass>xxxx</pass>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>false</importwatchedstate>
    <importresumepoint>false</importresumepoint>
  </videolibrary>
</advancedsettings>

I assume you’re using OpenVPN and openvpn.service as been enabled.

This is a bit experimental but please modify file /lib/systemd/system/mediacenter.service and change the line:

After = remote-fs.target network-online.target mysql.service

to

After = remote-fs.target network-online.target mysql.service openvpn@xxxxxx.service

where xxxxxx is the name of the configuration file in /etc/openvpn, without the .conf part. (So in this case it would have been named /etc/openvpn/xxxxxx.conf.)

Reboot and see if the start of Kodi is sufficiently delayed.

Thank you for the quick answer.
It doesn’t seem to work. I think because I’m using the add-on “VPN manager for OpenVPN” to connect on VPN. I don’t find a .conf in etc/openvpn but a -conf. I tried anyway but without any succes.

Is there a possibility to connect on VPN directly before launching Kodi, by configuring in the console ?

I think you’ll either need to contact the author of the add-on or “go native” and use OpenVPN without the add-on.

As a tacky fix you might add a sleep to the mediacenter service before starting kodi to delay the startup.

Hi all,

I succeeded to connect to VPn with the native method. I change the line in mediacenter.service.

The advancedsetting.xml is launched at start up and the configuration stay in the OSMC parameters, but nothing appears on my Kodi menu. There is no informations for my database from my NAS. I open the mariaDB port too on my NAS, 3307, it is not because of that.

I don?t understand. Maybe there is something else to do?

Greetings

Read the logs, they hold the answers.

Better still, post the logs here. :wink:

This is the Kodi.log, I don’t see something wrong in it … Do you want other logs?

14:39:25.374 T:1958633472  NOTICE: special://profile/ is mapped to: special://masterprofile/
14:39:25.374 T:1958633472  NOTICE: -----------------------------------------------------------------------
14:39:25.374 T:1958633472  NOTICE: Starting Kodi (17.5). Platform: Linux ARM (Thumb) 32-bit
14:39:25.374 T:1958633472  NOTICE: Using Release Kodi x32 build (version for Raspberry Pi)
14:39:25.374 T:1958633472  NOTICE: Kodi compiled Oct 29 2017 by GCC 4.9.2 for Linux ARM (Thumb) 32-bit version 3.16.39 (200743)
14:39:25.375 T:1958633472  NOTICE: Running on Open Source Media Center 2017.10-1, kernel: Linux ARM 32-bit version 4.9.29-10-osmc
14:39:25.375 T:1958633472  NOTICE: FFmpeg version/source: ffmpeg-3.1-kodi
14:39:25.375 T:1958633472  NOTICE: Host CPU: ARMv7 Processor rev 5 (v7l), 4 cores available
14:39:25.375 T:1958633472  NOTICE: ARM Features: Neon disabled
14:39:25.375 T:1958633472  NOTICE: special://xbmc/ is mapped to: /usr/share/kodi
14:39:25.375 T:1958633472  NOTICE: special://xbmcbin/ is mapped to: /usr/lib/kodi
14:39:25.375 T:1958633472  NOTICE: special://xbmcbinaddons/ is mapped to: /usr/lib/kodi/addons
14:39:25.375 T:1958633472  NOTICE: special://masterprofile/ is mapped to: /home/osmc/.kodi/userdata
14:39:25.375 T:1958633472  NOTICE: special://envhome/ is mapped to: /home/osmc
14:39:25.375 T:1958633472  NOTICE: special://home/ is mapped to: /home/osmc/.kodi
14:39:25.375 T:1958633472  NOTICE: special://temp/ is mapped to: /home/osmc/.kodi/temp
14:39:25.375 T:1958633472  NOTICE: special://logpath/ is mapped to: /home/osmc/.kodi/temp
14:39:25.376 T:1958633472  NOTICE: The executable running is: /usr/lib/kodi/kodi.bin
14:39:25.376 T:1958633472  NOTICE: Local hostname: ZABO-PI
14:39:25.376 T:1958633472  NOTICE: Log File is located: /home/osmc/.kodi/temp//kodi.log
14:39:25.376 T:1958633472  NOTICE: -----------------------------------------------------------------------
14:39:25.597 T:1958633472   ERROR: DBus: Error org.freedesktop.DBus.Error.ServiceUnknown - The name org.freedesktop.UPower was not provided by any .service files
14:39:25.626 T:1958633472  NOTICE: load settings...
14:39:25.962 T:1958633472  NOTICE: Found 2 Lists of Devices
14:39:25.963 T:1958633472  NOTICE: Enumerated PI devices:
14:39:25.963 T:1958633472  NOTICE:     Device 1
14:39:25.963 T:1958633472  NOTICE:         m_deviceName      : HDMI
14:39:25.963 T:1958633472  NOTICE:         m_displayName     : HDMI
14:39:25.963 T:1958633472  NOTICE:         m_displayNameExtra:
14:39:25.963 T:1958633472  NOTICE:         m_deviceType      : AE_DEVTYPE_HDMI
14:39:25.963 T:1958633472  NOTICE:         m_channels        : FL,FR
14:39:25.963 T:1958633472  NOTICE:         m_sampleRates     : 8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000
14:39:25.964 T:1958633472  NOTICE:         m_dataFormats     : AE_FMT_FLOAT,AE_FMT_S32NE,AE_FMT_S16NE,AE_FMT_S32LE,AE_FMT_S16LE,AE_FMT_FLOATP,AE_FMT_S32NEP,AE_FMT_S16NEP,AE_FMT_RAW
14:39:25.964 T:1958633472  NOTICE:         m_streamTypes     : STREAM_TYPE_AC3,STREAM_TYPE_EAC3,STREAM_TYPE_DTSHD_CORE,STREAM_TYPE_DTS_2048,STREAM_TYPE_DTS_1024,STREAM_TYPE_DTS_512
14:39:25.964 T:1958633472  NOTICE:     Device 2
14:39:25.964 T:1958633472  NOTICE:         m_deviceName      : Analogue
14:39:25.964 T:1958633472  NOTICE:         m_displayName     : Analogue
14:39:25.964 T:1958633472  NOTICE:         m_displayNameExtra:
14:39:25.964 T:1958633472  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
14:39:25.964 T:1958633472  NOTICE:         m_channels        : FL,FR
14:39:25.964 T:1958633472  NOTICE:         m_sampleRates     : 48000
14:39:25.964 T:1958633472  NOTICE:         m_dataFormats     : AE_FMT_FLOAT,AE_FMT_S32LE,AE_FMT_S16LE,AE_FMT_FLOATP,AE_FMT_S32NEP,AE_FMT_S16NEP
14:39:25.964 T:1958633472  NOTICE:         m_streamTypes     : No passthrough capabilities
14:39:25.964 T:1958633472  NOTICE:     Device 3
14:39:25.964 T:1958633472  NOTICE:         m_deviceName      : Both
14:39:25.964 T:1958633472  NOTICE:         m_displayName     : HDMI and Analogue
14:39:25.964 T:1958633472  NOTICE:         m_displayNameExtra:
14:39:25.965 T:1958633472  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
14:39:25.965 T:1958633472  NOTICE:         m_channels        : FL,FR
14:39:25.965 T:1958633472  NOTICE:         m_sampleRates     : 48000
14:39:25.965 T:1958633472  NOTICE:         m_dataFormats     : AE_FMT_FLOAT,AE_FMT_S32LE,AE_FMT_S16LE,AE_FMT_FLOATP,AE_FMT_S32NEP,AE_FMT_S16NEP
14:39:25.965 T:1958633472  NOTICE:         m_streamTypes     : No passthrough capabilities
14:39:25.965 T:1958633472  NOTICE: Enumerated ALSA devices:
14:39:25.965 T:1958633472  NOTICE:     Device 1
14:39:25.965 T:1958633472  NOTICE:         m_deviceName      : @
14:39:25.965 T:1958633472  NOTICE:         m_displayName     : Default (bcm2835 ALSA bcm2835 ALSA)
14:39:25.965 T:1958633472  NOTICE:         m_displayNameExtra:
14:39:25.965 T:1958633472  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
14:39:25.965 T:1958633472  NOTICE:         m_channels        : FL,FR
14:39:25.965 T:1958633472  NOTICE:         m_sampleRates     : 8000,11025,16000,22050,32000,44100,48000
14:39:25.965 T:1958633472  NOTICE:         m_dataFormats     : AE_FMT_S16NE,AE_FMT_S16LE,AE_FMT_U8
14:39:25.965 T:1958633472  NOTICE:         m_streamTypes     : No passthrough capabilities
14:39:25.997 T:1958633472  NOTICE: Loaded settings file from special://xbmc/system/advancedsettings.xml
14:39:25.998 T:1958633472  NOTICE: Contents of special://xbmc/system/advancedsettings.xml are...
                                        <?xml version="1.0" encoding="UTF-8" ?>
                                        <!-- Do not modify! These are OSMC Optimised Settings for your device  !-->
                                        <!-- If you wish to override any of these values, then create a file in /home/osmc/.kodi/userdata/advancedsettings.xml !-->
                                        <!-- It will override these settings, and your settings will be preserved across OSMC updates !-->
                                        <advancedsettings>
                                          <imageres>540</imageres>
                                          <fanartres>720</fanartres>
                                          <splash>false</splash>
                                          <handlemounting>0</handlemounting>
                                          <samba>
                                            <clienttimeout>30</clienttimeout>
                                          </samba>
                                        </advancedsettings>
14:39:26.004 T:1958633472  NOTICE: Loaded settings file from special://profile/advancedsettings.xml
14:39:26.004 T:1958633472  NOTICE: Contents of special://profile/advancedsettings.xml are...
                                        <?xml version="1.0" encoding="utf-8" ?>
                                        <advancedsettings>
                                          <videodatabase>
                                            <name>KODI-video</name>
                                            <host>XX.XX.XX.XX</host>
                                            <user>kodi</user>
                                            <pass>*****</pass>
                                            <type>mysql</type>
                                            <port>3307</port>
                                          </videodatabase>
                                          <musicdatabase>
                                            <name>KODI-music</name>
                                            <host>XX.XX.XX.XX</host>
                                            <user>kodi</user>
                                            <pass>*****</pass>
                                            <type>mysql</type>
                                            <port>3307</port>
                                          </musicdatabase>
                                          <videolibrary>
                                            <importwatchedstate>true</importwatchedstate>
                                            <importresumepoint>true</importresumepoint>
                                          </videolibrary>
                                        </advancedsettings>
14:39:26.004 T:1958633472 WARNING: VIDEO database configuration is experimental.
14:39:26.006 T:1958633472  NOTICE: Default Video Player: VideoPlayer
14:39:26.007 T:1958633472  NOTICE: Default Audio Player: paplayer
14:39:26.007 T:1958633472  NOTICE: Disabled debug logging due to GUI setting. Level 0.
14:39:26.007 T:1958633472  NOTICE: Log level changed to "LOG_LEVEL_NORMAL"
14:39:26.007 T:1958633472  NOTICE: CMediaSourceSettings: loading media sources from special://masterprofile/sources.xml
14:39:26.010 T:1958633472  NOTICE: Loading player core factory settings from special://xbmc/system/playercorefactory.xml.
14:39:26.018 T:1958633472  NOTICE: Loaded playercorefactory configuration
14:39:26.019 T:1958633472  NOTICE: Loading player core factory settings from special://masterprofile/playercorefactory.xml.
14:39:26.019 T:1958633472  NOTICE: special://masterprofile/playercorefactory.xml does not exist. Skipping.
14:39:26.326 T:1958633472  NOTICE: Running database version Addons27
14:39:28.099 T:1958633472  NOTICE: ADDONS: Using repository repository.xbmc.org
14:39:28.099 T:1958633472  NOTICE: ADDONS: Using repository repository.zomboided.plugins
14:39:28.099 T:1958633472  NOTICE: ADDONS: Using repository repository.xvbmc
14:39:28.224 T:1958633472 WARNING: Unable to resolve: /inputstream.rtmp.so.1.0.4.SC get_addon, reason: /home/osmc/.kodi/addons/inputstream.rtmp/inputstream.rtmp.so.1.0.4.SC: undefined symbol: get_addon
14:39:28.225 T:1958633472   ERROR: Unable to resolve exports from dll /home/osmc/.kodi/addons/inputstream.rtmp/inputstream.rtmp.so.1.0.4.SC
14:39:29.047 T:1958633472  NOTICE: Raspberry PI firmware version: Sep 22 2017 21:36:43 
                                        Copyright (c) 2012 Broadcom
                                        version f5217b8887607d0dd890a434de9c73d9aa9a7c0f (clean) (release)
14:39:29.048 T:1958633472  NOTICE: ARM mem: 752MB GPU mem: 256MB MPG2:0 WVC1:0
14:39:29.048 T:1958633472  NOTICE: cache.memorysize: 20MB libass.cache: 0MB
14:39:29.050 T:1958633472  NOTICE: Config:
                                        arm_freq=900
                                        audio_pwm_mode=1
                                        config_hdmi_boost=5
                                        disable_commandline_tags=2
                                        disable_l2cache=1
                                        disable_splash=1
                                        enable_uart=1
                                        force_eeprom_read=1
                                        force_pwm_open=1
                                        framebuffer_ignore_alpha=1
                                        framebuffer_swap=1
                                        hdmi_channel_map=8
                                        hdmi_force_cec_address=65535
                                        hdmi_force_hotplug=1
                                        hdmi_ignore_cec_init=1
                                        init_uart_clock=0x2dc6c00
                                        lcd_framerate=60
                                        over_voltage_avs=0x1b774
                                        over_voltage_avs_boost=0x1e848
                                        pause_burst_frames=1
                                        program_serial_random=1
                                        sdram_freq=450
                                        sdtv_aspect=1
                                        second_boot=1
                                        temp_limit=85
14:39:29.051 T:1958633472  NOTICE: Config:
                                        device_tree=-
14:39:29.072 T:1958633472  NOTICE: InitWindowSystem: Using EGL Implementation: raspberrypi
14:39:29.077 T:1958633472  NOTICE: Found resolution 640 x 480 for display 0 with 640 x 480 @ 60.000000 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 640 x 480 for display 0 with 640 x 480 @ 59.940063 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 800 x 600 for display 0 with 800 x 600 @ 60.000000 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 800 x 600 for display 0 with 800 x 600 @ 59.940063 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 1024 x 768 for display 0 with 1024 x 768 @ 60.000000 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 1024 x 768 for display 0 with 1024 x 768 @ 59.940063 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 1280 x 1024 for display 0 with 1280 x 1024 @ 60.000000 Hz
14:39:29.077 T:1958633472  NOTICE: Found resolution 1280 x 1024 for display 0 with 1280 x 1024 @ 59.940063 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 720 x 480 for display 0 with 720 x 480 @ 60.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 720 x 480 for display 0 with 720 x 480 @ 59.940063 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1280 x 720 for display 0 with 1280 x 720 @ 60.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1280 x 720 for display 0 with 1280 x 720 @ 59.940063 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1920 x 1080 for display 0 with 1920 x 1080 @ 60.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1920 x 1080 for display 0 with 1920 x 1080 @ 59.940063 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 720 x 576 for display 0 with 720 x 576 @ 50.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1280 x 720 for display 0 with 1280 x 720 @ 50.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1920 x 1080 for display 0 with 1920 x 1080 @ 50.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1920 x 1080 for display 0 with 1920 x 1080 @ 24.000000 Hz
14:39:29.078 T:1958633472  NOTICE: Found resolution 1920 x 1080 for display 0 with 1920 x 1080 @ 23.976025 Hz
14:39:29.078 T:1958633472  NOTICE: Found (1920x1080@60.000000) at 28, setting to RES_DESKTOP at 16
14:39:29.079 T:1958633472  NOTICE: Checking resolution 16
14:39:29.409 T:1958633472  NOTICE: GL_VENDOR = Broadcom
14:39:29.409 T:1958633472  NOTICE: GL_RENDERER = VideoCore IV HW
14:39:29.409 T:1958633472  NOTICE: GL_VERSION = OpenGL ES 2.0
14:39:29.409 T:1958633472  NOTICE: GL_SHADING_LANGUAGE_VERSION = OpenGL ES GLSL ES 1.00
14:39:29.409 T:1958633472  NOTICE: GL_EXTENSIONS = GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_texture_npot GL_OES_depth24 GL_OES_vertex_half_float GL_OES_EGL_image GL_OES_EGL_image_external GL_EXT_discard_framebuffer GL_OES_rgb8_rgba8 GL_OES_depth32 GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_APPLE_rgb_422 GL_EXT_debug_marker
14:39:32.123 T:1937765360  NOTICE: Running database version Addons27
14:39:32.128 T:1937765360  NOTICE: Running database version ViewModes6
14:39:32.134 T:1937765360  NOTICE: Running database version Textures13
14:39:32.161 T:1830810608  NOTICE: Register - new cec device registered on cec->RPI: CEC Adapter (2708:1001)
14:39:34.500 T:1937765360  NOTICE: Running database version KODI-music60
14:39:37.565 T:1937765360  NOTICE: Running database version KODI-video107
14:39:37.602 T:1937765360  NOTICE: Running database version TV29
14:39:37.605 T:1937765360  NOTICE: Running database version Epg11
14:39:37.609 T:1958633472  NOTICE: start dvd mediatype detection
14:39:40.077 T:1958633472 WARNING: JSONRPC: Could not parse type "Setting.Details.SettingList"
14:39:49.965 T:1958633472  NOTICE: initialize done
14:39:49.965 T:1958633472  NOTICE: Running the application...
14:39:49.976 T:1958633472  NOTICE: starting zeroconf publishing
14:39:49.977 T:1958633472  NOTICE: CWebServer[8080]: Started
14:39:49.977 T:1958633472  NOTICE: starting upnp client
14:39:49.983 T:1605366768  NOTICE: ES: Starting UDP Event server on port 9777
14:39:49.983 T:1605366768  NOTICE: UDP: Listening on port 9777 (ipv6 : true)
14:39:59.978 T:1689252848   ERROR: EXCEPTION: Unknown addon id 'repository.colossus'.
14:39:59.996 T:1689252848  NOTICE: [Covenant] ######################### COVENANT ############################
14:39:59.996 T:1689252848  NOTICE: [Covenant] ####### CURRENT COVENANT VERSIONS REPORT ######################
14:39:59.996 T:1689252848  NOTICE: [Covenant] ### ERROR GETTING COVENANT VERSIONS - NO HELP WILL BE GIVEN AS THIS IS NOT AN OFFICIAL COVENANT INSTALL. ###
14:39:59.996 T:1689252848  NOTICE: [Covenant] ###############################################################
14:39:59.998 T:1680864240  NOTICE: [plugin.video.youtube] Startup: detected Krypton (Kodi-17.5), setting DASH_SUPPORT_BUILTIN = False, DASH_SUPPORT_ADDON = True
14:40:06.913 T:1734341616 WARNING: CSkinInfo: failed to load skin settings
14:40:13.253 T:1805472752   ERROR: OnTvStandby - Unexpected [standby_pc_on_tv_standby] setting value
14:42:52.427 T:1937765360 WARNING: CSkinInfo: failed to load skin settings
14:42:58.314 T:1958633472  NOTICE: VideoPlayer: Opening: http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/b1-4.mov
14:42:58.314 T:1958633472 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
14:42:58.414 T:1567364080  NOTICE: Creating InputStream
14:42:59.043 T:1567364080  NOTICE: Creating Demuxer
14:43:00.502 T:1567364080  NOTICE: Opening stream: 0 source: 256
14:43:00.502 T:1567364080  NOTICE: Creating video codec with codec id: 28
14:43:00.525 T:1567364080  NOTICE: Creating video thread
14:43:00.525 T:1471149040  NOTICE: running thread: video_thread
14:43:01.196 T:1567364080 WARNING: CDVDMessageQueue(audio)::Put MSGQ_NOT_INITIALIZED
14:44:07.829 T:1471149040 WARNING: CRenderManager::WaitForBuffer - timeout waiting for buffer
14:45:04.564 T:1918890992 WARNING: Previous line repeats 1 times.
14:45:04.565 T:1918890992  NOTICE: CAESinkPi:AddPackets Underrun (delay:0.00 frames:2205)

Run grab-logs -A and post the URL it returns.

I didn’t know that command. Here they are. https://paste.osmc.tv/fetuyuxifo

1 Please set “Wait for network” in My OSMC > Network.

2 Run:

cat /lib/systemd/system/mediacenter.service
ls -l /etc/openvpn

1 Please set “Wait for network” in My OSMC > Network.

It is activated at every start up.

2 Run:

cat /lib/systemd/system/mediacenter.service
ls -l /etc/openvpn

Results :

osmc@ZABO-PI:~$ cat /lib/systemd/system/mediacenter.service
[Unit]
Description = media center application
After = remote-fs.target network-online.target mysql.service openvpn@vpn.service
Wants = network-online.target

[Service]
Type = simple
TimeoutStopSec = 20
ExecStart = /usr/bin/mediacenter
ExecStopPost = /usr/bin/mediacenter stop
Restart = on-abort

[Install]
WantedBy = multi-user.target

osmc@ZABO-PI:~$ ls -l /etc/openvpn
total 8
-rwxr-xr-x 1 root root 1301 Jun 26  2017 update-resolv-conf
-rwxr--r-- 1 root root 2432 Dec 27 01:16 vpn.conf
osmc@ZABO-PI:~$

I think another method will be necessary. Again, this has to be experimental, so it would be best if you have another Linux PC on which you can edit the SD card if things go wrong. It’s a bit of a hack but might just work for you.

First, you’ll need to create a directory:

sudo mkdir /lib/systemd/system/mediacenter.service.d

then create a file:

sudo nano /lib/systemd/system/mediacenter.service.d/wait-for-tun0.conf

Paste these two lines into the file:

[Service]
ExecStartPre = /usr/local/bin/wait-for-tun0.sh

Save, then create the shell script:

sudo edit /usr/local/bin/wait-for-tun0.sh

and paste this code into it:

#!/bin/bash
count=60
while [ $count -gt 0 ]; do
  if $(ip link show tun0 >/dev/null 2>&1); then break; fi
  sleep 1
  let count-=1
done
sleep 5

Save, and then run:

sudo chmod u+x /usr/local/bin/wait-for-tun0.sh

It simply delays the start of Kodi for up to 60 seconds until tun0 has been created then adds a further 5 seconds for any further routing commands. (I did say it is a bit hacky!)

I can"t use sudo edit, so I used sudo nano.

It doesn"t seem to work neither. The pi starts in less than a minute

Please see the logs : https://paste.osmc.tv/eqopucavug

Oops. Trying to multi-task. But you figured out what I meant. :wink:

It does seem to be working, in the sense that Kodi is starting about 5 seconds after the VPN has started, which is what I was trying to do.

Dec 29 00:13:48 ZABO-PI ovpn-vpn[312]: Initialization Sequence Completed
...
Dec 29 00:13:54 ZABO-PI mediacenter[629]: Starting Kodi...

I’d guess that either your VPN is having a few problems or your Kodi configuration needs to be fixed.

Ok, I will try that on a clean installation at my place. I have a dual boot OSMC/Retropie on this one…

Thank’s for you help

Hi all and happy new year!

I took a new microsd card an made a fresh install without the dual boot and it worked perfectly! Thank’s for you help!

I will try now to make it work with the dual boot from OSMC-Retropie. UPDATE : Working well too!!

In addition, is it possible that some services doesn’t pass trough the VPN connection ? Like youtube and other addons ?