PS3 Media Server as a Linux Service

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.

Re: PS3 Media Server as a Linux Service

Postby wonslung » Thu Feb 19, 2009 8:07 pm

i don't know.....you could try
sudo sh PMS.sh console
wonslung
 
Posts: 20
Joined: Tue Feb 17, 2009 7:17 am

Re: PS3 Media Server as a Linux Service

Postby martin » Mon Feb 23, 2009 10:21 am

Hello,

maybe someone can help me. I'm using SuSE 11.1, I've done anything like this Howto, but when I'm try to start the daemon this message comes up:

Code: Select all
./PS3MediaServerd.sh: line 56: log_daemon_msg: command not found
start-stop-daemon: unrecognized option '--chuid'
Try `start-stop-daemon --help' for more information.
./PS3MediaServerd.sh: line 59: log_end_msg: command not found


My config is here:
Code: Select all
#Modify path as per your need..here is default for me..
PATH=/usr/local/sbin/pms:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin

DESC="PS3 UPnP Media Server"
NAME=PMS.sh
#Don't forget to put proper PMS folder name here.
DAEMON=/usr/local/sbin/pms/PMS.sh

# replace userid with the one ,with which access you want to run PMS..This user and group # should exist in /etc/passwd and /etc/group...
PMSUSER=1000
PMSGROUP=100

# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
{
echo "Couldn't find $DAEMON"
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 /usr/local/sbin/pms/
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

:


Currently I've no idea how to fix it. Please help.

Thanks.
Martin
martin
 
Posts: 7
Joined: Mon Feb 23, 2009 10:11 am

Re: PS3 Media Server as a Linux Service

Postby wonslung » Tue Feb 24, 2009 7:16 am

i don't know if it matters or not but i noticed that you had actual numbers on your uid and gui settings....on mine i had to use the NAME of a user
wonslung
 
Posts: 20
Joined: Tue Feb 17, 2009 7:17 am

Re: PS3 Media Server as a Linux Service

Postby sanju » Tue Feb 24, 2009 7:36 pm

martin wrote:./PS3MediaServerd.sh: line 56: log_daemon_msg: command not found
start-stop-daemon: unrecognized option '--chuid'


Run "start-stop-daemon --help" on command prompt. look for option whcih enables changing user id. In case of Ubuntu its --chuid option which instructs start-stop-daemon to run daemon with access right of provided userid/groupid. I guess, may be in suse its different option which enables that.

In case nothing works you can just remove "--chuid $PMSUSER:$PMSGROUP ", although its not recomended as in this case PMS will run as root.
sanju
 
Posts: 19
Joined: Wed Jan 28, 2009 10:31 am

Re: PS3 Media Server as a Linux Service

Postby tlc » Tue Feb 24, 2009 8:55 pm

I hope you don't mind if I piggy back on your thread, Sanju. It was very nice of you to put up your script. Here's a Freebsd script that you can enable in rc.conf.

Copy this into a file called pmsd in your /usr/local/etc/rc.d folder. BSD's use this location for userland stuff that needs to start. Make sure pmsd is xecutable. Then, edit /etc/rc.conf and add pmsd_enable="YES". I went ahead and provided start, stop, restart and status. So, after putting this in, you'll be able to say /usr/local/etc/rc.d/pmsd status to find out if it's running.

Code: Select all
#!/bin/sh

# PROVIDE: pmsd
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf to enable pmsd:
# pmsd_enable (bool):   Set to "NO" by default.
#         Set it to "YES" to enable pmsd.

# Decide whether or not to run process as root
# If root is not utilized, ensure that chosen user/group:
#   exists in /etc/passwd, /etc/group
#   has correct permissions to resources
#   has correct permissions to log/pid directories

#pmsd_user="${pmsd_user:-"pms"}"
pmsd_user="root"

. /etc/rc.subr

# script variables
#   name = service name, used by the rest of the script to build paths/etc.
#   install_dir = where pms is located
#   command_name = pms' start script
#   conf_name = pms' configuration file (not working in *nix currently)
#   stop_timeout = how long to wait after HUP to issue -9
#   stdout/err_log = standard out and standard error log locations

name="pmsd"
rcvar=`set_rcvar`
install_dir="/usr/local/pms"
command_name="PMS.sh"
conf_name="pms.conf"

pmsd_enable=${pmsd_enable-"NO"}
pmsd_stop_timeout="${pmsd_stop_timeout:-"5"}"
pmsd_stdout_log="${pmsd_stdout_log:-"/usr/local/pms/logs/stdout.log"}"
pmsd_stderr_log="${pmsd_stderr_log:-"/usr/local/pms/logs/stderr.log"}"
pmsd_pidfile="/var/run/${name}/${name}.pid"

. /etc/rc.subr

load_rc_config $name
pidfile="${pmsd_pidfile}"

# Subvert the check_pid_file procname check.
if [ -f $pidfile ]; then
  read rc_pid junk < $pidfile
  if [ ! -z "$rc_pid" ]; then
    procname=`ps -o ucomm= $rc_pid`
  fi
fi
if [ -z "$procname" ]; then
  procname=nonexistent
fi

required_files="${install_dir}/${conf_name}"
pmsd_command="${install_dir}/${command_name}"
pmsd_config="${install_dir}/${conf_name}"

log_args=">> ${pmsd_stdout_log} \
   2>> ${pmsd_stderr_log} "

#actual command to start the java app as a daemon
cd ${install_dir}
command="/usr/sbin/daemon"
flags="-p ${pidfile} -u ${pmsd_user} ${pmsd_command} ${pmsd_conf} ${log_args}"

#functions to call commandline arguments
#   start, stop, restart and status
start_cmd="pmsd_start"
start_precmd="pid_touch"
stop_cmd="pmsd_stop"
status_cmd="pmsd_status"
restart_cmd="pmsd_restart"

#create pid file for tracking process
pid_touch ()
{
   touch $pidfile
   chown $pmsd_user $pidfile
}

#not the actual start, only used for restart
pmsd_start()
{
 eval ${command} ${flags}
}

#stop the daemon
pmsd_stop() {

     read rc_pid junk < $pidfile

   if [ -z "$rc_pid" ]; then
      [ -n "$rc_fast" ] && return 0

      if [ -n "$pidfile" ]; then
         echo "${name} not running? (check $pidfile)."

      else
         echo "${name} not running?"

      fi

      return 1
   fi


   echo "Stopping ${name}."
   
   #kill HUP first to see if it can end gracefully
   kill -1 ${rc_pid} 2> /dev/null && echo "Stopped."

   #blank pidfile for next start
   echo -n > ${pidfile}
}

#wait for kill -hup to finish (implement if pms gains start/stop functionality)
pmsd_wait_max_for_pid() {

   _timeout=$1
   shift
   _pid=$1
   _prefix=

   while [ $_timeout -gt 0 ] ; do
      echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
      _prefix=", "
      sleep 2

      kill -0 $_pid 2> /dev/null || break
      _timeout=$(($_timeout-2))

   done

   if [ -n "$_prefix" ]; then
      echo "."

   fi

}

#check daemon status
pmsd_status()
{
     read rc_pid junk < $pidfile
 
   if [ $rc_pid ]; then
      echo "${name} is running as pid ${rc_pid}."
   else
      echo "${name} is not running."
   fi

}

#attempt a restart
pmsd_restart()
{
   pmsd_stop
   echo "Starting ${name}."
   pmsd_start
}

run_rc_command "$1"


I actually run the service as a user called pms, but that's a little trickier to setup. So, this example is just running as root. I wouldn't advise that. If you run as pms, you'll need to make sure that it has the correct permissions on everything.
Last edited by tlc on Fri Feb 27, 2009 3:32 am, edited 1 time in total.
tlc
 
Posts: 10
Joined: Tue Feb 24, 2009 7:03 pm

Re: PS3 Media Server as a Linux Service

Postby martin » Tue Feb 24, 2009 9:48 pm

I'll try your script tlc, thanks for that :). I'll give my feedback soon.
Thanks for your feedback Sanju. I've readed some threads in the web today, and it looks like that on Suse 11.1, not the only Problem the chuid-option from the start-stop-daemon is. It looks like that the LSB stuff in Suse is missing some parameters, so that the log option don't working also. Can't tell better, I'm no native english speaker ;).
martin
 
Posts: 7
Joined: Mon Feb 23, 2009 10:11 am

Re: PS3 Media Server as a Linux Service

Postby sk33t3r » Fri Feb 27, 2009 6:16 am

I have or had the PS3 Media server working on my windows xp machine, but I dont want to leave that thing on 24 7, my linux box is on 24 7, so I decided to try this on my CenOS box. The first problem I ran into was JAVA wasn't installed, . I intalled that by following the instructions at http://java.com/en/download/help/5000010500.xml#enable, after that ./PMS.sh started with a few errors MEcoder, I got that taken care of. Now that I got PS3MS started on my linux box I tried to watch a mkv file thats works fine from my windows machine, it says data corrupt so I tried an *.avi it plays fine. Any help would be appreciated. Also what do I ned to edit so that only my music, and video directories show up on the PS3 and not every thing??

Thanks

PS heres what i see on my linux box when trying to play these MKV files

TRACE 23:24:38.778 Starting transcode/remux of The.Day.The.Earth.Stood.Still.001.mkv
sk33t3r
 
Posts: 2
Joined: Fri Feb 27, 2009 5:34 am
Location: Houston, Texas

Re: PS3 Media Server as a Linux Service

Postby tlc » Fri Feb 27, 2009 3:43 pm

sk33t3r wrote:Now that I got PS3MS started on my linux box I tried to watch a mkv file thats works fine from my windows machine, it says data corrupt so I tried an *.avi it plays fine. Any help would be appreciated.


Can't help you there. I can't get transcoding to work at all on FreeBSD. Streaming is wonderful and works perfectly. Any calls to any transcoder ends with a mkfifo error for me. Depending upon what userid you're running pms as, you need to make sure that that user has w access to /var/tmp/javaps3media (or whatever your temp directory for pms is).

sk33t3r wrote:Also what do I ned to edit so that only my music, and video directories show up on the PS3 and not every thing??


vi <your pms install directory>/pms.conf
add/edit:
folders=/<your partition>/<your music directory>, /<your partition>/<your video directory>, etc.

The filename is case-sensitive in the *nixes, of course, so you need to determine which of either PMS.conf or pms.conf is being read.
tlc
 
Posts: 10
Joined: Tue Feb 24, 2009 7:03 pm

Re: PS3 Media Server as a Linux Service

Postby sk33t3r » Fri Feb 27, 2009 5:35 pm

I have seen several post refer to PMS.conf, but i dont see that file, there is a WEB.conf which is for web streaming. DoI need to creat a PMS.conf? And this is version 1.04


PS3MS]# ls -al
total 35172
drwxr-xr-x 3 root root 4096 Feb 26 22:54 .
drwxr-xr-x 24 root root 4096 Feb 26 23:15 ..
-rw-r--r-- 1 root root 8874 Feb 4 12:34 CHANGELOG
-rw-r--r-- 1 root root 2487065 Feb 27 10:28 debug.log
-rw-r--r-- 1 root root 6311 Dec 29 06:35 FAQ
drwxr-xr-x 2 root root 4096 Feb 26 18:35 linux
-rw-r--r-- 1 root root 16513018 Feb 4 14:54 pms.jar
-rw-r--r-- 1 root root 16906240 Feb 26 18:34 pms-linux-1.04.tar
-rwxr-xr-x 1 root root 1036 Feb 26 21:09 PMS.sh
-rw-r--r-- 1 root root 6341 Feb 1 19:02 README
-rw-r--r-- 1 root root 3037 Feb 4 14:51 WEB.conf


I can't get transcoding to work at all on FreeBSD.


is txMuxeR in your /installdir/linux dir?? and would have MEncoder in the linux dir help with transcoding?

One last thing, NANO is a much easier editor than vi
sk33t3r
 
Posts: 2
Joined: Fri Feb 27, 2009 5:34 am
Location: Houston, Texas

Re: PS3 Media Server as a Linux Service

Postby tlc » Fri Feb 27, 2009 10:44 pm

sk33t3r wrote:I have seen several post refer to PMS.conf, but i dont see that file, there is a WEB.conf which is for web streaming. DoI need to creat a PMS.conf? And this is version 1.04


pms.conf is only built on the gui versions of the software. Hopefully, this will be corrected soon. Here's one I stole from a thread here:

Code: Select all
folders = /disk1/stuff, /disk2/stuff2
hostname =
port = 5010
language = en
thumbnails = true
thumbnail_seek_pos = 1
nbcores = 2
turbomode = false
minimized = false
hidevideosettings = false
usecache = false
charsetencoding = 850
engines = mencoder,avsmencoder,tsmuxer,mplayeraudio,ffmpegaudio,tsmuxeraudio,vlcvideo,mencoderwebvideo,mplayervideodump,mplayerwebaudio,vlcaudio,ffmpegdvrmsremux
autoloadsrt = true
avisynth_convertfps = true

avisynth_script = #AviSynth script is now fully customisable !\u0001#You must use the following variables (\"clip\" being the avisynth variable of the movie):\u0001#<movie>: insert the complete DirectShowSource instruction [ clip=DirectShowSource(movie, convertfps) ]\u0001#<sub>: insert the complete TextSub\/VobSub instruction if there's any detected srt\/sub\/idx\/ass subtitle file\u0001#<moviefilename>: variable of the movie filename, if you want to do all this by yourself\u0001#Be careful, the custom script MUST return the clip object\u0001<movie>\u0001<sub>\u0001return clip

transcode_block_multiple_connections = false
tsmuxer_forcefps = true
tsmuxer_preremux_pcm = false
tsmuxer_preremux_ac3 = false
audiochannels = 6

audiobitrate = 384
maximumbitrate = 0

skiploopfilter = false
enable_archive_browsing = false

mencoder_fontconfig = false
mencoder_font =
mencoder_forcefps = false
mencoder_usepcm = false
mencoder_intelligent_sync = true
mencoder_decode =
mencoder_encode = keyint=1:vqscale=1:vqmin=2
mencoder_nooutofsync = true
mencoder_audiolangs = fre,jpn,ger,eng
mencoder_sublangs = fre,eng
mencoder_audiosublangs =
mencoder_subfribidi = false
mencoder_ass_scale = 1.0
mencoder_ass_margin = 10
mencoder_ass_outline = 1
mencoder_ass_shadow = 1
mencoder_noass_scale = 3
mencoder_noass_subpos = 2
mencoder_noass_blur = 1
mencoder_noass_outline = 1
mencoder_subcp = cp1252
mencoder_ass = false
mencoder_disablesubs = false
mencoder_yadif = false
mencoder_scaler = false
mencoder_scalex = 0
mencoder_scaley = 0

ffmpeg = -g 1 -qscale 1 -qmin 2

mencoder_mt = false


I changed the port to 5010 (from the default of 5001) so that you know it is reading the conf file with sockstat -4 |grep 5010. If your conf is working, then that should return the listing for java/pms.

sk33t3r wrote:is txMuxeR in your /installdir/linux dir?? and would have MEncoder in the linux dir help with transcoding?


It sure is. I only messed around with it a little. Honestly, I haven't played around with it, because most of my stuff doesn't need transcoding. Maybe I'll try moving my MEncoder over the linux dir. That's not a bad suggestion.

sk33t3r wrote:One last thing, NANO is a much easier editor than vi


Indeed. :P But, you also don't get macros or multiple-buffers. I've got nothing against alpine/nano. In fact, I used pine all throughout college, and now I use alpine for mail on the server (it's even tied to my gmail acct/contacts via imap). I just am tied to vi, because I know that it's going to be on every *nix box I'll ever work on.
tlc
 
Posts: 10
Joined: Tue Feb 24, 2009 7:03 pm

PreviousNext

Return to Linux/Unix Support

Who is online

Users browsing this forum: No registered users and 3 guests