summaryrefslogtreecommitdiff
path: root/usr/src/cmd/hostid
diff options
context:
space:
mode:
authorKen Erickson <Ken.Erickson@Sun.COM>2008-09-27 00:08:58 -0700
committerKen Erickson <Ken.Erickson@Sun.COM>2008-09-27 00:08:58 -0700
commited5289f91b9bf164dccd6c75398362be77a4478d (patch)
tree7077442d2b9957d4cc322e51e61ed19a55e97326 /usr/src/cmd/hostid
parent2e1a94749a6ae1ee25de9f4492d4b90a3b408c4c (diff)
downloadillumos-gate-ed5289f91b9bf164dccd6c75398362be77a4478d.tar.gz
6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
PSARC/2007/078 Hostid for X86 systems
Diffstat (limited to 'usr/src/cmd/hostid')
-rw-r--r--usr/src/cmd/hostid/Makefile36
-rw-r--r--usr/src/cmd/hostid/smf/Makefile39
-rw-r--r--usr/src/cmd/hostid/smf/hostid.xml89
-rw-r--r--usr/src/cmd/hostid/smf/svc-hostid45
4 files changed, 201 insertions, 8 deletions
diff --git a/usr/src/cmd/hostid/Makefile b/usr/src/cmd/hostid/Makefile
index f8fbca600e..1ede858bb4 100644
--- a/usr/src/cmd/hostid/Makefile
+++ b/usr/src/cmd/hostid/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -20,23 +19,44 @@
# CDDL HEADER END
#
#
-# Copyright (c) 1995 by Sun Microsystems, Inc.
-# All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
PROG= hostid
include ../Makefile.cmd
+# Currently, the only architecture-specific things are
+# the SMF pieces that set up the software-defined hostid on
+# non-sparc platforms. These need to get installed on x86
+# which is why we do this in a $MACH subdir.
+
+sparc_SUBDIRS =
+i386_SUBDIRS = smf
+
+SUBDIRS = $($(MACH)_SUBDIRS)
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
+
.KEEP_STATE:
-all: $(PROG)
+all: $(PROG)
+
+install: all $(ROOTPROG) $(SUBDIRS)
-install: all $(ROOTPROG)
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
clean:
lint: lint_PROG
+FRC:
+
include ../Makefile.targ
diff --git a/usr/src/cmd/hostid/smf/Makefile b/usr/src/cmd/hostid/smf/Makefile
new file mode 100644
index 0000000000..9c1621d586
--- /dev/null
+++ b/usr/src/cmd/hostid/smf/Makefile
@@ -0,0 +1,39 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../../Makefile.cmd
+
+MANIFEST = hostid.xml
+METHOD = svc-hostid
+
+ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
+ROOTMETHOD = $(ROOTLIBSVCMETHOD)/$(METHOD)
+
+all clean clobber lint:
+
+install: all $(ROOTMANIFEST) $(ROOTMETHOD)
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/hostid/smf/hostid.xml b/usr/src/cmd/hostid/smf/hostid.xml
new file mode 100644
index 0000000000..f6f2ed89c7
--- /dev/null
+++ b/usr/src/cmd/hostid/smf/hostid.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+Use is subject to license terms.
+
+CDDL HEADER START
+
+The contents of this file are subject to the terms of the
+Common Development and Distribution License (the "License").
+You may not use this file except in compliance with the License.
+
+You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+or http://www.opensolaris.org/os/licensing.
+See the License for the specific language governing permissions
+and limitations under the License.
+
+When distributing Covered Code, include this CDDL HEADER in each
+file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+If applicable, add the following below this CDDL HEADER, with the
+fields enclosed by brackets "[]" replaced with your own identifying
+information: Portions Copyright [yyyy] [name of copyright owner]
+
+CDDL HEADER END
+
+
+ NOTE: This service manifest is not editable; its contents will
+ be overwritten by package or patch operations, including
+ operating system upgrade. Make customizations in a different
+ file.
+
+ Service manifest for hostid.
+-->
+
+<service_bundle type='manifest' name='SUNWcsr:hostid'>
+
+<service
+ name='system/hostid'
+ type='service'
+ version='1'>
+
+ <create_default_instance enabled='true' />
+
+ <single_instance />
+
+ <dependency
+ name='usr'
+ type='service'
+ grouping='require_all'
+ restart_on='none'>
+ <service_fmri value='svc:/system/filesystem/minimal' />
+ </dependency>
+
+ <exec_method
+ type='method'
+ name='start'
+ exec='/lib/svc/method/svc-hostid'
+ timeout_seconds='60' />
+
+ <exec_method
+ type='method'
+ name='stop'
+ exec=':true'
+ timeout_seconds='60' />
+
+ <property_group name='startd' type='framework'>
+ <propval name='duration' type='astring'
+ value='transient' />
+ </property_group>
+
+ <stability value='Unstable' />
+
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>
+ hostid
+ </loctext>
+ </common_name>
+
+ <documentation>
+ <manpage
+ title='hostid'
+ section='1'
+ manpath='/usr/share/man' />
+ </documentation>
+ </template>
+</service>
+
+</service_bundle>
diff --git a/usr/src/cmd/hostid/smf/svc-hostid b/usr/src/cmd/hostid/smf/svc-hostid
new file mode 100644
index 0000000000..91edb71a95
--- /dev/null
+++ b/usr/src/cmd/hostid/smf/svc-hostid
@@ -0,0 +1,45 @@
+#!/sbin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+. /lib/svc/share/smf_include.sh
+
+if [ `uname -p` = "sparc" ]; then
+ exit $SMF_EXIT_OK
+fi
+
+if smf_is_globalzone; then
+ if [ -f /etc/hostid ]; then
+ exit $SMF_EXIT_OK
+ else
+ host=`/usr/bin/hostid`
+ echo "# DO NOT EDIT" > /etc/hostid
+ r=`echo "0x${host}" | /usr/bin/perl -e \
+ 'while(<STDIN>){chop;tr/!-~/P-~!-O/;print $_,"\n";}exit 0;'`
+ printf "\"%s\"\n" $r >> /etc/hostid
+ fi
+fi
+
+exit $SMF_EXIT_OK