summaryrefslogtreecommitdiff
blob: 88255a5e99f1e1651e317eeb3439d1a7744ec58f (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
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

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

pidfile=/run/quagga/${SVCNAME}.pid

command=/usr/sbin/${SVCNAME}
command_args="-d -f ${CFGFILE} ${EXTRA_OPTS} --pid_file ${pidfile}"

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

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

depend() {
	config "$CFGFILE"

    [ ${SVCNAME} = "zebra" ] && need net || need zebra

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

start_pre() {
    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 `echo /usr/share/doc/quagga-*/samples/${SVCNAME}.conf.sample*`"
        return 1
    fi

	checkpath -d -m 0750 -o quagga:quagga /run/quagga

	if [ ${SVCNAME} = "zebra" ]; then
		ebegin "Cleaning up stale zebra routes..."
		ip route flush proto zebra
		eend $?
	fi
}