76 # Settings for client specific properties, to be passed via grub menu
77 #
78 BARGLIST=""
79
80 # import common functions
81 #
82 . ${DIRNAME}/installadm-common
83
84
85 # usage
86 #
87 # Purpose : Print the usage message in the event the user
88 # has input illegal command line parameters and
89 # then exit
90 #
91 # Arguments :
92 # none
93 #
94 usage () {
95 echo "Usage: $0 [-b <property>=<value>,...]"
96 echo "\t\t-e <macaddr> -t <imagepath> -n <svcname>"
97
98 exit 1
99 }
100
101 abort()
102 {
103 echo "${myname}: Aborted"
104 exit 1
105 }
106
107
108 #
109 # MAIN - Program
110 #
111
112 myname=`basename $0`
113 ID=`id`
114 USER=`expr "${ID}" : 'uid=\([^(]*\).*'`
115
116 unset BOOT_FILE IMAGE_PATH IMAGE_SERVER MAC_ADDR
183 if [ ! "$BOOT_FILE" ] ; then
184 usage ;
185 fi
186 shift 2;;
187
188 # -b option is used to introduce changes in a client,
189 # e.g. console=ttya
190 #
191 -b) BARGLIST="$BARGLIST"$2","
192 shift 2;;
193
194 -*) # -anything else is an unknown argument
195 usage ;
196 ;;
197 *) # all else is spurious
198 usage ;
199 ;;
200 esac
201 done
202
203 if [ -z "${MAC_ADDR}" -o -z "${IMAGE_PATH}" -o -z "${SERVICE_NAME}" ]; then
204 echo "${myname}: Missing one or more required options."
205 usage
206 fi
207
208 # If IMAGE_SERVER is passed in, check that it is equal to the local system
209 # since we don't yet support a remote system being the image server.
210 #
211 if [ -n "${IMAGE_SERVER}" ]; then
212 IMAGE_IP=`get_host_ip ${IMAGE_SERVER}`
213 if [ -z $IMAGE_IP ] ; then
214 echo "${myname}: Failed to get IP address for ${IMAGE_SERVER}"
215 exit 1
216 fi
217
218 if [ "${IMAGE_IP}" != "${SERVER_IP}" ]; then
219 echo "${myname}: Remote image server is not supported at this time."
220 exit 1
221 fi
222 fi
223
224 # Verify that IMAGE_PATH is a valid directory
225 #
226 if [ ! -d ${IMAGE_PATH} ]; then
227 echo "${myname}: Install image directory ${IMAGE_PATH} does not exist."
234 echo "${myname}: ${IMAGE_PATH}/solaris.zlib does not exist. " \
235 "The specified image is not an OpenSolaris image."
236 exit 1
237 fi
238
239
240 # Determine if image is sparc or x86
241 #
242 IMAGE_TYPE=`get_image_type ${IMAGE_PATH}`
243
244 # For sparc, make sure the user hasn't specified a boot file via
245 # the "-f" option. If they have, the BOOT_FILE variable will be set.
246 #
247 if [ "${IMAGE_TYPE}" = "${SPARC_IMAGE}" ]; then
248 if [ "X$BOOT_FILE" != "X" ] ; then
249 echo "${myname}: \"-f\" is an invalid option for SPARC"
250 exit 1
251 fi
252 fi
253
254 # Verify that service corresponding to SERVICE_NAME exists
255 #
256 ${DIRNAME}/setup-service lookup ${SERVICE_NAME} ${INSTALL_TYPE} local
257 if [ $? -ne 0 ] ; then
258 echo "${myname}: Service does not exist: ${SERVICE_NAME}"
259 exit 1
260 fi
261
262
263 # Convert the Ethernet address to DHCP "default client-ID" form:
264 # uppercase hex, preceded by the hardware
265 # address type ("01" for ethernet)
266 #
267 DHCP_CLIENT_ID=01`echo "${MAC_ADDR}" | ${TR} '[a-z]' '[A-Z]' |
268 awk -F: '
269 {
270 for (i = 1; i <= 6 ; i++)
271 if (length($i) == 1) {
272 printf("0%s", $i)
273 } else {
274 printf("%s", $i);
275 }
276 }'`
277
278
279 # Perform x86/sparc specific setup activities
280 #
281 if [ "${IMAGE_TYPE}" = "${X86_IMAGE}" ]; then
|
76 # Settings for client specific properties, to be passed via grub menu
77 #
78 BARGLIST=""
79
80 # import common functions
81 #
82 . ${DIRNAME}/installadm-common
83
84
85 # usage
86 #
87 # Purpose : Print the usage message in the event the user
88 # has input illegal command line parameters and
89 # then exit
90 #
91 # Arguments :
92 # none
93 #
94 usage () {
95 echo "Usage: $0 [-b <property>=<value>,...]"
96 echo "\t\t-e <macaddr> -n <svcname> [-t <imagepath>]"
97
98 exit 1
99 }
100
101 abort()
102 {
103 echo "${myname}: Aborted"
104 exit 1
105 }
106
107
108 #
109 # MAIN - Program
110 #
111
112 myname=`basename $0`
113 ID=`id`
114 USER=`expr "${ID}" : 'uid=\([^(]*\).*'`
115
116 unset BOOT_FILE IMAGE_PATH IMAGE_SERVER MAC_ADDR
183 if [ ! "$BOOT_FILE" ] ; then
184 usage ;
185 fi
186 shift 2;;
187
188 # -b option is used to introduce changes in a client,
189 # e.g. console=ttya
190 #
191 -b) BARGLIST="$BARGLIST"$2","
192 shift 2;;
193
194 -*) # -anything else is an unknown argument
195 usage ;
196 ;;
197 *) # all else is spurious
198 usage ;
199 ;;
200 esac
201 done
202
203 if [ -z "${MAC_ADDR}" -o -z "${SERVICE_NAME}" ]; then
204 echo "${myname}: Missing one or more required options."
205 usage
206 fi
207
208
209 # Verify that service corresponding to SERVICE_NAME exists
210 #
211 # Check the service exists in SMF
212 svcprop -p AI${SERVICE_NAME}/image_path \
213 -c svc:/system/install/server:default 1>/dev/null 2>&1
214 if [ $? -ne 0 ]; then
215 echo "${myname}: Service does not exist: ${SERVICE_NAME}"
216 exit 1
217 fi
218 # Check that the service is running
219 ${DIRNAME}/setup-service lookup ${SERVICE_NAME} ${INSTALL_TYPE} local
220 if [ $? -ne 0 ] ; then
221 echo "${myname}: Service does not exist: ${SERVICE_NAME}"
222 exit 1
223 fi
224
225
226 # Determine IMAGE PATH if not provided
227 #
228 if [ -z "${IMAGE_PATH}" ]; then
229 # Find IMAGE PATH from SMF
230 IMAGE_PATH="`svcprop -p AI${SERVICE_NAME}/image_path \
231 -c svc:/system/install/server:default 2>/dev/null`"
232 if [ $? -ne 0 ]; then
233 echo "${myname}: Image-path record for service" \
234 "${SERVICE_NAME} is missing."
235 exit 1
236 fi
237 fi
238
239 # If IMAGE_SERVER is passed in, check that it is equal to the local system
240 # since we don't yet support a remote system being the image server.
241 #
242 if [ -n "${IMAGE_SERVER}" ]; then
243 IMAGE_IP=`get_host_ip ${IMAGE_SERVER}`
244 if [ -z $IMAGE_IP ] ; then
245 echo "${myname}: Failed to get IP address for ${IMAGE_SERVER}"
246 exit 1
247 fi
248
249 if [ "${IMAGE_IP}" != "${SERVER_IP}" ]; then
250 echo "${myname}: Remote image server is not supported at this time."
251 exit 1
252 fi
253 fi
254
255 # Verify that IMAGE_PATH is a valid directory
256 #
257 if [ ! -d ${IMAGE_PATH} ]; then
258 echo "${myname}: Install image directory ${IMAGE_PATH} does not exist."
265 echo "${myname}: ${IMAGE_PATH}/solaris.zlib does not exist. " \
266 "The specified image is not an OpenSolaris image."
267 exit 1
268 fi
269
270
271 # Determine if image is sparc or x86
272 #
273 IMAGE_TYPE=`get_image_type ${IMAGE_PATH}`
274
275 # For sparc, make sure the user hasn't specified a boot file via
276 # the "-f" option. If they have, the BOOT_FILE variable will be set.
277 #
278 if [ "${IMAGE_TYPE}" = "${SPARC_IMAGE}" ]; then
279 if [ "X$BOOT_FILE" != "X" ] ; then
280 echo "${myname}: \"-f\" is an invalid option for SPARC"
281 exit 1
282 fi
283 fi
284
285
286 # Convert the Ethernet address to DHCP "default client-ID" form:
287 # uppercase hex, preceded by the hardware
288 # address type ("01" for ethernet)
289 #
290 DHCP_CLIENT_ID=01`echo "${MAC_ADDR}" | ${TR} '[a-z]' '[A-Z]' |
291 awk -F: '
292 {
293 for (i = 1; i <= 6 ; i++)
294 if (length($i) == 1) {
295 printf("0%s", $i)
296 } else {
297 printf("%s", $i);
298 }
299 }'`
300
301
302 # Perform x86/sparc specific setup activities
303 #
304 if [ "${IMAGE_TYPE}" = "${X86_IMAGE}" ]; then
|