3635 Auto Installer (AI) SMF service is required by AI project
authorJan Damborsky <jan.damborsky@sun.com>
Wed, 08 Oct 2008 11:51:45 +0200
changeset 242 ded531107d87
parent 241 9a75efc4064f
child 243 fc68c8b785db
3635 Auto Installer (AI) SMF service is required by AI project
usr/src/Targetdirs
usr/src/cmd/auto-install/Makefile
usr/src/cmd/auto-install/svc/Makefile
usr/src/cmd/auto-install/svc/auto-installer
usr/src/cmd/auto-install/svc/auto-installer.xml
usr/src/cmd/distro_const/auto_install/ai_generic_live.xml
usr/src/cmd/distro_const/auto_install/ai_x86_image.xml
usr/src/pkgdefs/SUNWauto-install/prototype_com
--- a/usr/src/Targetdirs	Wed Oct 08 10:13:32 2008 +0200
+++ b/usr/src/Targetdirs	Wed Oct 08 11:51:45 2008 +0200
@@ -111,6 +111,7 @@
 	/usr/share/man \
 	/usr/share/man/man1m \
 	/usr/share/distro_const \
+	/usr/share/distro_const/auto_install \
 	/usr/share/distro_const/slim_cd \
 	/usr/sbin \
 	/usr/sbin/installadm \
--- a/usr/src/cmd/auto-install/Makefile	Wed Oct 08 10:13:32 2008 +0200
+++ b/usr/src/cmd/auto-install/Makefile	Wed Oct 08 11:51:45 2008 +0200
@@ -31,6 +31,8 @@
 clobber:=	TARGET=	clobber
 install:=	TARGET=	install
 
+SUBDIRS=	svc
+
 PROGS=		ai_get_manifest ai_sd
 
 PYMODULES=	__init__.py
@@ -45,7 +47,7 @@
 
 all:		python $(PROGS)
 
-clean:
+clean:	$(SUBDIRS)
 	rm -f $(PROGS) $(PYCMODULES)
 
 clobber: clean
@@ -54,7 +56,8 @@
 	$(ROOTPYTHONVENDOR) \
 	$(ROOTPYTHONVENDORINSTALL) \
 	$(ROOTPYTHONVENDORINSTALLAI) \
-	$(ROOTPYMODULES) $(ROOTPYCMODULES)
+	$(ROOTPYMODULES) $(ROOTPYCMODULES) \
+	$(SUBDIRS)
 
 python:
 	$(PYTHON) -m compileall -l $(@D)
@@ -69,4 +72,9 @@
 
 install_h:
 
+$(SUBDIRS): FRC
+	cd $@; pwd; echo $(TARGET); $(MAKE) $(TARGET)
+
+FRC:
+
 include ../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/auto-install/svc/Makefile	Wed Oct 08 11:51:45 2008 +0200
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+#
+
+APPMANIFESTSRC= auto-installer.xml
+
+SVCMETHODSRC= auto-installer
+
+include $(SRC)/cmd/Makefile.cmd
+
+FILEMODE= 444
+
+APPMANIFESTS= $(APPMANIFESTSRC:%=$(ROOTMANAPP)/%)
+
+SVCMETHODS= $(SVCMETHODSRC:%=$(ROOTLIBSVCMETHOD)/%)
+$(SVCMETHODS) :=	FILEMODE= 0555
+
+all:
+
+install: all $(ROOTMANAPP) $(ROOTLIBSVCMETHOD) $(APPMANIFESTS) $(SVCMETHODS)
+
+install_h:
+
+clobber clean:
+
+include $(SRC)/cmd/Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/auto-install/svc/auto-installer	Wed Oct 08 11:51:45 2008 +0200
@@ -0,0 +1,127 @@
+#!/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.
+#
+
+# Auto installer
+AI_ENGINE=/usr/bin/auto-install
+# Service Discovery Engine
+AISD_ENGINE=/usr/bin/ai_sd
+# Service Choosing Engine
+AISC_ENGINE=/usr/bin/ai_get_manifest
+# Auto install and System Configuration combined manifest
+AISC_MANIFEST=/tmp/ai_manifest.$$
+# List of services which Service Discovery Engine will
+# contact for obtaining the manifest
+AI_SERVICE_LIST=/tmp/service_list.$$
+# debug mode
+AI_DBGLVL=4
+# timeout for service discovery process
+AI_TIMEOUT=5
+
+. /lib/svc/share/smf_include.sh
+
+#
+# If 'install_service_address' variable was provided
+# by menu.lst, skip service discovery phase and directly
+# contact given machine
+#
+AI_SERVICE_ADDRESS=`/usr/sbin/prtconf -v /devices | \
+    /usr/bin/sed -n '/install_service_address/{;n;p;}' | \
+    /usr/bin/cut -f 2 -d \'`
+
+if [ -n "$AI_SERVICE_ADDRESS" ] ; then
+	echo "AI Service location provided, skipping service discovery"
+	echo "$AI_SERVICE_ADDRESS" > $AI_SERVICE_LIST
+else
+	#
+	# Invoke AI Service Discovery engine. It obtains list of
+	# available install services. Name of the service to look up
+	# is passed from GRUB 'menu.lst' by 'install_service' variable.
+	# If this variable is not set, only default install service
+	# is to be looked up
+	#
+	if [ ! -x  $AISD_ENGINE ] ; then
+		echo "Couldn't find Auto Installer Service Discovery Engine"
+		exit $SMF_EXIT_ERR_FATAL
+	fi
+
+	# get name of service to look up
+	AI_SERVICE_NAME=`/usr/sbin/prtconf -v /devices | \
+	    /usr/bin/sed -n '/install_service/{;n;p;}' | \
+	    /usr/bin/cut -f 2 -d \'`
+
+	if [ -n "$AI_SERVICE_NAME" ] ; then
+		echo "Service name to look up: " $AI_SERVICE_NAME
+
+		$AISD_ENGINE -n $AI_SERVICE_NAME -o $AI_SERVICE_LIST \
+		    -t $AI_TIMEOUT -d $AI_DBGLVL
+	else
+		echo "Service name not provided, " \
+		    "only default will be looked up"
+
+		$AISD_ENGINE -o $AI_SERVICE_LIST -t $AI_TIMEOUT -d $AI_DBGLVL
+	fi
+
+	if [ $? -ne 0 ] ; then
+		echo "Service discovery failed"
+		exit $SMF_EXIT_ERR_FATAL
+	fi
+fi
+
+#
+# Invoke AI Service choosing engine. It takes list of install
+# services to connect and tries to obtain valid manifest
+#
+
+if [ ! -x  $AISC_ENGINE ] ; then
+	echo "Couldn't find Auto Installer Service Choosing Engine"
+	exit $SMF_EXIT_ERR_FATAL
+fi
+
+$AISC_ENGINE -s $AI_SERVICE_LIST -o $AISC_MANIFEST -d $AI_DBGLVL
+
+if [ $? -ne 0 ] ; then
+	echo "Couldn't obtain valid Auto Install manifest"
+	exit $SMF_EXIT_ERR_FATAL
+fi
+
+#
+# Call AI engine to carry out real installation
+#
+
+if [ ! -x  $AI_ENGINE ] ; then
+	echo "Couldn't find Auto Installer engine"
+	exit $SMF_EXIT_ERR_FATAL
+fi
+
+$AI_ENGINE -p $AISC_MANIFEST
+ret = $?
+
+if [ ret -ne 0 ] ; then
+	echo "Automated Installation failed - error " $ret
+	exit $SMF_EXIT_ERR_FATAL
+fi
+
+exit $SMF_EXIT_OK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/auto-install/svc/auto-installer.xml	Wed Oct 08 11:51:45 2008 +0200
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!--
+Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+Use is subject to license terms.
+
+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.
+-->
+
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+
+<service_bundle type='manifest' name='SUNWinstall:auto-installer'>
+
+<service
+	name='auto-installer'
+	type='service'
+version='1'>
+
+<create_default_instance enabled='true' />
+<single_instance/>
+
+<!-- Must be able to access /tmp. -->
+<dependency
+	name='filesystem-minimal'
+	grouping='require_all'
+	restart_on='none'
+type='service'>
+	<service_fmri value='svc:/system/filesystem/minimal' />
+</dependency>
+
+<!-- There is a soft dependency on console-login. -->
+<dependency
+	name='console-login'
+	grouping='optional_all'
+	restart_on='none'
+type='service'>
+	<service_fmri value='svc:/system/console-login' />
+</dependency>
+
+<exec_method
+	type='method'
+	name='start'
+	exec='/lib/svc/method/auto-installer'
+timeout_seconds='0' />
+
+<exec_method
+	type='method'
+	name='stop'
+	exec=':kill'
+timeout_seconds='0' />
+
+<property_group name='startd' type='framework'>
+	<propval name='ignore_error' type='astring' value='core,signal' />
+</property_group>
+
+<stability value='Unstable' />
+
+<template>
+	<common_name>
+	<loctext xml:lang='C'>
+		auto-installer
+	</loctext>
+	</common_name>
+	<documentation>
+		<manpage title='$VALUE' section='$VALUE'
+		manpath='/usr/share/man' />
+	</documentation>
+</template>
+
+
+	</service>
+</service_bundle>
--- a/usr/src/cmd/distro_const/auto_install/ai_generic_live.xml	Wed Oct 08 10:13:32 2008 +0200
+++ b/usr/src/cmd/distro_const/auto_install/ai_generic_live.xml	Wed Oct 08 11:51:45 2008 +0200
@@ -23,7 +23,7 @@
     Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     Use is subject to license terms.
 
-    Service profile customized for Live DVD usage.
+    Service profile customized for Automated Installer
 
     NOTE:  Service profiles delivered by this package are not editable,
     and their contents will be overwritten by package or patch
@@ -200,6 +200,9 @@
   <service name='application/stosreg' version='1' type='service'>
     <instance name='default' enabled='false' />
   </service>
+  <service name='application/auto-installer' version='1' type='service'>
+    <instance name='default' enabled='true' />
+  </service>
 
   <!--
       Default service instances cloned as live-media instances
--- a/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Wed Oct 08 10:13:32 2008 +0200
+++ b/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Wed Oct 08 11:51:45 2008 +0200
@@ -66,6 +66,7 @@
 			<pkg name="SUNWaudd"/>
 			<pkg name="SUNWaudf"/>
 			<pkg name="SUNWaudiohd"/>
+			<pkg name="SUNWauto-install"/>
 			<pkg name="SUNWav1394"/>
 			<pkg name="SUNWbash"/>
 			<pkg name="SUNWbge"/>
--- a/usr/src/pkgdefs/SUNWauto-install/prototype_com	Wed Oct 08 10:13:32 2008 +0200
+++ b/usr/src/pkgdefs/SUNWauto-install/prototype_com	Wed Oct 08 11:51:45 2008 +0200
@@ -49,3 +49,14 @@
 f none usr/lib/python2.4/vendor-packages/osol_install/auto_install/__init__.py 0444 root bin
 f none usr/lib/python2.4/vendor-packages/osol_install/auto_install/__init__.pyc 0444 root bin
 s none usr/lib/python2.4/vendor-packages/osol_install/auto_install/ai_get_manifest.py=../../../../../bin/ai_get_manifest
+
+d none lib 755 root bin
+d none lib/svc 755 root bin
+d none lib/svc/method 755 root bin
+f none lib/svc/method/auto-installer 555 root bin
+
+d none var 0755 root sys
+d none var/svc 0755 root sys
+d none var/svc/manifest 0755 root sys
+d none var/svc/manifest/application 0755 root sys
+f none var/svc/manifest/application/auto-installer.xml 0444 root sys