xref: /titanic_50/usr/src/cmd/hostid/smf/svc-hostid (revision ed5289f91b9bf164dccd6c75398362be77a4478d)
1*ed5289f9SKen Erickson#!/sbin/sh
2*ed5289f9SKen Erickson#
3*ed5289f9SKen Erickson# CDDL HEADER START
4*ed5289f9SKen Erickson#
5*ed5289f9SKen Erickson# The contents of this file are subject to the terms of the
6*ed5289f9SKen Erickson# Common Development and Distribution License (the "License").
7*ed5289f9SKen Erickson# You may not use this file except in compliance with the License.
8*ed5289f9SKen Erickson#
9*ed5289f9SKen Erickson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*ed5289f9SKen Erickson# or http://www.opensolaris.org/os/licensing.
11*ed5289f9SKen Erickson# See the License for the specific language governing permissions
12*ed5289f9SKen Erickson# and limitations under the License.
13*ed5289f9SKen Erickson#
14*ed5289f9SKen Erickson# When distributing Covered Code, include this CDDL HEADER in each
15*ed5289f9SKen Erickson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*ed5289f9SKen Erickson# If applicable, add the following below this CDDL HEADER, with the
17*ed5289f9SKen Erickson# fields enclosed by brackets "[]" replaced with your own identifying
18*ed5289f9SKen Erickson# information: Portions Copyright [yyyy] [name of copyright owner]
19*ed5289f9SKen Erickson#
20*ed5289f9SKen Erickson# CDDL HEADER END
21*ed5289f9SKen Erickson#
22*ed5289f9SKen Erickson#
23*ed5289f9SKen Erickson# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*ed5289f9SKen Erickson# Use is subject to license terms.
25*ed5289f9SKen Erickson#
26*ed5289f9SKen Erickson
27*ed5289f9SKen Erickson. /lib/svc/share/smf_include.sh
28*ed5289f9SKen Erickson
29*ed5289f9SKen Ericksonif [  `uname -p` = "sparc" ]; then
30*ed5289f9SKen Erickson        exit $SMF_EXIT_OK
31*ed5289f9SKen Ericksonfi
32*ed5289f9SKen Erickson
33*ed5289f9SKen Ericksonif smf_is_globalzone; then
34*ed5289f9SKen Erickson        if [ -f /etc/hostid ]; then
35*ed5289f9SKen Erickson        	exit $SMF_EXIT_OK
36*ed5289f9SKen Erickson        else
37*ed5289f9SKen Erickson		host=`/usr/bin/hostid`
38*ed5289f9SKen Erickson                echo "# DO NOT EDIT" > /etc/hostid
39*ed5289f9SKen Erickson		r=`echo "0x${host}" | /usr/bin/perl -e \
40*ed5289f9SKen Erickson		    'while(<STDIN>){chop;tr/!-~/P-~!-O/;print $_,"\n";}exit 0;'`
41*ed5289f9SKen Erickson		printf "\"%s\"\n"  $r >> /etc/hostid
42*ed5289f9SKen Erickson        fi
43*ed5289f9SKen Ericksonfi
44*ed5289f9SKen Erickson
45*ed5289f9SKen Ericksonexit $SMF_EXIT_OK
46