Page 1 of 1

Ubuntu - Serviio unable to login when run as service

PostPosted: Thu Sep 29, 2016 5:23 am
by ZK57
So, I have been trying to get Serviio on Ubuntu 16.04 and have had a lot of problems. I finally managed to get it to work using

  Code:
sudo sh serviio.sh


I am able to log in remotely, but when I tried setting it up to run as a service on boot up, it starts up and is running, but when I try to login to the Media Brower, it immediately comes back to the login screen.

/etc/init.d script
  Code:
#! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          serviio
    # Required-Start:    $local_fs $remote_fs $network $syslog
    # Required-Stop:     $local_fs $remote_fs $network $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # X-Interactive:     true
    # Short-Description: Start/stop serviio media server
    # Description:       The Serviio media server makes your media available to
    #                    all kinds of networked devices.
    ### END INIT INFO

    #
    #########################################################
    #- Daemon Script Configuration for Serviio Media Server
    #- By Ian Laird; converted for Debian by Jacob Lundberg
    #- Updated and Merged for Ubuntu 14.04 by Matthew Bate
    #########################################################
    #
    #########################################################
    #

    . /lib/lsb/init-functions
    if [ -f /etc/default/rcS ]; then
            . /etc/default/rcS
    fi
    NAME="Serviio Media Server"
    DAEMON="/opt/serviio/bin/serviio.sh"      ## Update this to point at your serviio/bin/serviio.sh
    DAEMON_STOP=" -stop"
    SERVICE_ACCOUNT="serviio"            ## DON'T RUN UNDER ROOT!
    TIMEOUT=3
    # We have this because start-stop-daemon needs one and wont start without it.  Although it provides wrong PID ID of Java Client.
    PIDFILE="/var/run/serviiod.pid"         
    if [ -f /etc/default/serviio ]; then
            . /etc/default/serviio
    fi
    [ -x "$DAEMON" ] || exit 0
    #########################################################
    #
    #  Status function check not only the PID file but if it has gone missing it will look for the Java Client manually.
    #
    #########################################################
    status() {
        if [ $1 = "PID" ]; then
       if [ ! -f $TPIDFILE ]; then
           PID=$(ps -ef | grep "org.serviio.MediaServer" | grep -v grep | awk "{ print \$2 }")
           echo $PID
       else
           PID=$(cat $TPIDFILE)
              echo $PID
       fi
        else
            PID=$(ps -ef | grep "org.serviio.MediaServer" | grep -v grep | awk "{ print \$2 }")
            if [[ -z $PID ]]; then
                if [ $1 = "status" ]; then log_daemon_msg "Serviio is currently offline."; else echo "0"; fi # Offline
            else
              if [ $1 = "status" ]; then log_daemon_msg "Serviio is currently online."; else echo "1"; fi # Online
            fi   
        fi
    }
    start() {
        RUNNING=$(status "0")
        if [ $RUNNING = "0" ]; then
       log_daemon_msg "Starting Serviio Media Server..."
       start-stop-daemon --start -q -b -p "$PIDFILE" -m -c "${SERVICE_ACCOUNT}" -x "${DAEMON}"
       log_end_msg $?
        else
       log_daemon_msg "Serviio Media Server is already running."
       log_end_msg 1
        fi
    }
    stop() {
        RUNNING=$(status "0")
        if [ ${#RUNNING} = "1" ]; then
       log_daemon_msg "Shutting Down Serviio Media Server..."
       ${DAEMON} ${DAEMON_STOP}
       log_end_msg $?
        else
       log_daemon_msg "Serviio Media Server is already shutdown."
       log_end_msg 1
        fi
    }
    force_stop() {
        RUNNING=$(status "0")
        if [ ${#RUNNING} = "1" ]; then
       log_daemon_msg "Shutting Down Serviio Media Server..."
       RUNNING=$(status "PID")
       kill -TERM $RUNNING
       log_end_msg $?
        else
       log_daemon_msg "Serviio Media Server is already shutdown."
       log_end_msg 1
        fi
    }
    case "${1:-}" in
            start)
                    start
            ;;
            stop)
                    stop
            ;;
            restart)
                    stop
                    start
            ;;
            status)
                    status $1
            ;;
       force-stop)
          force_stop
       ;;
            *)
                    log_success_msg "Usage: /etc/init.d/$NAME {start|stop|force-stop|restart|status}"
                    exit 1
            ;;
    esac
    exit 0





:(

Re: Ubuntu - Serviio unable to login when run as service

PostPosted: Thu Sep 29, 2016 8:04 pm
by zip
did you set up a password in the console for the Remote (MediaBrowser) session?

Re: Ubuntu - Serviio unable to login when run as service

PostPosted: Fri Sep 30, 2016 12:04 am
by ZK57
zip wrote:did you set up a password in the console for the Remote (MediaBrowser) session?


Yes I did. If I shutdown the serviio service and just run the serviio.sh script in the bin directory, then I can login, but not if I run serviio as a service. I am wondering if it is a permission issue. I setup a serviio user and group, but when I run the script I do it with admin rights on my administrator account. My serviio folder though is setup as root as is the serviio.sh script.

Re: Ubuntu - Serviio unable to login when run as service

PostPosted: Fri Sep 30, 2016 12:54 pm
by zip
It should not really matter. You could check the serviio log file if there are any errors (you might have to enable detailed logging), and also check the browser DevTools Console to see if there are any JavaScript errors.