PageRenderTime 59ms CodeModel.GetById 55ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/rc2.d/S20debomatic

http://github.com/brinkman83/bashrc
Shell | 89 lines | 67 code | 10 blank | 12 comment | 20 complexity | df582e977a97daf033655bda0cab906c MD5 | raw file
 1#! /bin/sh
 2### BEGIN INIT INFO
 3# Provides:          debomatic
 4# Required-Start:    $local_fs
 5# Required-Stop:     $local_fs
 6# Default-Start:     2 3 4 5
 7# Default-Stop:      0 1 6
 8# Short-Description: Package autobuilder
 9# Description:       Automatic build machine for Debian source packages.
10#                    Directly based on skeleton init script.
11### END INIT INFO
12
13# Author: Karl Goetz <karl@kgoetz.id.au>
14
15PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
16DESC="Automatic build machine for Debian source packages"
17NAME=debomatic
18
19[ -r /etc/default/$NAME ] && . /etc/default/$NAME
20
21DAEMON=/usr/bin/debomatic
22DAEMON_ARGS="-c $DEBOMATIC_CONFIG_FILE $DEBOMATIC_OPTS"
23PIDFILE=/var/run/$NAME.pid
24SCRIPTNAME=/etc/init.d/$NAME
25
26[ -x "$DAEMON" ] || exit 0
27[ "$DEBOMATIC_AUTOSTART" = 0  ] && exit 0
28
29. /lib/init/vars.sh
30. /lib/lsb/init-functions
31
32do_start()
33{
34	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
35	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
36}
37
38do_stop()
39{
40	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
41	RETVAL="$?"
42	[ "$RETVAL" = 2 ] && return 2
43	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
44	[ "$?" = 2 ] && return 2
45	rm -f $PIDFILE
46	return "$RETVAL"
47}
48
49case "$1" in
50  start)
51	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
52	do_start
53	case "$?" in
54		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
55		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
56	esac
57	;;
58  stop)
59	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
60	do_stop
61	case "$?" in
62		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
63		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
64	esac
65	;;
66  restart|force-reload)
67	log_daemon_msg "Restarting $DESC" "$NAME"
68	do_stop
69	case "$?" in
70	  0|1)
71		do_start
72		case "$?" in
73			0) log_end_msg 0 ;;
74			1) log_end_msg 1 ;; # Old process is still running
75			*) log_end_msg 1 ;; # Failed to start
76		esac
77		;;
78	  *)
79		log_end_msg 1
80		;;
81	esac
82	;;
83  *)
84	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
85	exit 3
86	;;
87esac
88
89: