PS3 Media Server openSUSE init script - Updated

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.

PS3 Media Server openSUSE init script - Updated

Postby Wilt » Fri Jun 26, 2009 5:03 pm

Hello to everyone!

After finding this awesome application, i've installed it in my home media server, an openSUSE box. So I created this init script. Hope it's useful to someone!

NOTES:
- Requires a "pms" user created to run the PS3 Media server. Running with root is always a bad idea... :) Better create a user specific for PMS, can be set in the PMS_USER and PMS_GROUP variables at beginning of script.
- Logging is enabled at /var/log/pms.log. Also can be set in PMS_LOG var.

UPDATE:
- The previous version had a bug, the PMS.conf was not read. The current code works fine, but needs a support script listed after the int script
- The PMS_HOME value must be adjusted to the current PMS install directory
- Variable declaration order was messed up.. Now corrected!

/etc/init.d/pms
Code: Select all
#!/bin/sh
#
# PS3 MEDIA SERVER (PMS)
#
### BEGIN INIT INFO
# Provides:          pms
# Required-Start:    $ALL $remote_fs
# Required-Stop:     $null
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: PS3 Media Server daemon
# Description:       PS3 Media Server daemon
### END INIT INFO

PMS_USER=pms
PMS_GROUP=users
PMS_PORT=5001

JAVA="/usr/bin/java"
PMS_HOME="/opt/pms"
PMS_JAR="$PMS_HOME/pms.jar"
PMS_CMD="${JAVA} -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -jar ${PMS_JAR} console"
PMS_STARTCMD="${PMS_HOME}/pmsd"

PMS_PIDFILE=/var/run/pms.pid
PMS_LOG=/var/log/pms.log

test -f $PMS_JAR || { echo "$PMS_JAR not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

. /etc/rc.status

# Reset status of this service
rc_reset


# Get PID for PMS cmd
get_pid ()
{
    for pid in `ls /proc`; do
        if [ -d /proc/$pid ] && [ -f /proc/$pid/cmdline ]; then
            if [ "$1" = "$(</proc/$pid/cmdline)" ]; then
                # return with current pid
                return
            fi
        fi
    done
    pid=0
}


# checkport <port>
# returns 1 if port_used, 0 if not used
check_port()
{
    if netstat -nlept 2>/dev/null | grep --regexp=":$PMS_PORT " &>/dev/null ; then
        return 1
    else
        return 0
    fi
}


# Check if PMS has a PID
check_pid()
{
    get_pid `eval echo ${PMS_CMD} | sed -e 's/ //g'`
    if [ 0 = $pid ]; then
        return 0
    else
        return 1
    fi

}


case "$1" in
    start)
        echo -n "PS3 Media Server "
        check_pid
        if ! [ 0 = $? ]; then
            echo "already running"
            rc_failed
            rc_status -v1
            rc_exit
        fi
        check_port
        if ! [ 0 = $? ]; then
            echo "port $PMS_PORT already in use"
            rc_failed
            rc_status -v1
            rc_exit
        fi
        export PMS_HOME PMS_CMD
        /sbin/startproc -f -u $PMS_USER -g $PMS_GROUP -p ${PMS_PIDFILE} ${PMS_STARTCMD} >> ${PMS_LOG} 2>&1
        check_pid
        if [ 0 = $? ]; then
            echo "failed start, couldn't obtain PID"
            rc_failed
            rc_status -v1
            rc_exit
        fi
        echo $pid > ${PMS_PIDFILE}
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down PS3 Media Server "
        check_pid
        if [ 0 = $? ]; then
            echo "not running"
            rc_failed
            rc_status -v1
            rc_exit
        fi
        /sbin/killproc -TERM -p ${PMS_PIDFILE} ${JAVA}
        rc_status -v
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    status)
        echo -n "Checking for service PS3 Media Server "
        /sbin/checkproc -p $PMS_PIDFILE ${JAVA}
        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
        ;;
esac
rc_exit



/opt/pms/pmsd
Code: Select all
#!/bin/sh

# Go to the PMS Home dir
cd ${PMS_HOME}

# Execute the command to start PMS
exec ${PMS_CMD}
Last edited by Wilt on Sun Jun 28, 2009 7:57 pm, edited 1 time in total.
Wilt
 
Posts: 2
Joined: Fri Jun 26, 2009 4:42 pm

Re: PS3 Media Server openSUSE init script

Postby bobby » Sun Jun 28, 2009 8:26 am

Hi,

Thanks I've been looking for a script just like this for my Open SUSE box. Only problem is every time I attempt to start the process, I get the following error:

PS3 Media Server failed start, couldn't obtain PID


Any ideas at to what might be causing this? Thanks.
bobby
 
Posts: 2
Joined: Sun Jun 28, 2009 8:23 am

Re: PS3 Media Server openSUSE init script - Updated

Postby Wilt » Sun Jun 28, 2009 8:01 pm

Please, use the updated script version... The variable declaration order was incorrect, and the server can't be started.

Posted the wrong version of the script! :oops:
Wilt
 
Posts: 2
Joined: Fri Jun 26, 2009 4:42 pm

Re: PS3 Media Server openSUSE init script - Updated

Postby bobby » Tue Jun 30, 2009 11:19 am

Worked a treat. Thanks very much.
bobby
 
Posts: 2
Joined: Sun Jun 28, 2009 8:23 am

Re: PS3 Media Server openSUSE init script - Updated

Postby private-eye » Sun Jul 05, 2009 3:41 pm

Running openSUSE 11.1 64-bit here. I just get a "port 5001 already in use" message. Doesn't really make much sense since PMS.sh starts just fine and the port is not used by anything else.
private-eye
 
Posts: 1
Joined: Sun Jul 05, 2009 3:26 pm

Re: PS3 Media Server openSUSE init script - Updated

Postby EagleIJoe » Thu Sep 03, 2009 10:31 pm

To officially conclude the usage one might do:
Code: Select all
$ /sbin/insserv pms
$ ln -s /etc/init.d/pms /sbin/rc-pms


Thank you very much for the script!
EagleIJoe
 
Posts: 1
Joined: Wed Aug 26, 2009 11:53 am

Re: PS3 Media Server openSUSE init script - Updated

Postby jdmp10 » Sun Nov 29, 2009 1:41 am

Hi guys, I found this forum on google when searching for info on setting up a PS3 Media Server. I installed the Windows version on a laptop of mine running Windows 7 and it runs just fine but I really want to get my linux machine up and run as a media server.

I am relatively new to linux and I would really appreciate if one of you guys would tell me where I would need to enter this script to get the media server working on my openSUSE machine. Thanks alot.
jdmp10
 
Posts: 1
Joined: Sun Nov 29, 2009 1:37 am

Re: PS3 Media Server openSUSE init script

Postby terryhoax » Fri Jun 17, 2011 12:20 pm

Hello 2 all,
i hope anyone will read this post after such a long time sinch the last post. So i got the selm problem:
bobby wrote:Hi,
PS3 Media Server failed start, couldn't obtain PID

Any ideas at to what might be causing this? Thanks.



So where can i find the updated script with the right var's ? I used the script from the first post.
My System is OpenSuse 11.3

Many Thanx
JRE
terryhoax
 
Posts: 1
Joined: Fri Jun 17, 2011 12:14 pm

Re: PS3 Media Server openSUSE init script - Updated

Postby stevecrox » Thu May 02, 2013 7:57 am

I have tried using the above script in OpenSuse 12.3 but I keep hitting the following error:

INFO 2013-05-02 07:51:57.974 [main] Using localhost address
INFO 2013-05-02 07:51:57.977 [main] Created socket: 0.0.0.0/0.0.0.0:5001
ERROR 2013-05-02 07:51:58.450 [main] A serious error occurred during PMS init
java.net.UnknownHostException: stevecrox-nas.site: stevecrox-nas.site
at java.net.InetAddress.getLocalHost(InetAddress.java:1438) ~[na:1.7.0_15]
at net.pms.network.HTTPServer.start(HTTPServer.java:131) ~[pms.jar:1.80.0]
at net.pms.PMS.init(PMS.java:479) [pms.jar:1.80.0]
at net.pms.PMS.createInstance(PMS.java:795) [pms.jar:1.80.0]
at net.pms.PMS.main(PMS.java:869) [pms.jar:1.80.0]
stevecrox
 
Posts: 1
Joined: Thu May 02, 2013 7:54 am

Re: PS3 Media Server openSUSE init script - Updated

Postby ilasolomon » Sat Sep 07, 2013 1:33 pm

Hi,
I have the PMS installed on openSuSE 12.3 KDE. I had to turn off the firewall to be able to have a communication between PS3 and the server. I can browse folder and movies from PS3 (wireless connection) but when trying to play any video it gives this error:

[This content can not be played]
800288E1

I never had this when using Fedora, or Windows 7

It seems I have all the necessary codecs installed (VLC, ffmpeg) but there is something missing here that I cannot pin point.
ilasolomon
 
Posts: 2
Joined: Sat Sep 07, 2013 1:21 pm

Next

Return to Linux/Unix Support

Who is online

Users browsing this forum: Google [Bot] and 6 guests