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