New "Debian/Ubuntu" init.d script procedure for PS3MS

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.

New "Debian/Ubuntu" init.d script procedure for PS3MS

Postby carlettod » Tue Apr 24, 2012 11:33 am

Hello,
I have long used PS3MediaServer as daemon on my Ubuntu headless systems (from 10.04 to 11.10).
Recently I installed the program with deb package (thanks happy.neko) without any problem.
However I noticed that the start/stop procedure uses a very obsolete init script and new requirements from users may not be met.

Starting from the "skeleton initscript" of Debian as template, I therefore decided to fully rewrite the procedure to meet my requirements and those of other forum users.

The new procedure is suitable for both "deb package" and "traditional package" versions.

The difficult part was adapting procedure to java process management of PS3 Media Server, while sticking to the LSB standard and its related return codes.

The new init procedure has the following features and advantages:
- a very clear and simple structure of the two files (initscript and default);
- its full compatibility with the LSB standard (both Debian, Ubuntu and derivates);
- full PIDFILE support;
- the presence of the PIDFILE allows to identify the correct java daemon process of PS3 Media Server in order to avoid confusion with other instances of same program started from the GUI;
- full support of LSB "log_*" message functions;
- full support for the "start-stop-daemon" procedure (both in the start and stop of the daemon);
- high reliability in case of crash of java processes of PS3 Media Server.
- management and correct use of the "PMS_PROFILE" environment variable – this is read by PS3 Media Server when it starts (variable "P3MS_PROFILE" in the old initscript was wrong);
- shift of all PS3 Media Servers specific variables to "/etc/default/ps3mediaserver" file with full detailed instructions;
- opportunity to run the daemon with a different user in only three simple steps (described in file "/etc/default/ps3mediaserver");
- in accordance with the Debian standard, configuration files of daemons necessarily need to be placed in /etc subfolder. So in the new procedure files of system profile ("PMS.conf" and WEB.conf") are now read as default directly from folder "/etc/ps3mediaserver" (that is suitables for happy.neko deb package);
- Variables values are based on files structure of happy.neko deb package. If user want change location (e.g. "/opt/ps3mediaserver" - to use the initscript with downloaded linux package from PS3MS web site), it has to change only three variables: "PMS_PROFILE" variable in "/etc/default/ps3mediaserver" file; "NAME" and "DAEMON" variables in "/etc/init.d/ps3mediaserver" file; if you change the variable "NAME" please be careful to rename "/etc/default/ps3mediaserver" file also;
- for headless mode (daemon need this) now it uses "JAVA_OPT" variable with value "-Djava.awt.headless=true" that, based on my experience, in presence of some particular graphical environment, is more reliable than "DAEMON_OPTS" variable with value "console".

For one month or so, I have been testing this procedure on my Ubuntu 11.10 (64bit) headless system in all possible instances (start, stop, status, restart, "restart" in case of daemon crash, "stop" in case of running a multimedia stream) without any problem having been found.

It would be necessary to test the procedure on other systems: Debian 6, older and new (12.04) versions of Ubuntu and some derivates.

As my personal contribution to forum, please find attached in "ps3ms_init.zip" the two files I rewrote entirely:

- "ps3mediaserver.init" to be renamed as "/etc/init.d/ps3mediaserver";
- "ps3mediaserver.default" to be renamed as "/etc/default/ps3mediaserver".

I hope that my work will be instrumental in the improvement of PS3 Media Server project.

Waiting for your test results and opinions

Thanks
Carlo
Attachments
ps3ms_init.zip
(2.56 KiB) Downloaded 534 times
carlettod
 
Posts: 10
Joined: Wed Feb 01, 2012 11:49 am

Re: New "Debian/Ubuntu" init.d script procedure for PS3MS

Postby caitsith01 » Sat May 05, 2012 3:52 pm

Hi - I am trying to sort out a solution for a setup where I want PMS running on an ethernet connection which comes and goes - at present this causes instability/crashes with a manually started version of PMS.

Would your script cover this scenario?
caitsith01
 
Posts: 2
Joined: Thu Apr 26, 2012 1:18 am

Re: New "Debian/Ubuntu" init.d script procedure for PS3MS

Postby carlettod » Sat May 05, 2012 6:26 pm

My script does not handle the network status.
It manages only the start and stop routine and the necessary variables.

You can try before with my script for start/stop of the daemon avoiding manual start.
If you have same problem, you can try with following solution.

To avoid the crash of the PMS daemon, you can create a script that stops the daemon when the network is down and put it in the "/etc/network/if-down.d/" folder.
You can also create another script to start the daemon when network came back up and put it in the "/etc/network/if-up.d" folder.

The structure of this script is similar to that of mine.
You can use as template those already present in these folders.

Bye
Carlo
carlettod
 
Posts: 10
Joined: Wed Feb 01, 2012 11:49 am

Re: New "Debian/Ubuntu" init.d script procedure for PS3MS

Postby happy.neko » Sun May 13, 2012 8:14 pm

Hi, arlettod.

I want to thank you for your contribution and say that your init.d script (with small changes) is now included in deb package.

viewtopic.php?f=3&t=13046&start=110#p69211
happy.neko
Project Member
 
Posts: 478
Joined: Fri Sep 23, 2011 5:38 pm

Re: New "Debian/Ubuntu" init.d script procedure for PS3MS

Postby carlettod » Mon May 14, 2012 9:46 am

You're welcome.
Thanks for your confidence.
If you need, I remain available for updates, changes and tests.

Bye
Carlo
carlettod
 
Posts: 10
Joined: Wed Feb 01, 2012 11:49 am


Return to Linux/Unix Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests