summaryrefslogtreecommitdiff
path: root/solaris/quagga.init.in
blob: 808fcbe8577eb98ae6de004776174c6c75171baf (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
#!/sbin/sh
#
# Copyright 2001,2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# $Id: quagga.init.in,v 1.2 2005/04/26 02:35:03 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>";
}	

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

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

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

DAEMON=`svcprop -p @PACKAGE_NAME@/daemon_name ${FMRI} 2> /dev/null`
[ -z "${DAEMON}" ] && exit $SMF_EXIT_ERR_CONFIG

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

CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}`
PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}`
USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}`
GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}`
VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${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}"
[ -n "${VTYPORT}" ] && ARGS="${ARGS} --vty_port ${VTYPORT}"
[ -n "${VTYADDR}" ] && ARGS="${ARGS} --vty_addr ${VTYADDR}"

# have to have a pid file for script to work
[ -z "${PIDFILE}" ] && exit $SMF_EXIT_ERR_CONFIG

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

start () {
	/usr/local/quagga/sbin/${DAEMON} ${ARGS} &
}

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

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

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

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

exit $SMF_EXIT_OK;