Ubuntu - Serviio unable to login when run as service
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
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

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
