#! /bin/bash # ---------------------------------------------------------------------------- # /etc/init.d/pms - PMS init script # # Creation : 2011-06-02 starwarsfan # Last update: $Id$ # # Copyright (c) 2011 the eisfair team, # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ---------------------------------------------------------------------------- #exec 2> `pwd`/pms-init-trace$$.log #set -x # Include functions . /etc/init.d/functions . /lib/lsb/init-functions DESC="PS3 UPnP Media Server" NAME=PMS.sh # PMS folder name DAEMON=/data/packages/pms/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=root PMSGROUP=root # 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 PMS_FOLDER 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