Fedora 11 server 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.

Fedora 11 server init script

Postby deejaybags » Sat Nov 14, 2009 12:29 pm

Hi All,

I have installed this great piece of software to a directory /usr/local/ps3mediaserver and have written the following init script to work with Fedora 11's initscripts package. Well, not really written, just hacked the start script for samba :-P This script works for me, and I thought I should share it. Feel free to use and change as you need to.
Code: Select all
# chkconfig: - 91 50
# description: Starts and stops the ps3mediaserver
# pidfile: /usr/local/ps3mediaserver/ps3mediaserver.pid
# config:  /usr/local/ps3mediaserver/PMS.conf

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
  exit 1

# Avoid using root's TMPDIR
unset TMPDIR

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1



start() {
        echo -n $"Starting $KIND services: "
        cd $PROG_ROOT
        daemon $PROG_ROOT/$PROG_EXEC
        [ $RETVAL -eq 0 ] && echo `ps o pid,args|grep $PROG_JAR|grep -v grep|awk {'print $1'}` > $PROG_ROOT/$PROG_NAME.pid || \
        return $RETVAL

stop() {
        echo -n $"Shutting down $KIND services: "
        killproc -p $PROG_ROOT/$PROG_NAME.pid
        [ $RETVAL -eq 0 ] && rm -f $PROG_ROOT/$PROG_NAME.pid
        return $RETVAL

restart() {

rhstatus() {
        status -p $PROG_ROOT/$PROG_NAME.pid $PROG_NAME
        return $?

case "$1" in
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 2
exit $?

This file was created at /etc/init.d/ps3mediaserver and was installed using
Code: Select all
chkconfig --add ps3mediaserver

To PMS.sh, I added the following to near the start of the file
Code: Select all
export JAVA_HOME=/opt/SDK/jdk
export PATH=$JAVA_HOME/bin:$PATH

The last line of the PMS.sh was also changed. The exec and the quotes around the $JAVA were removed, the setting for headless was added, some logging to /var/log/ps3mediaserver.log and the & to make the process run in the background. The line now looks like
Code: Select all
$JAVA $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -classpath "$PMS_JARS" net.pms.PMS "$@" >>/var/log/ps3mediaserver.log 2>>/var/log/ps3mediaserver.log &

now the service can be started by
Code: Select all
service ps3mediaserver start

stopped with
Code: Select all
service ps3mediaserver stop

restarted with
Code: Select all
service ps3mediaserver restart

and check the status with
Code: Select all
service ps3mediaserver status

and turned on at boot with
Code: Select all
chkconfig --level 2345 ps3mediaserver on

Make sure the $JAVA_HOME you put in the PMS.sh file is correct for your system.
If you use a different directory to install the software to, change the $PROG_ROOT var
If you use a different script to the usual PMS.sh script, change $PROG_EXEC var
if the java class file ever changes from pms.jar, change $PROG_JAR

i think that just about sums it up. hope this helps some of you out there...
Posts: 2
Joined: Sat Nov 14, 2009 11:49 am

Re: Fedora 11 server init script

Postby Doomstalk » Sat Dec 12, 2009 7:58 pm

Hm, this seems like the wrong thread for your problem. That being said, have you verified that PMS.sh has execute permissions the file system?
Posts: 17
Joined: Sat Dec 12, 2009 6:17 pm

Re: Fedora 11 server init script

Postby deejaybags » Tue Dec 15, 2009 2:17 pm

buddyburton wrote:i write ./PMS.sh and i get the following: bash: ./PMS.sh: Permission denied
i try run it as sudo ./PMS.sh but all i get is a sudo: ./PMS.sh: command not found.

as Doomstalk said, check ya permissions on PMS.sh. if those are incorrect,you will also probably need to change linux/tsMuxeR as well
Code: Select all
chmod +x PMS.sh
chmod +x linux/tsMuseR
Posts: 2
Joined: Sat Nov 14, 2009 11:49 am

Re: Fedora 11 server init script

Postby quietdragon » Wed Apr 13, 2011 5:23 am

I'm using pms-linux-1.21.0. For this version I had to add a console option:

Code: Select all
java -Djava.awt.headless=true -Xmx768M -Xss16M -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -classpath /opt/ps3mediaserver/pms/update.jar:/opt/ps3mediaserver/pms/pms.jar net.pms.PMS console

I also had to use java-1.6.0-openjdk on Fedora.
Posts: 3
Joined: Wed Apr 13, 2011 4:59 am

Re: Fedora 11 server init script

Postby fab5fred » Sat Apr 16, 2011 10:25 pm

I just tried to update to 1.21.1 and I copied it over my existing 1.20 install and it wouldn't start, so I reverted my PMS.sh file and it started, but I could not find it on my network. So I then changed the execute script to the above mentioned one and now I get this:

Code: Select all
Starting ps3mediaserver services: Exception in thread "main" java.lang.NoClassDefFoundError: net/pms/PMS
Caused by: java.lang.ClassNotFoundException: net.pms.PMS
   at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: net.pms.PMS. Program will exit.

I checked and I do have java 1.6.0 installed

Code: Select all

export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-
export PATH=$JAVA_HOME/bin:$PATH

DIRNAME=`dirname $0`

# OS specific support (must be 'true' or 'false').
case "`uname`" in

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$PMS_HOME" ] &&
PMS_HOME=`cygpath --unix "$PMS_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`

# Setup PMS_HOME
if [ "x$PMS_HOME" = "x" ]; then
   PMS_HOME=`cd $DIRNAME/; pwd`
export PMS_HOME

# Setup the JVM
if [ "x$JAVA" = "x" ]; then
   if [ "x$JAVA_HOME" != "x" ]; then

# Setup the classpath

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
   PMS_HOME=`cygpath --path --windows "$PMS_HOME"`
   JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
   PMS_CLASSPATH=`cygpath --path --windows "$PMS_CLASSPATH"`

# Execute the JVM
java -Djava.awt.headless=true -Xmx768M -Xss16M -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -classpath /opt/ps3mediaserver/pms/update.jar:/opt/ps3mediaserver/pms/pms.jar net.pms.PMS console

Any help would be appreciated as 1.21.1 fixes a lot of my MKV issues from what I read
Posts: 1
Joined: Sat Apr 16, 2011 10:21 pm

Re: Fedora 11 server init script

Postby ferrouille » Tue May 24, 2011 7:01 pm

same issue for me.. did you ever find a solution for this?
Posts: 2
Joined: Thu May 19, 2011 11:59 pm

Re: Fedora 11 server init script

Postby chocolateboy » Tue May 24, 2011 7:11 pm

Project Member
Posts: 2581
Joined: Wed Sep 16, 2009 10:05 am

Return to Linux/Unix Support

Who is online

Users browsing this forum: No registered users and 2 guests