Thanks to all the people who have put their time and effort into getting this software to work, also on a headless linux machine. This was exactly what I was looking for. But obviously, I'm posting here because I have a bit of a problem.

I'm running Ubuntu Jaunty with a 2.6.28-11-server kernel (headless), and I try to get as much of the software through the apt repository, since that makes it easy to manage. The problem: I can run PMS.sh without a problem, and it seems that most of the codecs work (haven't tried everything yet, but avi, mkv, mp3 and jpg I have tested successfully so far, and if I have other codec problems, I will dig into it myself first), but I can't run the software through the init.d script that has been provided in this thread. That's to say, it will run, but apparently it doesn't find my PMS.conf file, which it does find when running the software directly from the command line.
I've basically used most of kes' setup, only modifying the things that are different for my setup. I really can't find what's wrong.
My PS3MediaServerd:
- Code: Select all
#! /bin/sh
### BEGIN INIT INFO
# Provides: pms
# Required-Start: $network $local_fs $remote_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PS3 UPnP Media Server
### END INIT INFO
# Source init-functions:
source /lib/lsb/init-functions
# Script variables:
MONTH=`date +%Y-%m`
PMS_ROOT="/usr/src/pms-linux-1.10.5"
PMS_LOG="/var/log/pms/pms-$MONTH.log"
DESC="PS3 UPnP Media Server"
NAME="PMS.sh"
# Path to executable:
DAEMON="$PMS_ROOT/$NAME"
# Run as user/group [UPDATE THESE TO MAKE VALID]:
PMSUSER=kryz
PMSGROUP=kryz
# update PATH:
PATH="$PMS_ROOT:${PATH:+$PATH:}/usr/sbin:/sbin"
# export env-vars
export PATH PMS_ROOT PMS_LOG
# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then {
echo "Couldn't find $DAEMON or not executable"
exit 99
}
fi
#
# Function that starts the daemon/service
#
do_start() {
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
cd "$PMS_ROOT"
start-stop-daemon --start --quiet --chuid $PMSUSER:$PMSGROUP --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --chuid $PMSUSER:$PMSGROUP --exec $DAEMON \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop() {
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --signal 2 --retry 5 --quiet --name java
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
return "$RETVAL"
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop}" >&2
exit 3
;;
esac
exit 0
My PMS.sh:
- Code: Select all
#!/bin/sh
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
# Sanitycheck environment
[ "x$PMS_ROOT" = "x" ] && echo "[ERROR] Environment variable 'PMS_ROOT' not set properly!" && exit 1
[ "x$PMS_LOG" = "x" ] && echo "[ERROR] Environment variable 'PMS_LOG' not set properly!" && exit 1
# Execute the JVM
exec "$JAVA" $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -jar "$PMS_JAR" "$@" 2>&1 >> "$PMS_LOG" &
A few notes:
- My JAVA_HOME environment variable is set and correct.
- PMS.sh is executable for the user in the init script (kryz).
- PMS.conf is in the /usr/src/pms-linux-1.10.5 directory.
- I don't get any specific errormessages when running the init script, other than a very clear hint that ; this is what the log file (in var/log/pms) says:
- Code: Select all
[main] TRACE 18:37:23.068 Error in accessing debug.log...
[main] TRACE 18:37:23.070 Using temp folder for debug.log...
GUI environment no available
Switching to console mode
[main] TRACE 18:37:23.201 Starting Java PS3 Media Server v1.10.5
[main] TRACE 18:37:23.202 by shagrath / 2008-2009
[main] TRACE 18:37:23.202 http://ps3mediaserver.blogspot.com
[main] TRACE 18:37:23.202 http://code.google.com/p/ps3mediaserver
[main] TRACE 18:37:23.203
[main] TRACE 18:37:23.203 Java 1.6.0_16-Sun Microsystems Inc.
[main] TRACE 18:37:23.203 OS Linux amd64 2.6.28-11-server
[main] TRACE 18:37:23.204 Encoding: UTF-8
[main] TRACE 18:37:23.204 Temp folder: /tmp/javaps3media
[main] TRACE 18:37:23.304 Registering transcoding engine FFmpeg Audio
[main] TRACE 18:37:23.324 Registering transcoding engine MEncoder
[main] TRACE 18:37:23.325 Registering transcoding engine MPlayer Audio
[main] TRACE 18:37:23.326 Registering transcoding engine MEncoder Web
[main] TRACE 18:37:23.327 Registering transcoding engine MPlayer Video Dump
[main] TRACE 18:37:23.327 Registering transcoding engine MPlayer Web
[main] TRACE 18:37:23.332 Registering transcoding engine TsMuxer
[main] TRACE 18:37:23.333 Registering transcoding engine Audio High Fidelity
[main] TRACE 18:37:23.334 Registering transcoding engine VideoLan Audio Streaming
[main] TRACE 18:37:23.335 Registering transcoding engine VideoLan Video Streaming
[main] TRACE 18:37:23.335 Registering transcoding engine Raws Thumbnailer
[main] TRACE 18:37:23.562 Scanning network interface eth0 / eth0
[main] TRACE 18:37:23.565 Using address /192.168.0.2 found on network interface: name:eth0 (eth0) index: 2 addresses: /192.168.0.2;
[main] TRACE 18:37:23.566 Created socket: /192.168.0.2:5001
[Thread-1] TRACE 18:37:23.594 Starting DLNA Server on host 192.168.0.2 and port 5001...
[main] TRACE 18:37:23.602 Sending ALIVE...
[main] TRACE 18:37:23.649 Using following UUID: 77b62f5c-743d-318b-914a-691511738ca5
[main] TRACE 18:37:27.498 It's ready! You should see the server appears on XMB
[Thread-4] TRACE 18:37:37.494 Sending ALIVE...
[Thread-4] TRACE 18:38:02.416 Sending ALIVE...
It's clear here that the 'cd' command simply hasn't worked, so we're not in the PMS_ROOT directory. Another hint that this did not work is the following:
- Code: Select all
kryz@orcrist:~$ /etc/init.d/PS3MediaServerd start
/etc/init.d/PS3MediaServerd: 13: source: not found
/etc/init.d/PS3MediaServerd: 94: log_daemon_msg: not found
/etc/init.d/PS3MediaServerd: 94: log_end_msg: not found
For some reason, the source command used in the script cannot be executed. And the other two errors, I don't know, my scripting / linux knowledge is far too basic.
Anyone able to help me out?
Small edit, as stipulated by the smart people of tweakers.net: source is a /bin/bash internal executable, and doesn't work under /bin/sh (unless /bin/sh is merely a symlink to /bin/bash), so I just changed the shebang to #!/bin/bash, and now I don't get the source / log_daemon_msg / log_end_msg errors anymore. But the core issue is not solved yet.
Edit 2: I've found the cause for the issue. For some reason, when in the init script, the current dir is indeed de PMS directory, but when in PMS.sh, pwd is /. I thought the 'if' statement in the PMS.sh would do something with that, but only now I get that it doesn't, so I just added a 'cd "$PMS_HOME"' line in the script, and everything seems to work. If anyone would like to see my new and improved versions of the scripts, don't hesitate to ask. I won't put them in this post now, since it's already full with the problem scripts.
