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 timpootle » Thu Dec 16, 2010 4:18 pm

I am trying a slightly different hack. The runlevel was a red herring, but it is beyond my capability to prevent PMS from running until after network connection. The problem is compounded by Network-Manager requiring me to log in to Gnome before starting up.

My current thinking is a PHP file on my webserver (same machine as mediaserver) which will restart PMS when I click on it from the PS3 browser. Something like this:
Code: Select all
tim@bigbluelinux:/var/www$ cat pmsrestart.php
<?php
echo "hello";
echo exec ("/etc/init.d/pms-linux restart");
?>


Now I'm having problems with permissions. Normally I run "sudo /etc/init.d/pms-linux restart" but obviously I don't want to give the webserver sudo rights, so I have tried to CHOWN and CHGROUP the PMS files to the webuser, www-data. So far I have changed /var/run/pmslinux.pid but I still get
Code: Select all
/etc/init.d/pms-linux: line 93: kill: (2258) - Operation not permitted
rm: cannot remove `/var/run/pms-linux.pid': Permission denied
Warning: pms-linux is already running !


This is a lot of work for a dirty hack which shouldn't even be necessary.

Lostar - what did you mean by "he-he... speedup boot" ? I can only see your code slowing down boot time, not speeding it up. Please excuse my ignorance. I wasn't sure where to put your code, so I haven't tried it at all. My startup script doesn't have a block "case '$1' in start)" , only "case '$1' in start|stop|force-stop)" . Is this where your code should go, or in a separate block of its own?
timpootle
 
Posts: 4
Joined: Thu Nov 25, 2010 7:07 pm
Location: Altrincham, UK

Re: PS3 Media Server as a Linux Service

Postby Sixcurses » Mon May 23, 2011 6:01 pm

WorldOfHurt wrote:
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

post for download: viewtopic.php?f=3&t=154&start=40

this script will also work on ubuntu (11.04) with PMS.conf if you change the following
Code: Select all
do_start()
{
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started
   start-stop-daemon --background --start --quiet --chuid $PMSUSER:$PMSGROUP --pidfile $PIDFILE --make-pidfile --exec $DAEMON --test > /dev/null \
      || return 1
   start-stop-daemon --background --start --quiet --chuid $PMSUSER:$PMSGROUP --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- \
      $DAEMON_ARGS > /dev/null \
      || return 2
   # Add code here, if necessary, that waits for the process to be ready
   # to handle requests from services started subsequently which depend
   # on this one.  As a last resort, sleep for some time.
}

To
Code: Select all
do_start()
{
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started
   start-stop-daemon --background --start --quiet --chdir $PMS_ROOT --chuid $PMSUSER:$PMSGROUP --pidfile $PIDFILE --make-pidfile --exec $DAEMON --test > /dev/null \
      || return 1
   start-stop-daemon --background --start --quiet --chdir $PMS_ROOT --chuid $PMSUSER:$PMSGROUP --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- \
      $DAEMON_ARGS > /dev/null \
      || return 2
   # Add code here, if necessary, that waits for the process to be ready
   # to handle requests from services started subsequently which depend
   # on this one.  As a last resort, sleep for some time.
}


by adding --chdir $PMS_ROOT you ensure that it loads your config file otherwise it will start at / instead of your folder for example /media/video orso.

hope it helps someone
Sixcurses
 
Posts: 2
Joined: Sun Apr 24, 2011 1:04 pm

Re: PS3 Media Server as a Linux Service

Postby sshambar » Sun May 29, 2011 9:40 am

Here's my configuration for setting up the PMS (1.23) on Fedora 15 as a background service running as unprivileged user 'pms' -- I've tried to leave the downloaded code as unchanged as possible...

You need to yum localinstall libzen0 and libmediainfo0 from http://mediainfo.sourceforge.net/en/Download/Fedora (atm, only F14 versions are available, but they work).

Also, yum install mencoder, java-1.6.0-openjdk and jna (jna is needed if you have /var mounted noexec, more on this later)

Download pms-generic-linux-unix-1.23.0.tgz (current version) and pms-config.tgz (attached to this post) to /var/tmp

Save pms-setup.tgz (attached), extract it, and then run the file (./pms-setup.sh)

The pms-setup.sh script will:
* create the pms user and group (home /opt/ps3mediaserver)
* extract /var/tmp/pms-config.tgz, creating directories /etc/opt/ps3mediaserver and /var/opt/ps3mediaserver, and the startup script in /etc/systemd/system
* extract /var/tmp/pms-generic-linux-unix-1.23.0.tgz in /opt
* create the link /opt/ps3mediaserver to the install in /opt
* fix logging configuration, and create a few links for DLNA cache and convenience
* install/enable the start script

You can then edit /etc/opt/ps3mediaserver/conf/PMS.conf (use the supplied default.conf file as a reference), and then start the service using:
Code: Select all
systemctl start ps3mediaserver.service

(or reboot, since the service is now enabled)

Result: All configuration is under /etc, all logs/databases are under /var, all code is under /opt.

NOTE #1: By default, PMS attempts to load the logging configuration file logback.headless.xml in the working directory (/opt/ps3mediaserver) - since the logging config distributed with PMS is not ideal for a headless setup, the setup script (above), moves it aside, and uses a supplied one: /etc/opt/ps3mediaserver/logback.headless.xml. Edit that file if you wish to alter logging.

NOTE #2: java's native library loader will attempt extract/link a copy of libjnidispatch.so in the 'java.io.tmpdir' directory to use in loading native libraries (like libmediainfo). Since /var is commonly mounted noexec, you might need to install the jna package (which includes libjnidispatch.so); that combined with the LD_LIBRARY_PATH set in the attached pms-config.tgz will prevent java extracting/linking to /var (since it would fail if it's noexec).

If you install an update, you should only need to run the "After each install/upgrade" section of the pms-setup.sh script.

Hope you find it useful :)

Scott
Attachments
pms-setup.tgz
(544 Bytes) Downloaded 212 times
pms-config.tgz
(2.9 KiB) Downloaded 234 times
sshambar
 
Posts: 1
Joined: Sat May 28, 2011 9:59 pm

Re: PS3 Media Server as a Linux Service

Postby ryman » Sat Jan 21, 2012 11:58 pm

Scott, thank you very much for the post on creating the PS3 media server for F15. Your install and setup was very strait forward and simple to follow.

I have it set up and running on my ps3 and changed the search folder to my /home folder. But I am unable to browse the folders within my /home location. I have added the user 'pms' to my group within /etc/group and made sure my home folder has read/execute access for groups. But I am still unable to browse the folders from the PS3.

Thank you in advance for any help.
ryman
 
Posts: 1
Joined: Sat Jan 21, 2012 11:41 pm

Re: PS3 Media Server as a Linux Service

Postby dmbkiwi » Mon Feb 06, 2012 8:22 am

lordemsworth wrote:I'm not much of an expert to be able to break down those init files, but one thing you could do if you started the program from command line - use nohup.
That way when you logged out of your ssh session, PS3 Media Server would still be running.

bash prompt> nohup <path to PMS.sh>/PMS.sh
I know that this isn't the perfect solution - but you're going to need someone better versed in the scripts to help you.

Amir


If you're struggling with starting pms as a daemon, have a look at this article which breaks down some different options for running pms as a daemon:

http://everydaylht.com/howtos/multimedi ... amsung-tv/
dmbkiwi
 
Posts: 1
Joined: Mon Feb 06, 2012 8:19 am

Previous

Return to Linux/Unix Support

Who is online

Users browsing this forum: No registered users and 4 guests