You are not logged in.
Pages: 1
I've been trying all day to write this rc.d script to get PS3 Media Server to run as a daemon and I can't get it to work. I think I'm getting closer though. When I do /etc/rc.d/pms start it tries to start but says "/usr/bin/pms: line 50: exec: java: not found" JRE is installed and PS3 Media Server works perfectly if I just run it from the terminal by issuing "pms". Which is why I find it strange that when trying to start the daemon it can't find java. Any ideas would be greatly appreciated.
Here is my rc.d script
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="pms server"
NAME=pms
DAEMON=/usr/bin/pms
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Starting pms server..."
$DAEMON &
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon $NAME
pidof $NAME > $PIDFILE
stat_done
fi
;;
stop)
stat_busy "Stopping pms server..."
if [ -a $PIDFILE ]; then
PID='cat $PIDFILE'
kill $PID > /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm $PIDFILE
rm_daemon $NAME
stat_done
fi
else
pkill $NAME
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
fi
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
esac
exit 0
And here is the contents of /usr/bin/pms
#!/bin/sh
PMS_HOME=/opt/pms
cd $PMS_HOME
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=`cd $DIRNAME/; pwd`
fi
export 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
PMS_JAR="$PMS_HOME/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"`
PMS_CLASSPATH=`cygpath --path --windows "$PMS_CLASSPATH"`
fi
# Execute the JVM
exec "$JAVA" $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -jar "$PMS_JAR" "$@"
Offline
You should add /opt/java/jre/bin to the PATH variable on top of the rc.d script.
Offline
Thank you so much Surgat_ ! It works! Excellent!
Offline
I took this script and touched it up a bit, and now it works quite well. Posting working script for whoever needs it:
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/jre/bin
DESC="pms server"
NAME=pms
DAEMON=/usr/bin/pms
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Starting pms server..."
$DAEMON &
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon $NAME
# pidof $NAME > $PIDFILE
sleep 10
ps fax | grep -i pms.jar | grep -v grep | awk '{print $1}' > $PIDFILE
stat_done
fi
;;
stop)
stat_busy "Stopping pms server..."
if [ -a $PIDFILE ]; then
PID=`cat $PIDFILE`
kill $PID > /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm $PIDFILE
rm_daemon $NAME
stat_done
fi
else
pkill $NAME
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
fi
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
esac
exit 0
Offline
Actually you only need this because you're using Sun's java, not openjdk.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
When I run sudo /etc/rc.d/pms start it keeps sending messages to the terminal. Any way to get the rc.d/pms to behave as all the other daemons? IE dont show the startup inbetween Starting [BUSY] and starting [DONE] aswell as the
announce afterwards.
[flax@flax-server ~]$ sudo /etc/rc.d/pms start
:: Starting pms server... [BUSY]
GUI environment no available
Switching to console mode
[main] TRACE 23:52:01.129 Starting Java PS3 Media Server v1.10.5
[main] TRACE 23:52:01.131 by shagrath / 2008-2009
[main] TRACE 23:52:01.131 http://ps3mediaserver.blogspot.com
[main] TRACE 23:52:01.131 http://code.google.com/p/ps3mediaserver
[main] TRACE 23:52:01.131
[main] TRACE 23:52:01.132 Java 1.6.0_18-Sun Microsystems Inc.
[main] TRACE 23:52:01.132 OS Linux i386 2.6.34-ARCH
[main] TRACE 23:52:01.132 Encoding: UTF-8
[main] TRACE 23:52:01.138 Temp folder: /tmp/javaps3media
[main] TRACE 23:52:01.166 Registering transcoding engine FFmpeg Audio
[main] TRACE 23:52:01.180 Registering transcoding engine MEncoder
[main] TRACE 23:52:01.180 Registering transcoding engine MPlayer Audio
[main] TRACE 23:52:01.181 Registering transcoding engine MEncoder Web
[main] TRACE 23:52:01.181 Registering transcoding engine MPlayer Video Dump
[main] TRACE 23:52:01.182 Registering transcoding engine MPlayer Web
[main] TRACE 23:52:01.185 Registering transcoding engine TsMuxer
[main] TRACE 23:52:01.185 Registering transcoding engine Audio High Fidelity
[main] TRACE 23:52:01.186 Registering transcoding engine VideoLan Audio Streaming
[main] TRACE 23:52:01.186 Registering transcoding engine VideoLan Video Streaming
[main] TRACE 23:52:01.187 Registering transcoding engine Raws Thumbnailer
[main] TRACE 23:52:01.267 Scanning network interface eth0 / eth0
[main] TRACE 23:52:01.269 Using address /192.168.1.5 found on network interface: name:eth0 (eth0) index: 2 addresses: /192.168.1.5;
[main] TRACE 23:52:01.269 Created socket: /192.168.1.5:5001
[Thread-1] TRACE 23:52:01.281 Starting DLNA Server on host 192.168.1.5 and port 5001...
[main] TRACE 23:52:01.285 Sending ALIVE...
[main] TRACE 23:52:01.296 Using following UUID: 45a7fdcf-159c-3d2d-b675-7db17eff8d18
[Thread-1] TRACE 23:52:03.782 Receiving a request from: 192.168.1.2
[Thread-1] TRACE 23:52:05.169 Receiving a request from: 192.168.1.3
[main] TRACE 23:52:06.247 It's ready! You should see the server appears on XMB
[DONE]
[flax@flax-server ~]$ [Thread-14] TRACE 23:52:16.246 Sending ALIVE...
sdf
-bash: sdf: command not found
[flax@flax-server ~]$ asd
-bash: asd: command not found
[flax@flax-server ~]$ [Thread-14] TRACE 23:52:40.932 Sending ALIVE...
[Thread-14] TRACE 23:55:44.107 Sending ALIVE...
[Thread-103] TRACE 23:57:19.812 Starting transcode/remux of Spartacus.Blood.and.Sand.S01E02.720p.HDTV.X264-DIMENSION.mkv
Offline
Pages: 1