Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

142 lines (128 sloc) 3.566 kb
#! /bin/sh
#
# /etc/init.d/pancake
#
# Author: Jan Erik Petersen <Marco01_809@web.de>
# Requires Pancake 1.3 or newer
#
### BEGIN INIT INFO
# Provides: pancake
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Pancake
# Description: Pancake HTTP Server
### END INIT INFO
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/local/sbin:/usr/sbin:/bin:/usr/local/bin:/usr/bin
DESC="Pancake HTTP Server"
NAME=pancake
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/usr/local/Pancake/sys/pancake.sh
DAEMON_ARGS="--daemon --pidfile=$PIDFILE"
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 5
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
. /lib/lsb/init-functions
# Return
# 0 if daemon is running
# 1 if daemon is not running and the pid file exists
# 3 if daemon is not running
# 4 if unable to determine status
get_status()
{
start-stop-daemon --quiet --pidfile $PIDFILE --status
}
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_start()
{
get_status && return 1
$DAEMON $DAEMON_ARGS >/dev/null || return 2
}
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
do_stop()
{
get_status || return 1
start-stop-daemon --quiet --pidfile $PIDFILE --stop --retry=TERM/30/KILL/5 || return 2
rm -f $PIDFILE
return 0
}
# Return
# 0 if SIGHUP was sent
# 1 if daemon was not running
# 2 if sending SIGHUP failed
do_reload()
{
get_status || return 1
start-stop-daemon --quiet --pidfile $PIDFILE --stop --signal HUP || return 2
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) log_end_msg 0 ;;
*) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) log_end_msg 0 ;;
*) log_end_msg 1 ;;
esac
;;
status)
get_status
status=$?
case "$status" in
0) log_action_msg "$DESC is running with PID `cat $PIDFILE`" ;;
1) log_action_msg "$DESC is not running, but $PIDFILE still exists" ;;
3) log_action_msg "$DESC is not running" ;;
*) log_failure_msg "Unable to determine status of $DESC" ;;
esac
exit $status
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1; exit 7 ;;
*) log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
*) log_end_msg 1 ;;
esac
;;
*)
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2
exit 3
;;
esac
Jump to Line
Something went wrong with that request. Please try again.