summaryrefslogtreecommitdiffstats
path: root/unmaintained/apache-couchdb/apache-couchdb.initd
blob: c3a136dfb8edf3d17d15e553774c3cdcd9627db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/sbin/runscript
# Copyright 1999-2013 Dirkjan Ochtman
# Distributed under the terms of the Apache License, Version 2.0

depend() {
	need net
	after firewall
}

start() {
	ebegin "Starting ${SVCNAME}"

	args="-b"
	if test -n "$COUCHDB_STDOUT_FILE"; then
		args="$args -o $COUCHDB_STDOUT_FILE"
	fi
	if test -n "$COUCHDB_STDERR_FILE"; then
		args="$args -e $COUCHDB_STDERR_FILE"
	fi
	if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then
		args="$args -r $COUCHDB_RESPAWN_TIMEOUT"
	fi
	if test -n "$COUCHDB_OPTIONS"; then
		args="$args $COUCHDB_OPTIONS"
	fi
	if test -n "$COUCHDB_PID_FILE"; then
	    args="$args -p $COUCHDB_PID_FILE"
    else
        echo "* ERROR: COUCHDB_PID_FILE must be set"
        return -1
    fi
	if test -z "$COUCHDB_USER"; then
        echo "* ERROR: COUCHDB_USER must be set"
        return -1
	fi

	checkpath --directory --owner ${COUCHDB_USER} ${COUCHDB_PID_FILE%/*}

	start-stop-daemon --start --exec ${EXEC} --name ${COUCHDB_BEAM} \
		--user ${COUCHDB_USER} --pidfile ${COUCHDB_PID_FILE} -- $args

	eend $? "Failed to start ${SVCNAME}"
}

stop() {
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --exec ${EXEC} --name ${COUCHDB_BEAM} \
		--pidfile ${COUCHDB_PID_FILE}
	eend $? "Failed to stop ${SVCNAME}"
}