提交 489fab3e 编写于 作者: K kohsuke

Integrated the scripts contributed by Amelia Lwis <alewis@tibco.com>



git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9346 71c3de6d-444a-0410-be80-ed276b4c234a
上级 d1e51821
# Defaults for hudson initscript
# sourced by /etc/init.d/hudson
# installed at /etc/default/hudson by the maintainer scripts
# defaults for hudson continuous integration server
#
# This is a POSIX shell fragment
#
# pulled in from the init script; makes things easier.
NAME=hudson
# Additional options that are passed to the Daemon.
DAEMON_OPTS=""
# location of java
JAVA=/usr/bin/java
# arguments to pass to java
JAVA_ARGS=-jar
PIDFILE=/var/run/hudson/hudson.pid
# user id to be invoked as (otherwise will run as root; not wise!)
HUDSON_USER=hudson
# location of the hudson war file
HUDSON_WAR=/usr/local/bin/$NAME.war
# hudson home location
#HUDSON_HOME=/var/lib/hudson
# log location. this may be a syslog facility.priority
#HUDSON_LOG=/var/log/$NAME.log
#HUDSON_LOG=daemon.info
# arguments to pass to hudson.
# --javahome=$JAVA_HOME
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.$ADMIN_USER=admin
#HUDSON_ARGS=
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
#!/bin/sh
# /etc/init.d/hudson
# debian-compatible hudson startup script.
# Amelia A Lewis <alewis@ibco.com>
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/hudson
DESC="Hudson Continuous Integration Server"
NAME=hudson
DESC=hudson
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Include hudson defaults if available
if [ -f /etc/default/hudson ] ; then
. /etc/default/hudson
fi
#DAEMON=$HUDSON_SH
DAEMON=/usr/bin/daemon
DAEMON_ARGS="--name=$NAME --inherit --env=HUDSON_HOME=$HUDSON_HOME --output=$HUDSON_LOG --user=$HUDSON_USER --pidfile=$PIDFILE"
set -e
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# 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
$DAEMON $DAEMON_ARGS --running && return 1
$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS $HUDSON_WAR $HUDSON_ARGS || 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
$DAEMON $DAEMON_ARGS --running || return 1
$DAEMON $DAEMON_ARGS --stop || return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return 0
}
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
#reload)
#
# If the daemon can reload its config files on the fly
# for example by sending it SIGHUP, do it here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this a do-nothing entry.
#
# echo "Reloading $DESC configuration files."
# start-stop-daemon --stop --signal 1 --quiet --pidfile \
# /var/run/$NAME.pid --exec $DAEMON
#;;
force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart" except that it does nothing if the
# daemon isn't already running.
# check wether $DAEMON is running. If so, restart
start-stop-daemon --stop --test --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON \
&& $0 restart \
|| exit 0
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册