summaryrefslogtreecommitdiff
path: root/solaris/quagga.init.in
blob: ba3b484a904436431aed4615027dab06272c2127 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/sbin/sh
#
# Copyright 2001,2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# $Id: quagga.init.in,v 1.4 2005/06/15 11:00:11 paul Exp $
#
# Starts/stops the appropriate daemon

SMFINCLUDE=/lib/svc/share/smf_include.sh

if [ -f "$SMFINCLUDE" ] ; then
	. "$SMFINCLUDE";
fi

usage () {
	echo "Usage: $0 (start|stop) <fmri> <instance>";
}	

case $1 in
	'help' | 'usage')
	usage
	;;
esac

# fmri and instance must be given.
FMRI="$2"
INSTANCE="$3"
if [ -z "$FMRI" -o -z "$INSTANCE" ]; then
	usage
	exit $SMF_EXIT_ERR_CONFIG
fi

# fmri must exist
svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG

case ${INSTANCE} in
	zebra | ospfd | ospf6d | ripd | ripngd | bgpd )
	;;
	*)
	usage
	exit $SMF_EXIT_ERR_CONFIG;
	;;
esac

svcprop -q -p @PACKAGE_TARNAME@/config_file ${FMRI} && \
	CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}`
svcprop -q -p @PACKAGE_TARNAME@/pid_file ${FMRI} && \
	PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}`
svcprop -q -p @PACKAGE_TARNAME@/user ${FMRI} && \
	USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}`
svcprop -q -p @PACKAGE_TARNAME@/group ${FMRI} && \
	GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}`
svcprop -q -p @PACKAGE_TARNAME@/vty_addr ${FMRI} && \
	VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${FMRI}`
svcprop -q -p @PACKAGE_TARNAME@/vty_port ${FMRI} && \
	VTYPORT=`svcprop -p @PACKAGE_TARNAME@/vty_port ${FMRI}`

[ -n "${CONFFILE}" ] && ARGS=" -f ${CONFFILE}"
[ -n "${PIDFILE}" ] && ARGS="${ARGS} --pid_file ${PIDFILE}"
[ -n "${USER}" ] && ARGS="${ARGS} --user ${USER}"
[ -n "${GROUP}" ] && ARGS="${ARGS} --group ${GROUP}"

# vty should default to disabled, ie port == 0
[ -z "${VTYPORT}" ] && VTYPORT=0
ARGS="${ARGS} --vty_port ${VTYPORT}"

# default listen address should be localhost
[ -z "${VTYADDR}" ] && VTYADDR=127.1
ARGS="${ARGS} --vty_addr ${VTYADDR}"

# have to have a pid file for script to work
# we can assume it otherwise
if [ -z "${PIDFILE}" ]; then
	PIDFILE="@quagga_statedir@/${INSTANCE}.pid"
else
	ARGS="${ARGS} --pid_file ${PIDFILE}"
fi

# config file must exist
#[ ! -f "$CONFFILE" ] &&  exit $SMF_EXIT_ERR_CONFIG

# we need @quagga_statedir@ to exist, it might be on tmpfs.
if [ ! -d @quagga_statedir@ ] ; then
	mkdir -p @quagga_statedir@
	chown @enable_user@:@enable_group@ @quagga_statedir@
	chmod 751 @quagga_statedir@
fi

start () {
	@sbindir@/${INSTANCE} ${ARGS} &
}

stop () {
	if [ -f "${PIDFILE}" ]; then
		/usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"`
	fi
}

restart() {
	stop ${INSTANCE}
	sleep 1
	start ${INSTANCE}
}

case $1 in 
'start')
	start ${2}
	;;
'stop')
	stop ${2}
	;;

'restart')
	restart ${2}
	;;
*)
	usage
	exit 1
	;;
esac	

exit $SMF_EXIT_OK;