Startup really confuses me. It seems various methods for starting things happen in different locations all over the place. But is there a way to define the order they are loaded?

Specifically... I have an issue where Plex Media Server (PMS) can't be discovered by clients if the server's VPN connection is established prior PMS starting. It was driving me nuts, but I discovered that I could solve the problem by shutting down PMS, shutting down the VPN, turning on PMS and then turning on VPN.

I'm not exactly sure how PMS auto-loads itself at startup, but the VPN is something I defined by editing: /etc/network/if-up.d/slickvpn with the following:

#! /bin/bash


activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
    nmcli con up id "${VPN_CONNECTION_NAME}"

That's a script I found somewhere (I think on this site) when looking for help autoconnecting a VPN.

So I guess /etc/network/if-up.d/ scripts are initiated prior to the PMS service. How can I flip that? Or other solution?


I think you may want to give upstart a try instead. You can stop the VPN server from starting in the ifupdown scripts (moving the file somewhere else) then make some upstart jobs.

Create (or modify if it's already existing, you should search in /etc/init) the PMS start up file in /etc/init and fill it up (**if it's already present, just take note of the name of the .conf file):

# pms - Plex Media Server

description "Plex Media Server"

start on (local-filesystems and net-device-up IFACE!=lo)
## here you can define what interface you can wait, just change IFACE!=lo for IFACE=eth0, etc.

## This stops the job at shutdown
stop on runlevel [!2345]

    exec /path/to/pms/server/binar
end script

This is very basic upstart script. You should add/modify things around. Now the other script:

Create the /etc/init/vpn.conf file and fill it with the following content

# vpn - Virtual Private Network server

description "Virtual Private Network server"

start on started plexmediaserver
## now, the VPN server will only start if PMS starts :D

## This stops the job at shutdown you can modify it and make it to stop before stoping PMS
stop on runlevel [!2345]

env REQUIRED_CONNECTION_NAME="Wired connection 1"


    exec /usr/bin/nmcli con up id "${VPN_CONNECTION_NAME}"
end script


  • Can you clarify that the first code section should be in /etc/init/plexmediaserver.conf and that you're suggesting I move /etc/init.d/plexmediaserver [where?]? Thanks. – bcsteeve Nov 9 '13 at 21:13
  • If the file is already in /etc/init you don't need to do anything. The second one may need modification (changing start on started pms for start on started plexmediaserver`). If the first file is present, you don't need to do anything with it. – Braiam Nov 9 '13 at 21:45
  • Understood, thank you. Got it working! Yes, had to change from "pms" to "plexmediaserver". Suggest you change that in your answer, or (if its not universal) note that it must match the name of the PMS service. Thanks again! – bcsteeve Nov 9 '13 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.