Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

klish / contrib / konfd.init.debian @ edce0a7c

History | View | Annotate | Download (3.14 KB)

1
#! /bin/sh
2
### BEGIN INIT INFO
3
# Provides:          kondf
4
# Required-Start:    
5
# Required-Stop:     
6
# Default-Start:     2 3 4 5
7
# Default-Stop:      0 1 6
8
# Short-Description: Konfd initscript
9
# Description:       Klish configuration daemon
10
### END INIT INFO
11

    
12
# Author: Nixus Networks <oss@nixus.es>
13
#
14
# Please remove the "Author" lines above and replace them
15
# with your own name if you copy and modify this script.
16

    
17
# Do NOT "set -e"
18

    
19
# PATH should only include /usr/* if it runs after the mountnfs.sh script
20
PATH=/sbin:/usr/sbin:/bin:/usr/bin
21
DESC="Klish configuration daemon"
22
NAME=gluff
23
DAEMON=/usr/sbin/$NAME
24
PIDFILE=/var/run/$NAME.pid
25
SCRIPTNAME=/etc/init.d/$NAME
26

    
27
# Exit if the package is not installed
28
[ -x "$DAEMON" ] || exit 0
29

    
30
# Read configuration variable file if it is present
31
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
32

    
33
# Load the VERBOSE setting and other rcS variables
34
. /lib/init/vars.sh
35

    
36
# Define LSB log_* functions.
37
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
38
# and status_of_proc is working.
39
. /lib/lsb/init-functions
40

    
41
DAEMON_ARGS="-l $QUEUE_DB -h $MYSQL_HOST -u $MYSQL_USER -p $MYSQL_PASSWD -d $MYSQL_DB $OPTIONS"
42

    
43
#
44
# Function that starts the daemon/service
45
#
46
do_start()
47
{
48
                log_daemon_msg "Starting $DESC" "$NAME"
49
                start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS	
50
		ps -fe | grep $DAEMON | head -n1 | cut -d" " -f 6 > ${PIDFILE}
51
	
52
		log_end_msg $?
53
}
54

    
55
#
56
# Function that stops the daemon/service
57
#
58
do_stop()
59
{
60
	log_daemon_msg "Stopping $DESC" "$NAME"
61
	start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
62
        log_end_msg $?
63
        rm -f "$PIDFILE"
64
}
65

    
66

    
67
#
68
# Function that sends a SIGHUP to the daemon/service
69
#
70
do_reload() {
71
	#
72
	# If the daemon can reload its configuration without
73
	# restarting (for example, when it is sent a SIGHUP),
74
	# then implement that here.
75
	#
76
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
77
	return 0
78
}
79

    
80
case "$1" in
81
  start)
82
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
83
	do_start
84
	case "$?" in
85
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
86
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
87
	esac
88
	;;
89
  stop)
90
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
91
	do_stop
92
	case "$?" in
93
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
94
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
95
	esac
96
	;;
97
  status)
98
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
99
       ;;
100
  #reload|force-reload)
101
	#
102
	# If do_reload() is not implemented then leave this commented out
103
	# and leave 'force-reload' as an alias for 'restart'.
104
	#
105
	#log_daemon_msg "Reloading $DESC" "$NAME"
106
	#do_reload
107
	#log_end_msg $?
108
	#;;
109
  restart|force-reload)
110
	#
111
	# If the "reload" option is implemented then remove the
112
	# 'force-reload' alias
113
	#
114
	do_stop
115
	case "$?" in
116
	  0|1)
117
		do_start
118
		case "$?" in
119
			0) log_end_msg 0 ;;
120
			1) log_end_msg 1 ;; # Old process is still running
121
			*) log_end_msg 1 ;; # Failed to start
122
		esac
123
		;;
124
	  *)
125
	  	# Failed to stop
126
		log_end_msg 1
127
		;;
128
	esac
129
	;;
130
  *)
131
	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
132
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
133
	exit 3
134
	;;
135
esac
136

    
137
: