I am running a headless server on Fedora 15 and have been trying for the last while to get PS3 Media Server installed and running as a service (that starts automatically).
The system is a quad-core Xeon 2.13GHz with 4gb RAM on a wired Gigabit LAN.
I installed PS3MS to /usr/local/PMS, I set permissions for the directory and the PMS.sh and pms.jar files to 777. If I log in as a user over SSH, I can start PS3MS by running sh /usr/local/PMS/PMS/sh - although it tells me there is no GUI available and switches to console mode (even though I have "headless=true" in the PMS.sh script. I included an "&" at the end of the PMS.sh script so that I am able to close the terminal and PS3MS keeps running.
I would like to have PSMS start automatically when the system boot, but I cannot get it to work.
This is my PMS.sh script
- Code: Select all
#!/bin/sh
cd /usr/local/PMS/
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/
export PATH=$JAVA_HOME/bin:$PATH
DIRNAME=`dirname $0`
# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
esac
# 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"`
fi
# Setup PMS_HOME
if [ "x$PMS_HOME" = "x" ]; then
PMS_HOME=$DIRNAME
fi
export PMS_HOME
# XXX: always cd to the working dir: https://code.google.com/p/ps3mediaserver/issues/detail?id=730
cd $PMS_HOME
# Setup the JVM
if [ "x$JAVA" = "x" ]; then
if [ "x$JAVA_HOME" != "x" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="java"
fi
fi
# Setup the classpath
# since we always cd to the working dir, these a) can be unqualified and b) *must*
# be unqualified: https://code.google.com/p/ps3mediaserver/issues/detail?id=1122
PMS_JARS="update.jar:pms.jar"
# 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"`
fi
# Execute the JVM
$JAVA $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -classpath "$PMS_JARS" net.pms.PMS "$@" console &
I have tried using a script in /etc/rc.d/init.d called PMS:
- Code: Select all
#!/bin/sh
#
#chkconfig: - 91 50
# description: Starts and stops the ps3mediaserver
# pidfile: /usr/local/PMS/PMS.pid
# config: /usr/local/PMS/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
else
exit 1
fi
# Avoid using root's TMPDIR
unset TMPDIR
# Source networking configuration and check that networking is up.
if [ -f /etc/sysconfig/network ] ; then
. /etc/sysconfig/network
[ ${NETWORKING} = "no" ] && exit 1
fi
# The displayed name of the service
SERVICE_NAME='PMS'
# Where PMS.sh is located
PMS_DIR='/usr/local/PMS/'
#the name of the PMS.sh file, in case you renamed it
PROG_FILE='PMS.sh'
# The name of the search string in `ps`. For java programs, this is the name of the main jar file, for all others, it is the same as PROG_FILE
PROC_NAME='pms.jar'
# the name of the config file, in case you renamed it
CONFIG_FILE=/usr/local/PMS/PMS.conf
#the log file. stderr and stdout are redirected to this file.
LOG_FILE=/var/log/PMS.log
# the name of the PID file. The process ID is stored in this file.
# NOTE: This file is required for proper functionality!
PID_FILE=/usr/local/PMS/PMS.pid
# the name of the system lock file. This file is empty, but lets the system know there is supposed to be a service running.
# NOTE: This file is required for proper functionality!
LOCK_FILE=/var/lock/subsys/PMS
###############################
# Edit past here at your own risk! #
###############################
RETVAL=0
start() {
if [ ! -f $PID_FILE ]; then
echo -n $"Starting $SERVICE_NAME: "
cd $PMS_DIR
daemon "$PMS_DIR/$PROG_FILE 2>1 > $LOG_FILE &"
else
rhstatus
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCK_FILE && echo `ps x o pid,args|grep $PROC_NAME|grep -v grep|awk {'print $1'}` > $PID_FILE || RETVAL=1
echo
return $RETVAL
}
stop() {
if [ -f $PID_FILE ]; then
echo -n $"Stopping $SERVICE_NAME: "
killproc -p $PID_FILE
else
rhstatus
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $PID_FILE && rm -f $LOCK_FILE
echo
return $RETVAL
}
restart() {
stop
start
}
rhstatus() {
status -p $PID_FILE $SERVICE_NAME
return $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rhstatus
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
$RETVAL = 3
esac
exit $RETVAL
I can install the script with "chkconfig --add PMS" and turn in on for various run levels with "chkconfig --level 2345 PMS on"
It appears to start when I give the command: service PMS start
But, it doesn't seem to actually run or show up on the PS3.
I have also tried to add a line to rc.local:
sh /usr/local/PMS/PMS.sh
But that doesn't seem to be working either - no PS3MS on the PS3
Has anyone been able to get this running on a headless Fedora 15? Can anyone help?
Thanks!
