1 #!/usr/bin/ksh
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, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
9 #
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
14 #
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 #
21 # CDDL HEADER END
22 #
23 #
24 #ident "%Z%%M% %I% %E% SMI"
25 #
26 # Copyright (c) 2001 by Sun Microsystems, Inc.
27 # All rights reserved.
28 #
29
30 #
31 # Source the utilities.
32 #
33 DIRNAME=`dirname $0`
34 . ${DIRNAME}/utilities.san
35
36 #
37 # Process the input arguments.
38 #
39 VALIDOPTS=d
40 process_args $@
41
42 #
43 # In case the tester wants to see script output, allow them
44 # to run in debug mode.
45 #
46 TESTNAME=`basename $0`
47 if [ ! -z "${DEBUG}" ]
48 then
49 OUTFILE=/tmp/${TESTNAME}.$$
50 echo "Output from test: ${TESTNAME}" >${OUTFILE}
51 echo >>${OUTFILE}
52 echo "debug output can be found at ${OUTFILE}"
53 else
54 OUTFILE=/dev/null
55 fi
56
57 #
58 # Set variables.
59 #
60 SRVNAME=`uname -n`
61 SRVADDR=`get_server_ip`
62 DHCP_CONFIG=/etc/inet/dhcpsvc.conf
63
64 #
65 # If the DHCP server is running, kill it.
66 #
67 pkill -x -u 0 in.dhcpd
68
69 #
70 # Make sure to clean up before we configure.
71 #
72 rm -f ${DHCP_CONFIG} >>${OUTFILE} 2>&1
73
74 #
75 # Config.
76 #
77 /usr/sbin/dhcpconfig -R ${SRVADDR} >>${OUTFILE} 2>&1
78
79 #
80 # Verify that the dhcp config file was created.
81 #
82 if [ ! -f ${DHCP_CONFIG} ]
83 then
84 echo "${DHCP_CONFIG} not created."
85 echo "${TESTNAME} - Test failed!"
86 exit 1
87 fi
88
89 #
90 # Verify that the run mode was defined in the config file
91 #
92 DEFLINE=`grep "RUN_MODE=relay" ${DHCP_CONFIG}`
93 if [ -z "${DEFLINE}" ]
94 then
95 echo "RUN_MODE not set correctly in ${DHCP_CONFIG}"
96 echo "${TESTNAME} - Test failed!"
97 exit 1
98 fi
99
100 #
101 # Verify that the relay destinations was defined in the config file
102 #
103 DEFLINE=`grep "RELAY_DESTINATIONS=${SRVADDR}" ${DHCP_CONFIG}`
104 if [ -z "${DEFLINE}" ]
105 then
106 echo "RELAY_DESTINATIONS not set correctly in ${DHCP_CONFIG}"
107 echo "${TESTNAME} - Test failed!"
108 exit 1
109 fi
110
111 #
112 # Verify that the dhcp server was started.
113 #
114 PID=`pgrep -x -u 0 in.dhcpd`
115 if [ -z "${PID}" ]
116 then
117 echo "DHCP Server was not started."
118 echo "${TESTNAME} - Test failed!"
119 exit 1
120 fi
121
122 echo "${TESTNAME} - Test passed."
123 exit 0