LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Slackware current wont run my app in rc.local on boot (https://www.linuxquestions.org/questions/slackware-14/slackware-current-wont-run-my-app-in-rc-local-on-boot-4175578698/)

luckyknight 04-30-2016 01:02 PM

Slackware current wont run my app in rc.local on boot
 
I am trying to run Serviio on boot in rc.local. It's a chain where rc.local is run, running rc.serviio which then runs serviio.sh.

If I manually run /etc/rc.d/rc.local serviio fine after logging in.

Serviios logs in /usr/local/src/serviio/log are empty.
Serviio is symlink from /usr/local/src/serviio to /usr/local/src/serviio-1.6.1

Slackware is slackware-current as of April 30th 2016

Any ideas?

/etc/rc.d/rc.local permissions:

-rwxr-xr-x 1 root root 668 Apr 30 18:41 rc.local

ls -la rc.serviio
-rwxr-xr-x 1 root root 710 Jun 24 2015 rc.serviio

In rc.local - rc.serviio is called:

Code:

if [ -x /etc/rc.d/rc.serviio ]; then
        /etc/rc.d/rc.serviio start
fi

Here is my /etc/rc.d/rc.serviio

Code:

#!/bin/sh

#--------SERVIIO start-stop-status script

daemon_status ()
{
        ps | grep '^ *[0-9]* serviio' > /dev/null
}

case $1 in
        start)
                # start Serviio in background mode
                su - upnp -s /bin/sh -c "/usr/local/src/serviio/bin/serviio.sh &"
                exit 0
        ;;
        stop)
                su - upnp -s /bin/sh -c "/usr/local/src/serviio/bin/serviio.sh -stop"
                exit 0
        ;;
        status)
                if daemon_status ; then
                        exit 0
                else
                        exit 1
                fi
        ;;
        log)
        echo "/var/log/serviio.log"
                exit 0
        ;;
esac


bassmadrigal 04-30-2016 02:27 PM

Is your network fully up on boot or does it come up later in the process? It's been years since I ran serviio (and I think it was on Windows at the time), but it might exit if there isn't a network device to attach to. Then, since your network likely comes up later, it might work fine.

You can see problems like this if you are attempting to mount network drives in your fstab but your network doesn't come up before the scripts attempt to mount all drives.

Hangaber 04-30-2016 02:39 PM

Isolate which part or script is failing. Determine which of the three scripts (if any) actually runs.
On line 2 of each script, something like...
Code:

echo "This is rc.local"
(or rc.serviio or serviio.sh)

Why the 'su' instead of a plain "/usr/local/src/serviio/bin/serviio.sh &"?

bassmadrigal 04-30-2016 03:38 PM

Quote:

Originally Posted by Hangaber (Post 5538713)
Why the 'su' instead of a plain "/usr/local/src/serviio/bin/serviio.sh &"?

Many people will do this for apps that have a network socket open. It prevents the app from running with root permissions and limits security issues if the app is compromised.

Hangaber 04-30-2016 04:16 PM

Quote:

Originally Posted by bassmadrigal (Post 5538737)
It prevents the app from running with root permissions and limits security issues if the app is compromised.

Thanks. Of course! I should have known that and use it myself in a few cases. I was used to seeing the 'run as' username at the end. :)

bassmadrigal 04-30-2016 05:20 PM

Another thing I thought of is to see if serviio is throwing out any errors. You could append a redirect all output, including any errors to a temporary file.

Code:

su - upnp -s /bin/sh -c "/usr/local/src/serviio/bin/serviio.sh > /tmp/serviio-start.log 2>&1 &"

Gerard Lally 04-30-2016 07:14 PM

Am I missing something obvious here? Surely the problem is that the OP, with his "su - upnp" in rc.serviio, is trying to get the user upnp to run the serviio.sh script in /usr/local/ ? I have no Slackware running here at the moment; does a Slackware installation even have a user upnp? If not, has the OP created this user, and granted the user permission to execute the serviio.sh script? I presume the OP runs the script manually as root; I also presume this is why it succeeds when run manually. In his rc.serviio script, however, he is trying to run it as upnp. That's what su - upnp means. We need to know whether this user exists and has been granted permission to run serviio.sh.

bassmadrigal 04-30-2016 09:01 PM

OP said that if s/he runs rc.local after bootup, serviio starts fine. This implies that OP has already created the upnp user and that permissions are set properly.


All times are GMT -5. The time now is 11:58 PM.