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 WorldOfHurt » Thu Jan 07, 2010 12:04 am

lordemsworth wrote:if you would be so kind, it would be appreciated.

Amir


Voila

NOTE: You'll need to sort out the user:group stuff and the PMS_ROOT path to the pms root dir
Attachments
ps3msd.zip
/etc/init.d/ps3msd script for linux
(1.8 KiB) Downloaded 532 times
User avatar
WorldOfHurt
 
Posts: 252
Joined: Thu Mar 19, 2009 10:49 pm
Location: Winchester, UK

Re: PS3 Media Server as a Linux Service

Postby lordemsworth » Thu Jan 07, 2010 5:28 am

Thank you.
lordemsworth
 
Posts: 28
Joined: Wed Jan 06, 2010 7:22 am

Re: PS3 Media Server as a Linux Service

Postby Umbra » Thu Jan 07, 2010 12:28 pm

I have a small problem with the script when i run ./PS3MediaServerd
i get this :
./PS3MediaServerd: line 1: /bin/: is a directory
Usage: {start|stop}

But i dont even have /bin/: in the file...
This is my path settings :
PATH=/home/umbra/Skrivbord/Xbox360/pms-linux-1.11.369/ps3mediaserver-read-only/ps3mediaserver

DESC="PS3 UPnP Media Server"
NAME=PMS.sh
#Don't forget to put proper PMS folder name here.
DAEMON=/home/umbra/Skrivbord/Xbox360/pms-linux-1.11.369/ps3mediaserver-read-only/ps3mediaserver/PMS.sh
Umbra
 
Posts: 121
Joined: Wed Jan 06, 2010 11:32 pm

Re: PS3 Media Server as a Linux Service

Postby brainspank » Wed Jan 27, 2010 3:09 am

Umbra wrote:I have a small problem with the script when i run ./PS3MediaServerd
i get this :
./PS3MediaServerd: line 1: /bin/: is a directory
Usage: {start|stop}


probably a copy/paste error.

edit the script. look at the first line, it probably looks like this:
Code: Select all
/bin/


change it to look like this:
Code: Select all
#!/bin/sh
brainspank
 
Posts: 2
Joined: Wed Jan 27, 2010 2:51 am

Re: PS3 Media Server as a Linux Service

Postby igor2711 » Tue Feb 09, 2010 4:12 pm

Hi, besten Dank an alle die mitmachen - vor allem an WorldofHurt für sein Init Script.

Bin Anfänger und habe es Dank eurer HIlfe geschafft - will nur alle die Probleme haben ermuntern - es geht doch.

Eine Frage: wie ich PS3MS installiert habe konnte ich Verzeichnisse einschränken, um auf der PS3 nicht durch einen endlosen Verzeichnis-Baum navigieren zu müssen. Dabei ist der neue Folder (mit Musik) eingetragen in *.conf (folder = \/home\/medien) - alles bestens.

Jetzt starte ich den MS mit dem Script und habe den ganzen Baum wieder obwohl sich im conf Script nichts verändert hat.

Kann wer helfen - was habe ich falsch gemacht bzw. vergessen?

Besten Dank im Voraus,
igor
igor2711
 
Posts: 3
Joined: Tue Feb 09, 2010 4:05 pm

Re: PS3 Media Server as a Linux Service

Postby igor2711 » Tue Feb 09, 2010 4:27 pm

SORRY, stupid me - I did not notice the language in the forum - sorry guys... this is how tired and fed up one can get...

In a nutshell:

Thanks to WorldofHurt for his inits script - i am a absolute beginner and with your help managed to get it up and running.

Even as a service starting at boot. One thing though:

in the fancy GUI i could choose the media directory, it worked fine and I did not have to navigate for ages in the directory tree to get to the media files as after the initial installation. In the *.conf there was a line (and still is) "folder=\/home\/media". When I start the ps3ms now as a service with the script it works fine but i again have to dig deep through the dir structure as before.

All hints greatly appreciated,
thanks in advance, igor

ps. by the way: my conf file has only five line... should I really paste all the lines from references that yould be found in the forum?
igor2711
 
Posts: 3
Joined: Tue Feb 09, 2010 4:05 pm

Re: PS3 Media Server as a Linux Service

Postby WorldOfHurt » Tue Feb 09, 2010 11:24 pm

Just an update as it seems to be causing some confusion...

To use the debian init.d script I posted previously, you need to modify the PMS.sh file.

Because the init daemon has no working dir, you have to make sure it is working in the pms installation dir before it runs up the java. The java code expects the .conf files to be in the same working dir when it starts up.

So, the last 2 lines of the PMS.sh script have to look like this:
Code: Select all
cd $PMS_ROOT
exec "$JAVA" $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -classpath "$PMS_JARS" net.pms.PMS "$@"


Note there is NO AMPERSAND on the end of the exec line, because that breaks the pidfile mechanism in the init script.

If you get this wrong, it will probably start up ok, but since it fails to load the pms.conf file ('cos it can't find it) you will find the path configuration is ignored and the PS3 will show the whole dir tree of your server, all the way from root.

And lastly, if you use a separate user/group for the pms daemon, remember to set the permissions up so it can read the conf files, execute the PMS.sh script, write to the database AND read your media directories... ;) The easiest way to test this is with "su ..." and then trying to access/execute the relevant item.

So endeth the lesson. All hail PS3 Media Server. :D
User avatar
WorldOfHurt
 
Posts: 252
Joined: Thu Mar 19, 2009 10:49 pm
Location: Winchester, UK

Re: PS3 Media Server as a Linux Service

Postby igor2711 » Tue Feb 09, 2010 11:34 pm

Thanks WoH,
it works - i just tested it with user root and it worked like a charm. now i will work bottom up until i find the missing permission for a "normal" user...

great forum - saved my day.... cheers, i.
igor2711
 
Posts: 3
Joined: Tue Feb 09, 2010 4:05 pm

Re: PS3 Media Server as a Linux Service

Postby skamansam » Fri Jul 23, 2010 4:37 pm

The previous init script which was posted did not work for me, as I am running Fedora 13. This is my script, which can be easily adapted to other programs.

/******************* /etc/init.d/ps3mediaserver ***********************************/

#!/bin/sh
#
# chkconfig: - 91 50
# description: Starts and stops the ps3mediaserver
# pidfile: /opt/ps3mediaserver/ps3mediaserver.pid
# config: /opt/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
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='ps3mediaserver'

# Where PMS.sh is located
PMS_DIR='/opt/ps3mediaserver'

#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=/opt/ps3mediaserver/PMS.conf

#the log file. stderr and stdout are redirected to this file.
LOG_FILE=/var/log/ps3mediaserver.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=/opt/ps3mediaserver/ps3mediaserver.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/ps3mediaserver


###############################
# 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


/******************* end /etc/init.d/ps3mediaserver ***********************************/

I hope you all benefit from this! If you want to adjust this for another program, simply edit the beginning of the file and be careful not to edit past where it says not to!
skamansam
 
Posts: 1
Joined: Thu Jul 22, 2010 6:19 pm

Re: PS3 Media Server as a Linux Service

Postby lordemsworth » Tue Aug 03, 2010 6:26 am

Thanks for the script.

Does anyone know how to make this run as non-root?

Amir
lordemsworth
 
Posts: 28
Joined: Wed Jan 06, 2010 7:22 am

PreviousNext

Return to Linux/Unix Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests