#!/bin/sh # /*******************************************************************************/ # /* */ # /* Copyright 2004 Pascal Gloor */ # /* */ # /* Licensed under the Apache License, Version 2.0 (the "License"); */ # /* you may not use this file except in compliance with the License. */ # /* You may obtain a copy of the License at */ # /* */ # /* http://www.apache.org/licenses/LICENSE-2.0 */ # /* */ # /* Unless required by applicable law or agreed to in writing, software */ # /* distributed under the License is distributed on an "AS IS" BASIS, */ # /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ # /* See the License for the specific language governing permissions and */ # /* limitations under the License. */ # /* */ # /*******************************************************************************/ WDIR="%PATH%"; PIRANHA="${WDIR}/bin/piranha"; CONFIG="${WDIR}/etc/piranha.conf"; PIDFILE="${WDIR}/var/piranha.pid"; case "$1" in start) printf 'piranha start: '; if [ -x ${PIRANHA} ] then if [ -r ${CONFIG} ] then ${PIRANHA} ${CONFIG} && echo "ok"; else echo "piranha fatal error, cannot find ${CONFIG}"; fi else echo "piranha fatal error cannot exec ${PIRANHA}"; fi ;; stop) printf 'piranha stop : '; if [ -r ${PIDFILE} ] then PID=`cat ${PIDFILE}`; if [ -n "${PID}" ] then kill -9 ${PID} && echo "ok"; else echo "piranha fatal error invalid PID '${PID}'"; fi else echo "piranha fatal error cannot find pid file ${PIDFILE}"; fi ;; reload) printf 'piranha reload : '; if [ -r ${PIDFILE} ] then PID=`cat ${PIDFILE}`; if [ -n "${PID}" ] then kill -1 ${PID} && echo "ok"; else echo "piranha fatal error invalid PID '${PID}'"; fi else echo "piranha fatal error cannot find pid file ${PIDFILE}"; fi ;; restart) $0 stop; $0 start; ;; *) echo "$0 { start | stop | reload | restart }" ;; esac