Fedora 11 server init script

Hi All,
I have installed this great piece of software to a directory /usr/local/ps3mediaserver and have written the following init script to work with Fedora 11's initscripts package. Well, not really written, just hacked the start script for samba
This script works for me, and I thought I should share it. Feel free to use and change as you need to.
This file was created at /etc/init.d/ps3mediaserver and was installed using
To PMS.sh, I added the following to near the start of the file
The last line of the PMS.sh was also changed. The exec and the quotes around the $JAVA were removed, the setting for headless was added, some logging to /var/log/ps3mediaserver.log and the & to make the process run in the background. The line now looks like
now the service can be started by
stopped with
restarted with
and check the status with
and turned on at boot with
Make sure the $JAVA_HOME you put in the PMS.sh file is correct for your system.
If you use a different directory to install the software to, change the $PROG_ROOT var
If you use a different script to the usual PMS.sh script, change $PROG_EXEC var
if the java class file ever changes from pms.jar, change $PROG_JAR
i think that just about sums it up. hope this helps some of you out there...
bags1
I have installed this great piece of software to a directory /usr/local/ps3mediaserver and have written the following init script to work with Fedora 11's initscripts package. Well, not really written, just hacked the start script for samba

- Code: Select all
#!/bin/sh
#
# chkconfig: - 91 50
# description: Starts and stops the ps3mediaserver
# pidfile: /usr/local/ps3mediaserver/ps3mediaserver.pid
# config: /usr/local/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.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
PROG_NAME='ps3mediaserver'
PROG_ROOT='/usr/local/ps3mediaserver'
PROG_JAR='pms.jar'
PROG_EXEC='PMS.sh'
RETVAL=0
start() {
KIND="$PROG_NAME"
echo -n $"Starting $KIND services: "
cd $PROG_ROOT
daemon $PROG_ROOT/$PROG_EXEC
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && echo `ps o pid,args|grep $PROG_JAR|grep -v grep|awk {'print $1'}` > $PROG_ROOT/$PROG_NAME.pid || \
RETVAL=1
return $RETVAL
}
stop() {
KIND="$PROG_NAME"
echo -n $"Shutting down $KIND services: "
killproc -p $PROG_ROOT/$PROG_NAME.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $PROG_ROOT/$PROG_NAME.pid
return $RETVAL
}
restart() {
stop
start
}
rhstatus() {
status -p $PROG_ROOT/$PROG_NAME.pid $PROG_NAME
return $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rhstatus
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac
exit $?
This file was created at /etc/init.d/ps3mediaserver and was installed using
- Code: Select all
chkconfig --add ps3mediaserver
To PMS.sh, I added the following to near the start of the file
- Code: Select all
export JAVA_HOME=/opt/SDK/jdk
export PATH=$JAVA_HOME/bin:$PATH
The last line of the PMS.sh was also changed. The exec and the quotes around the $JAVA were removed, the setting for headless was added, some logging to /var/log/ps3mediaserver.log and the & to make the process run in the background. The line now looks like
- Code: Select all
$JAVA $JAVA_OPTS -Xmx768M -Djava.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -classpath "$PMS_JARS" net.pms.PMS "$@" >>/var/log/ps3mediaserver.log 2>>/var/log/ps3mediaserver.log &
now the service can be started by
- Code: Select all
service ps3mediaserver start
stopped with
- Code: Select all
service ps3mediaserver stop
restarted with
- Code: Select all
service ps3mediaserver restart
and check the status with
- Code: Select all
service ps3mediaserver status
and turned on at boot with
- Code: Select all
chkconfig --level 2345 ps3mediaserver on
Make sure the $JAVA_HOME you put in the PMS.sh file is correct for your system.
If you use a different directory to install the software to, change the $PROG_ROOT var
If you use a different script to the usual PMS.sh script, change $PROG_EXEC var
if the java class file ever changes from pms.jar, change $PROG_JAR
i think that just about sums it up. hope this helps some of you out there...
bags1