xref: /titanic_52/usr/src/cmd/cmd-inet/usr.sbin/in.routed/svc-route (revision ae115bc77f6fcde83175c75b4206dc2e50747966)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27
28. /lib/svc/share/smf_include.sh
29. /lib/svc/share/routing_include.sh
30
31smf_is_globalzone || exit $SMF_EXIT_OK
32
33daemon_args=`get_daemon_args $SMF_FMRI`
34options="AdghmnqsStvVzT:F:P:"
35
36#
37# Handle upgrade - routing/daemon-args property must be mapped to properties
38# in routeadm property group.  Note that the SMF-incompatible -t option is not
39# supported, since it requires that in.routed run in the foreground.
40#
41if [ -n "$daemon_args" ]; then
42	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
43	    "$options" "A" ignore_auth false true
44	set_daemon_ordered_multivalue_property "$SMF_FMRI" "$daemon_args" \
45	    "$options" "F" minimize_routes
46	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
47	    "$options" "g" offer_default_route true false
48	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
49	    "$options" "h" advertise_host_routes false true
50	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
51	    "$options" "m" advertise_host_routes_primary true false
52	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
53	    "$options" "n" install_routes false true
54	set_daemon_ordered_multivalue_property "$SMF_FMRI" "$daemon_args" \
55	    "$options" "P" parameters
56	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
57	    "$options" "q" supply_routes false true
58	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
59	    "$options" "s" supply_routes true
60	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
61	    "$options" "S" default_routes_only true false
62	set_daemon_value_property "$SMF_FMRI" "$daemon_args" \
63	    "$options" "T" log_file
64	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
65	    "$options" "v" debug true false
66	set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \
67	    "$options" "z" debug true
68	clear_daemon_args $SMF_FMRI
69fi
70
71#
72# Assemble arguments to daemon from properties
73#
74args="`get_daemon_option_from_boolean_property $SMF_FMRI ignore_auth \
75	A false`"
76args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
77	offer_default_route g true`"
78args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
79	advertise_host_routes h false`"
80args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
81	advertise_host_routes_primary m true`"
82args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
83	install_routes n false`"
84args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
85	supply_routes q false`"
86# We only use -s option when there are multiple network interfaces.
87numv4ifs=`/usr/sbin/ifconfig -a4u | \
88	/usr/bin/nawk '($1 == "inet" && $2 != "127.0.0.1") { print $2 }' | \
89	/usr/bin/wc -l`
90if [ "$numv4ifs" -gt 1 ]; then
91	args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
92		supply_routes s true`"
93fi
94args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
95	default_routes_only S true`"
96args="$args`get_daemon_option_from_boolean_property $SMF_FMRI \
97	debug z true`"
98if [ -n "$args" ]; then
99	args="-${args}"
100fi
101args="$args `get_daemon_ordered_multivalue_option_from_property $SMF_FMRI \
102	minimize_routes F`"
103args="$args `get_daemon_ordered_multivalue_option_from_property \
104	$SMF_FMRI parameters P`"
105args="$args `get_daemon_option_from_property $SMF_FMRI \
106	log_file T`"
107
108/usr/sbin/in.routed $args
109
110[ "$?" = 0 ] || exit $SMF_EXIT_ERR_FATAL
111
112exit "$SMF_EXIT_OK"
113