summaryrefslogtreecommitdiff
blob: c05face0045893fce069980d78f5f2a736e73cdb (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
51
52
53
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/quagga-services.init.2,v 1.3 2011/09/27 21:51:34 flameeyes Exp $

: ${CFGFILE:=/etc/quagga/${SVCNAME}.conf}

get_service_config() {
	[ -e "$CFGFILE" ] || return

	awk '$1 == "'$1'" { s=$2 } END { print s }' "$CFGFILE"
}

depend() {
	config "$CFGFILE"

    need zebra

	[ "$(get_service_config log)" = "syslog" ] && \
		use logger
}

start() {
    if [ ! -e "${CFGFILE}" ] ; then
        eerror "Before starting ${SVCNAME} you have to configure it, by creating"
        eerror "a ${CFGFILE} file."
        eerror ""
        eerror "A sample file has been installed in `ls /usr/share/doc/quagga-*/samples/${SVCNAME}.conf.sample`"
        return 1
    fi

    if [ ! -d /var/run/quagga ] ; then
        mkdir -p /var/run/quagga
        chown quagga:quagga /var/run/quagga
        chmod 0750 /var/run/quagga
    fi

    ebegin "Starting ${SVCNAME}"
    start-stop-daemon \
        --start --exec /usr/sbin/${SVCNAME} \
        --pidfile /var/run/quagga/${SVCNAME}.pid \
		-- -d -f "${CFGFILE}" ${EXTRA_OPTS} \
		--pid_file /var/run/quagga/${SVCNAME}.pid

    eend $?
}

stop() {
    ebegin "Stopping ${SVCNAME}"
    start-stop-daemon --stop \
        --pidfile /var/run/quagga/${SVCNAME}.pid
    eend $?
}