[INIT SCRIPT] PS3 Media Server Debian/Ubuntu init script

For help and support with issues specific to Linux/Unix
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply.

[INIT SCRIPT] PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Wed Mar 04, 2009 3:59 pm

[UPDATE 12-ago-2011]
Version 3.0: Added PID file (thanks to Sylvain) && PID file management (no more multiple starts of the daemon by mistake)
Version 2.1: 'Going to perfection' version :D(NO NEED TO CHANGE PMS.sh script, read instructions below)
Version 2.0: Completely reworked the way the script work (logging is now possible) - You need also to update the PMS.sh script (included)
Version 1.3: Added 2 variables in the script to run the daemon with the preferred credentials and moved the PID file to PMS_HOME
Version 1.2: Fixed a bug that prevented PMS.conf to be read by the init script
Version 1.1: Removed 'reload' option and added 'status' option (issuing a status option tells you if PS3 Media Server is running or not)
------------------------------------------------------------------------------------------------------------------------------------------------------------

I made myself this init script for Debian/Ubuntu based systems to use PS3 media server as a system service.
I followed strict ubuntu policies to create this script and it's working quite well.

IF YOU are using any older version, replace PMS.sh with the original bundled version of PS3MediaServer!!!!

Currently I'm using it on my Natty 11.04 server and it's working like a charm.
The logs are located in /var/log/pms and have a monthly file scheme.

[*]Unzip the script and put it in /etc/init.d
[*]Edit the script PMS_HOME variable and write your path to PS3 Media Server (in my case /opt/pms).
[*]Edit the PMS_USER and PMS_GROUP variables in the script to the user and group you want to use to launch the PS3 Media Server
[*]Make the script executable with command: "sudo chmod a+x PS3Mediaserver"
[*]If you want to autostart the PS3MediaServer on boot type "sudo update-rc.d PS3MediaServer defaults 90"

Enjoy it.NEW VERSION 3.0 AVAILABLE. PLEASE DONATE
Attachments
PS3MediaServer30.zip
Version 3.0
(1.23 KiB) Downloaded 4737 times
Last edited by RyLoS on Fri Aug 12, 2011 12:25 pm, edited 18 times in total.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby Topguy » Wed Mar 04, 2009 4:16 pm

Very good script and guide.

People might want to double check that "which java" returns the path to the JRE they wish to use. I use Suns JDK on my system so I would have to change that.
Topguy
 
Posts: 219
Joined: Mon Jan 19, 2009 9:27 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Wed Mar 04, 2009 4:33 pm

Script updated to 1.1 version, check first post for differences.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Thu Mar 05, 2009 11:12 am

Script updated to 1.2 version, check first post for differences.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Tue Mar 10, 2009 11:00 am

Script updated to 1.3 version. Now you can run the daemon with your preferred credentials.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby combr » Wed Mar 11, 2009 9:04 pm

Thanks, good idea.
I'm using AltLinux, but i can some rework and use your script as base.
it's easier than write it from scratch ;)
combr
 
Posts: 4
Joined: Sat Mar 07, 2009 7:10 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby Jagged » Fri Mar 13, 2009 7:37 pm

Here's the one I just threw together for my Fedora system.

Code: Select all
#!/bin/bash
#
#       /etc/rc.d/init.d/pmsd
#
# Starts the PS3 Media Server
#
# chkconfig: 345 70 80
# description: PS3 Media Server
# processname: java

### BEGIN INIT INFO
# Provides: pmsd
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start:  3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop pmsd
# Description: PS3 Media Server
### END INIT INFO

PMSUSER=pms
PMSGROUP=pms
JAVA=`which java`

PMS_HOME=/opt/ps3mediaserver
PMS_JAR="$PMS_HOME/pms.jar"
JAVA_OPTS="-Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -jar $PMS_JAR > /dev/null 2>&1 &"
PMSDPID=/var/run/pmsd.pid

export PMS_HOME


# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

#
# See how we were called.
#

start() {

        # Check if pms is already running
        if [ ! -f /var/lock/subsys/pmsd ]; then
                echo -n $"Starting PMS daemon: "
            daemon --user "$PMSUSER" "$JAVA" $JAVA_OPTS
            RETVAL=$?
            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pmsd
            echo
        fi
        return $RETVAL
}

stop() {

        echo -n $"Stopping PMS daemon: "
        killproc $JAVA
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pmsd
        echo
    return $RETVAL
}


restart() {
        stop
        start
}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        restart
        ;;
status)
        status $JAVA
        RETVAL=$?
        ;;
*)
        echo $"Usage: $0 {start|stop|status|restart)"
        RETVAL=2
esac

exit $RETVAL

Jagged
 
Posts: 75
Joined: Thu Feb 26, 2009 8:44 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby leifg » Sun Mar 22, 2009 1:43 pm

Thanks for the script, it works great for me, except the fact that I have to manually stop and start it, so that the media center appears.

So I was wondering, is there already a log file of the start up process written or can I alter the script in a way so this happens. That would help me for the first step.

best regards
Leif
leifg
 
Posts: 1
Joined: Sun Mar 22, 2009 1:40 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Mon Mar 23, 2009 9:18 am

It just start the PS3Mediaserver with the user/group you specified on the script.
If you want to see what's wrong for you, just run the default PMS.sh script that come with PS3Mediaserver with the same credentials you use on the init script and you will see the log window.
Hope this help you.

Edit (for more expert users):
You can also remove the '--background' switch in the init script and start it (it will not be forked as a daemon) so you'll see the log window.
Remember that this is for debug purposes, when you've finished, put the '--background' switch were it was or you will have problems on normal use.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Re: PS3 Media Server Debian/Ubuntu init script

Postby RyLoS » Mon Apr 20, 2009 11:00 am

My script it's working like a charm for now, but i've noticed memory leakage in ps3mediaserver itself....after days of usage, the memory utilization is growing day by day.
I think developers needs to analyze this further.
RyLoS
 
Posts: 15
Joined: Wed Mar 04, 2009 3:50 pm
Top

Next

Return to Linux/Unix Support

Who is online

Users browsing this forum: No registered users and 2 guests