FAQ  •  Register  •  Login

Linux Daemon scripts

<<

kc1

Streaming enthusiast

Posts: 28

Joined: Mon Jun 06, 2011 12:21 pm

Post Tue Jun 07, 2011 12:29 pm

Re: Linux Daemon scripts

jtl wrote:Debian Squeeze wants a little different init script. Also, -halt does not work for me (it behaves just like without the argument, i.e. if the server is already running, it will stay running, and if it is already stopped, it will be started up). I've updated Ian Laird's script to handle these two issues.

Copy Ian's config file (above) into /etc/default (Debian's path for such things). Update the user and path values. Then you can use this...


Hello again, when you say to update user value, do you mean change the line in Ian's script it says:
  Code:
 SERVICE_ACCOUNT="root" ## DON'T RUN UNDER ROOT!


What should I change it to?

I'm also confused about the bit that says:
  Code:
DAEMON="/bin/serviio"    ## Update this to point at serviio_root/bin/serviio.sh


My Serviio installation is in //NVX/c/webroot/serviio, does that mean the line in the config file should be: DAEMON="/c/webroot/serviio/bin/serviio.sh" or just DAEMON="/c/webroot/serviio/" or something else?

Thanks
Trying to get Serviio working with Samsung D7000 and ReadyNas NVX without a PC in between
<<

LarryJB20@gmail.com

Serviio newbie

Posts: 1

Joined: Tue Jun 07, 2011 5:56 pm

Post Tue Jun 07, 2011 6:25 pm

Re: Linux Daemon scripts

I am a true linux newbie so please be gentle.
The best I can tell this is close, if not exactly what I want to do.
I have Serviio installed and working on Ubuntu 10.04 server edition.
I want have Serviio start at system boot and then be able to run the console via a VPN connection using the GNOME gui.
How can I accomplish this?

I suppose these instructions are clear to a seasoned Linux user, but not so much for me. BTW, What is a Daemon script? Does that mean a start up script? How is daemon pronounced? Day'-mon (rhymes with gone)
<<

pierrep

Streaming enthusiast

Posts: 41

Joined: Sun Jun 12, 2011 6:59 am

Location: Grenoble - France

Post Mon Jun 13, 2011 6:27 pm

Re: Linux Daemon scripts

Hello

I'm running Serviio on a Fedora 15 server. I've installed daemon scripts as described in clearfoundation forum (scripts described in current post fail with Fedora!).

Serviio start correctly with the clearfoundation script, after launching I have:
  Code:
 ps -ef | grep serviio
  root      6819     1  0 14:26 ?   00:00:00 /usr/bin/sudo -u serviio -H /usr/bin/serviio/bin/serviio.sh -headless
  serviio   6821  6819  0 14:26 ?   00:00:00 /bin/sh /usr/bin/serviio/bin/serviio.sh -headless
  serviio   6826  6821 36 14:26 ?   02:01:17 java -Xmx384M -Djava.net.preferIPv4Stack=true ........

But when I try "service serviio stop" (it launch "killproc serviio.sh") only the 2 first processes are killed: the java process remain active and I have to kill it manually.

Any idea to solve the problem?

Thanks
Pierre
<<

oshunluvr

Serviio newbie

Posts: 9

Joined: Sun Jun 26, 2011 4:42 pm

Post Tue Jun 28, 2011 2:21 pm

Re: Linux Daemon scripts

I'm trying to get Serviio to run as a daemon on Ubuntu 10.04.2 server in a headless configuration and jopiexjoker's script doesn't work for me. I get an awk formatting error two places in the script. I'm working on my own but this is my first daemon script. If anyone else has the same experience and/or solution please post!
<<

pierrep

Streaming enthusiast

Posts: 41

Joined: Sun Jun 12, 2011 6:59 am

Location: Grenoble - France

Post Wed Jun 29, 2011 10:08 am

Re: Linux Daemon scripts

pierrep wrote:... when I try "service serviio stop" (it launch "killproc serviio.sh") only the 2 first processes are killed: the java process remain active and I have to kill it manually.


I've solved the problem by changing the stop() function in the script
  Code:
stop() {
    check
    echo -n "Shutting down Serviio DLNA daemon: "
    # Retrieve JAVA Serviio process ID
    PIDDAEMON=`pgrep $SERVIIO_DAEMON`
    [ -z "$PIDDAEMON" ] || PIDJAVA=`ps -o pid= --ppid $PIDDAEMON`
    # Kill the daemon
    killproc "$SERVIIO_BIN"
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/serviio.sh
    echo
    # Kill the JAVA Serviio process if exists
    [ -z "$PIDJAVA" ] || kill -9 $PIDJAVA
    return $RETVAL
}
<<

MaxS

Serviio newbie

Posts: 1

Joined: Fri Aug 05, 2011 6:38 pm

Post Fri Aug 05, 2011 7:05 pm

Re: Linux Daemon scripts

Hi All! Привет всем! ;)
jopiexjoker wrote:For all you ubuntu lovers, like myself... I've combined above scripts and got it to work in ubuntu 10.10.

Then make the script /etc/init.d/serviio like this:
  Code:
...
start() {
        log_daemon_msg "Starting Serviio media server daemon" "$NAME"
        start-stop-daemon --start -q -b -p "$PIDFILE" -m -c "${SERVICE_ACCOUNT}" -x "${DAEMON}"
        log_end_msg $?
}
...




It was checked on Ubuntu 11.04 :
/etc/init.d/serviio
  Code:
...
start() {

   # Set up correct LANG
   if [ -r /etc/default/locale ]; then
       . /etc/default/locale
       export LANG LANGUAGE LC_MESSAGES LC_ALL LC_CTYPE
   fi

        log_daemon_msg "Starting Serviio media server daemon" "$NAME"
        start-stop-daemon --start -q -b -p "$PIDFILE" -m -c "${SERVICE_ACCOUNT}" -x "${DAEMON}"
        log_end_msg $?
}
...

With this script, serviio is starting with US-ASCII setting. I have added these lines after start() to set it back to the system coding.
<<

jonolafur

Serviio newbie

Posts: 1

Joined: Thu Aug 11, 2011 2:55 pm

Post Thu Aug 11, 2011 3:21 pm

Re: Linux Daemon scripts

Hi All,

since ubuntu now uses upstart for handling the startup process rather than the good old SysV-init, I thought I'd share with you an extremely simple script that handles this startup business via startup. Simply save the following script in the directory /etc/init/ (without the ".d" at the end...) and call it serviio.conf:
  Code:
start on started networking
script
   /<path-to-serviio>/serviio.sh
end script

and replace <path-to-serviio> with the actual path to your serviio installation. And yes, this is really the complete script! The upstart system now starts the serviio server as soon as all networking jobs have been started. If you need it to start earlier or later, please check the excellent documentation on upstart for example here: http://upstart.ubuntu.com/cookbook/.

You can now get a list of all jobs registered with upstart by issuing:
  Code:
>initctrl list

and serviio should be one of them.

Check the status of serviio with:
  Code:
>status serviio

and you should get something like:
  Code:
>serviio start/running, process 1009

if it is already running, otherwise it says:
  Code:
>serviio stop/waiting

You can start and stop the job via:
  Code:
>sudo start serviio

and
  Code:
>sudo stop serviio


Personally, I can't think of anything else I would need in this context...

Regards,

Jón
<<

bananaco

Serviio newbie

Posts: 3

Joined: Sun Oct 02, 2011 2:30 am

Post Sun Oct 02, 2011 2:38 am

Re: Linux Daemon scripts

For the life of me, I cannot get my serviio server to run at boot. I'm running mythbuntu 11.04. I'm a unix novice. I've tried everything in this thread and nothing works. Haven't been able to get a daemon to work, haven't been able to get upstart to work...nothing. When I run the serviio.sh script through the terminal manually, it runs just fine and works as excellently as serviio always does, but I want this to start on boot so I don't have to start every time my server is rebooted. Does anyone have any suggestions on where I can look to see why my serviio isn't starting. I have upstart conf file below:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# serviio

description "Serviio Server Service"
author "me"

start on runlevel [2345]
stop on runlevel [06]

respawn

expect fork

script
exec /programs/serviio/bin/serviio.sh
end script
-----------------------------------------------------------------------------------------------------------------------------------------------------

I also tried the sugested :

script
/programs/serviio/bin/serviio.sh
end script

and that doesn't work either. WHen I run "sudo start serviio" it says it starts and gives me a PID, but I'll run "status serviio" immediately after that and it says it is stopped. I also see nothing in the /log/serviio.log file.

I've spent about 3 days on this now and I'm about to give up. Anyone's time and help would be very much appreciated!

Thanks! (and let me know if you need more info from me...I don't know where I would be able to view a log that shows why it isn't starting...syslog says nothing)
<<

patters

User avatar

DLNA master

Posts: 1282

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Mon Oct 03, 2011 9:45 am

Re: Linux Daemon scripts

Is killing the serviio java process (as some of these example scripts do) really a good idea? Isn't there a good chance it can leave database files locked etc.? I use the serviio's built-in stop function in the script I made for Synology NAS. The status function works because for my package serviio runs as the user 'serviio':
  Code:
#!/bin/sh

#--------SERVIIO start-stop-status script
#--------package maintained at pcloadletter.co.uk

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

case $1 in
        start)
                # start Serviio in background mode
                su - serviio -s /bin/sh -c "${SYNOPKG_PKGDEST}/bin/serviio.sh &"
                exit 0
        ;;
        stop)
                su - serviio -s /bin/sh -c "${SYNOPKG_PKGDEST}/bin/serviio.sh -stop"
                exit 0
        ;;
        status)
                if daemon_status ; then
                        exit 0
                else
                        exit 1
                fi
        ;;
        log)
        echo "${SYNOPKG_PKGDEST}/log/serviio.log"
                exit 0
        ;;
esac
LG OLED55B8PLA | PS4 Pro | Xbox One S | Synology DS214play
Serviio 2.1 package for Synology NAS - with limited hardware transcoding support!
<<

knyckis

Serviio newbie

Posts: 2

Joined: Tue Oct 04, 2011 10:18 pm

Post Tue Oct 04, 2011 10:27 pm

Re: Linux Daemon scripts

@bananaco:

Did you really try out jonolafur's Aug 11 suggestion in full? I have tried it twice, once on 11.04 Desktop and once on Server, and it works like a charm. (THX Jón for that simple and beautiful solution!)

If that does not work, maybe you have not installed it right (although it looks like you have from what I can see). Here is a step by step on that, copied from viewtopic.php?f=5&t=289 (how-to is for 10.04, bur works great on 11.04 as well):

1. Open a terminal windows
2. Type "cd" [ENTER]
3. Type "wget ‪http://www.serviio.org/files/releases/s ... nux.tar.gz‬" [ENTER]
4. Type "tar xzvf serviio-0.4.1-linux.tar.gz" [ENTER]
5. Type "cd serviio-0.4.1./bin/" [ENTER]
6. Type "./serviio.sh" [ENTER]
Nothing happens at this time and it's normal, the server is running.
You can open another terminal (type CTRL+SHIFT+T for example if you are under Gnome Terminal), and :
1. Type "cd" [ENTER]
2. Type "cd serviio-0.4.1./log/" [ENTER]
3. Type "tail -f serviio.log" [ENTER], you'll then see what's happening (in real time) on the server
If you open (for example) your PS3 > XMB > Video > Serviio, you should find the server (without any items inside as long as you haven't opened the console to add directories containing media files).

Good luck!
//K
<<

Thomas.Letsch

Serviio newbie

Posts: 1

Joined: Fri Oct 14, 2011 9:57 am

Post Sun Oct 16, 2011 5:01 pm

Re: Linux Daemon scripts

HI,

since I am also running serviio under ubuntu 11.04, I started to use the upstart script from jonolafur. Reading a little bit further into upstart, I improved it and moved the shell script parts into it, too.

It expects a system with a serviio user, which owns the serviio installation (write to the library) and should be able to read all media files. It also expects to have serviio installed under /usr/local/serviio (can be configured in the upstart file). Check with:
# ls -la /usr/local/serviio
drwxr-xr-x 9 serviio users 4096 2011-10-14 10:25 .

/etc/init/serviio.conf:
  Code:
# serviio - DLNA Server
#

description     "Serviio DLNA server"

env ROOT_DIR=/usr/local/serviio
env USER=serviio
env SERVIIO_HOME=/usr/local/serviio
env JAVA_HOME=/usr/lib/jvm/java-6-openjdk
env JVM_OPTIONS="-Xmx384M -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dderby.system.home=$SERVIIO_HOME/library -Dserviio.home=$SERVIIO_HOME"
env LOGPATH=/var/log/serviio
env LOGFILE="$LOGPATH/startup.log"
env SERVIIO_CLASS_PATH="$SERVIIO_HOME/lib/serviio.jar:$SERVIIO_HOME/lib/derby.jar:$SERVIIO_HOME/lib/jcs.jar:$SERVIIO_HOME/lib/concurrent.jar:$SERVIIO_HOME/lib/freemarker.jar:$SERVIIO_HOME/lib/httpcore.jar:$SERVIIO_HOME/lib/jaudiotagger.jar:$SERVIIO_HOME/lib/jul-to-slf4j.jar:$SERVIIO_HOME/lib/jcl-over-slf4j.jar:$SERVIIO_HOME/lib/log4j.jar:$SERVIIO_HOME/lib/sanselan.jar:$SERVIIO_HOME/lib/slf4j-api.jar:$SERVIIO_HOME/lib/slf4j-log4j12.jar:$SERVIIO_HOME/lib/org.restlet.jar:$SERVIIO_HOME/lib/org.restlet.ext.xstream.jar:$SERVIIO_HOME/lib/xstream.jar:$SERVIIO_HOME/lib/rome.jar:$SERVIIO_HOME/lib/rome-modules.jar:$SERVIIO_HOME/lib/jdom.jar:$SERVIIO_HOME/lib/groovy-all.jar:$SERVIIO_HOME/lib/winp.jar:$SERVIIO_HOME/lib/org.restlet.ext.gson.jar:$SERVIIO_HOME/lib/gson.jar:$SERVIIO_HOME/config"

kill timeout 10

start on filesystem

stop on runlevel [016]

pre-start script
    mkdir -p $LOGPATH
    chown $USER:users $LOGPATH
end script

pre-stop script
     exec su -c  "$JAVA_HOME/bin/java $JVM_OPTIONS -classpath $SERVIIO_CLASS_PATH  org.serviio.MediaServer -stop > $LOGFILE 2>&1" $USER
end script

script
    exec su -c  "$JAVA_HOME/bin/java $JVM_OPTIONS -classpath $SERVIIO_CLASS_PATH  org.serviio.MediaServer > $LOGFILE 2>&1" $USER
end script



There is the normal stop call added as pre-stop-script. Then it will wait a maximum of 10secs before it really kills the process. Should be time enough for a normal shut down.
As you can see, the bootup log should be put into /car/log/serviio, which is not really working :-(. So still room for improvements...


Hope you can use it.

Regards,
Thomas
<<

abeloin

Serviio newbie

Posts: 3

Joined: Thu Nov 10, 2011 2:17 am

Location: Canada

Post Thu Nov 10, 2011 2:46 am

Re: Linux Daemon scripts

In Fedora 16, the Clear Foundation script fail to start via systemd with the following error message "sudo: sorry, you must have a tty to run sudo". Using su instead of sudo resolve the issue.

--edit--
See Serviio's Wiki for a modified initscript.
Last edited by abeloin on Thu Nov 10, 2011 5:31 pm, edited 1 time in total.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Nov 10, 2011 9:19 am

Re: Linux Daemon scripts

Could we start moving these scripts to wiki.serviio.org? That way everyone will be able to make changes to keep them up-to-date.
<<

kairoh

DLNA master

Posts: 180

Joined: Sun Aug 08, 2010 10:41 am

Location: France

Post Thu Nov 10, 2011 10:26 am

Re: Linux Daemon scripts

Here is a mix a previous upstart script for ubuntu:
  Code:
# serviio - DLNA Server
#

description "Serviio DLNA server"

# To be customized
env USER=serviio
env SERVIIO_HOME=/usr/local/serviio
env JAVA_HOME=/usr/lib/jvm/java-6-openjdk
env LOGPATH=/var/log/serviio
env LOGFILE="$LOGPATH/startup.log"

kill timeout 10
start on filesystem
stop on runlevel [016]

pre-start script
   mkdir -p $LOGPATH
   chown $USER:users $LOGPATH
end script

# Not sure it is necessary...
pre-stop script
   exec su -c  "$SERVIIO_HOME/bin/serviio.sh -stop >> $LOGFILE 2>&1" $USER
end script

script
   exec su -c  "$SERVIIO_HOME/bin/serviio.sh > $LOGFILE 2>&1" $USER
end script

I think the best way is to rely on serviio shell.
Serviio WebUI console developer : New Homepage | Support | Project | Issues

Samsung UA32C6600 | WinXP / Ubuntu 11.10 | Samsung Galaxy S | Freebox v6
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

GuSec

Serviio newbie

Posts: 5

Joined: Sun Nov 27, 2011 3:16 pm

Post Sun Nov 27, 2011 3:24 pm

Re: Linux Daemon scripts

Hi, I'm running Ubuntu 11.10 and used kairoh's script (the last post), which works like a charm for me. But, I'm using my ordinary user (the one who owns the homefolder where most of the mediafiles are located) instead of creating a specific "serviio"-user as the environmental variable USER. What's the downside to this?

I figured it was simpler and can't really see any problem with it, except that, of course, serviio has writing access to my home folder (didn't figure this should matter though, since serviio doesen't write to anything besides the library database files and it seems well written). Do I really need to create a serviio user, and if so, how? ;)
<<

Cerberus

User avatar

DLNA master

Posts: 4114

Joined: Sun Jan 02, 2011 5:20 pm

Location: Reading, UK

Post Sun Nov 27, 2011 4:22 pm

Re: Linux Daemon scripts

GuSec wrote:Hi, I'm running Ubuntu 11.10 and used kairoh's script (the last post), which works like a charm for me. But, I'm using my ordinary user (the one who owns the homefolder where most of the mediafiles are located) instead of creating a specific "serviio"-user as the environmental variable USER. What's the downside to this?

I figured it was simpler and can't really see any problem with it, except that, of course, serviio has writing access to my home folder (didn't figure this should matter though, since serviio doesen't write to anything besides the library database files and it seems well written). Do I really need to create a serviio user, and if so, how? ;)


you dont need to no but some have found its neater and looks better if you do, but in my opinion if it works who cares.
Phil Bennett
Beta Tester Group
Wiki | FAQ

Samsung LE40C750 LCD | Samsung BD-C5900 | Sony PS3 | Windows 7 |
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

vince

Serviio newbie

Posts: 2

Joined: Mon Nov 28, 2011 10:41 pm

Post Mon Nov 28, 2011 10:53 pm

Re: Linux Daemon scripts

zip wrote:Could we start moving these scripts to wiki.serviio.org? That way everyone will be able to make changes to keep them up-to-date.


Firstly, many thanks for all the bits of information and scripts on here, it was invaluable in getting my Ubuntu Server install working and configured.

So, in an attempt to make the next man's life even easier, I've had a go at adding a Ubuntu Server section into the Wiki:

http://wiki.serviio.org/doku.php?id=howto:linux:install
<<

Cerberus

User avatar

DLNA master

Posts: 4114

Joined: Sun Jan 02, 2011 5:20 pm

Location: Reading, UK

Post Tue Nov 29, 2011 7:34 am

Re: Linux Daemon scripts

vince wrote:
zip wrote:Could we start moving these scripts to wiki.serviio.org? That way everyone will be able to make changes to keep them up-to-date.


Firstly, many thanks for all the bits of information and scripts on here, it was invaluable in getting my Ubuntu Server install working and configured.

So, in an attempt to make the next man's life even easier, I've had a go at adding a Ubuntu Server section into the Wiki:

http://wiki.serviio.org/doku.php?id=howto:linux:install


looks great to me :) and saved me from doing it :D
Phil Bennett
Beta Tester Group
Wiki | FAQ

Samsung LE40C750 LCD | Samsung BD-C5900 | Sony PS3 | Windows 7 |
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

Morcegolas

Serviio newbie

Posts: 2

Joined: Wed Jan 18, 2012 2:57 am

Post Wed Jan 18, 2012 11:43 am

Re: Linux Daemon scripts

Hello people.

I'm very basic to linux, I have Mint 12 and Serviio working, but every time I reboot my machine I have to open terminal and run "sudo /home/username/.servio/bin/./serviio.sh" to get it working.

With the posted solutions I was unnable to get it work, can someone help me with this?

Thanks.
Last edited by Morcegolas on Wed Jan 18, 2012 11:52 am, edited 1 time in total.
<<

Cerberus

User avatar

DLNA master

Posts: 4114

Joined: Sun Jan 02, 2011 5:20 pm

Location: Reading, UK

Post Wed Jan 18, 2012 11:48 am

Re: Linux Daemon scripts

Phil Bennett
Beta Tester Group
Wiki | FAQ

Samsung LE40C750 LCD | Samsung BD-C5900 | Sony PS3 | Windows 7 |
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
PreviousNext

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.