Frank,

It can be done, however, you need to set up your own repository server. What we do is have a postscript that will run as a service, and once it's done, it will disable itself.

Take a solaris11 system, and use this as your local repository server.
Create your own repo server:

1.
Download the latest repository iso image from
http://www.genunix.org. It wil have a
name like 'osol-XXX-full.iso'. E.g:
# cd /tmp
# wget http://www.genunix.org/dist/indiana/osol-repo-0906-full.iso
# lofiadm -a /tmp/osol-repo-0906-full.iso /dev/lofi/100
# mount -F hsfs /dev/lofi/100 /mnt

On a filesystem with at least 10GB, copy the contest to a directory, e.g:

# mkdir /export/repo
# cd /mnt/repo
# tar -cf - . | (cd /export/repo;tar -xvf -)
# cd /; umount /mnt; lofiadm -d /dev/lofi/100

Edit the /export/repo/cfg_cache, change the origins property from
http://pkg.opensolaris.org/release
to http://<name of your repository server>

# svccfg -s application/pkg/server setprop pkg/inst_root=/export/repo
# svccfg -s application/pkg/server setprop pkg/readonly=true
# svccfg -s application/pkg/server setprop pkg/port=80
# svcadm refresh application/pkg/server
# svcadm enable application/pkg/server

Now you have build your own local repository.

2.
Now we have our local repository, we only have to create a package for the postscript to run after our opensolaris client reboots for the first time. We are creating a smf service that will start at the first reboot of the client, and when it's done, the service will disable itself and reboot your client to enable all changes you made with your postscript.

Let's say you dump your postscript on a apache server reachable as
http://your.own.apache.server/postscript
This file will then be copied to the /tmp directory on your client system, with the script below ('aipostscript')

Then you have to create a smf service for the client to grab it, you need 2 files 'aipostscript' and 'aipostscript.xml'

aipostscript: (with the reference to your postscript: http://your.own.apache.server/postscript)
--------------------
#! /bin/ksh

# This is the postscript wrapper for AI opensolaris installs
# the real postscript is actually on the install server and can be downloaded
# with wget from http://<install_server>:10101/postscript.pl
# postscript.pl is a cgi script and will download the file it points to
# based on the IP ADDRESS of the requester.

# The install server name and port will be read from the previous install log
# (/var/sadm/system/logs/ai_sd_log) and is actually the AI service
# (AI service: <server_ip>:10101) of the last successfull download
# of the manifest file after the first reboot

BUILD=`/usr/bin/uname -v | /usr/bin/sed s"/[^0-9]//g"`

AI_SERVICE=`/usr/bin/grep "AI service:" \
        /var/sadm/system/logs/ai_sd_log | \
        /usr/bin/awk '{print $NF}'| tail -1`

if [ "$AI_SERVICE" = "" ]
then
        AI_SERVICE=`/usr/bin/grep "AI service:" \
/var/sadm/system/logs/application-manifest-locator:default.log | \
                /usr/bin/awk '{print $NF}'| /usr/bin/tail -1`
fi

NETWORK_INTERFACE=`/usr/bin/grep "cmd:/usr/sbin/ifconfig" \
        /var/sadm/system/logs/application-manifest-locator:default.log | \
        /usr/bin/grep -v LOOPBACK | /usr/bin/awk '{print $NF}'| \
        /usr/bin/tail -1`

# WTF did they do in Build 170 and later ?? where is my network ?
if [ $BUILD -ge 170 ]
then
        if [ "$NETWORK_INTERFACE"  != "" ]
        then
                ifconfig $NETWORK_INTERFACE plumb
                ifconfig $NETWORK_INTERFACE auto-dhcp
        fi
fi

#if [ ! -s /tmp/postscript ]
#then
#        # give it another try, file doesn't exist or is empty
#        sleep 30
#        /usr/bin/wget $AI_SERVICE/postscript.pl -O /tmp/postscript
#fi

# get the postscript from the install server
/usr/bin/wget http://your.own.apache.server/postscript-O /tmp/postscript

# run it
/usr/bin/sh /tmp/postscript | tee /var/sadm/install/logs/postscript.log

# Disable myself to keep from running again
/usr/sbin/svcadm disable $SMF_FMRI

# reboot with my new settings from the postscript
/usr/sbin/reboot


aipostscript.xml:
---------------------------
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='aipostscript'>

<service name='application/aipostscript' type='service' version='1'>

<create_default_instance enabled='true' />

<!-- You want networking and other services started already, right? -->
<dependency
        name='state'
        grouping='require_all'
        restart_on='none'
        type='service'>
<service_fmri value='svc:/milestone/multi-user:default' />
</dependency>

<dependency
        name='network'
        grouping='require_all'
        restart_on='none'
        type='service'>
<service_fmri value='svc:/milestone/network' />
</dependency>

<exec_method
        type='method'
        name='start'
        exec='/lib/svc/method/aipostscript'
        timeout_seconds='6000' />

<exec_method
        type='method'
        name='stop'
        exec=':true'
        timeout_seconds='10' />

<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'>
Postscript service for AI and Asterix.
</loctext>
</common_name>
</template>
</service>

</service_bundle>



On your newly build repository, copy these 2 files to /root, E.G:
# cp /aipostscript* /root
# /usr/lib/pkg.depotd -p 10000 -d /export/repo
Log in again to your local repository in a new window.
# cd /root
# eval `pkgsend open [email protected]`
# pkgsend add file /root/aipostscript.xml \
 mode=0755 owner=root group=sys \
 path=/var/svc/manifest/application/aipostscript.xml
# pkgsend add file /root/aipostscript \
 mode=0755 owner=root group=sys \
 path=/lib/svc/method/aipostscript
# pkgsend close
Go back to the window where you started the pkg.depotd and exit with CTRL-C
# pkg rebuild-index
# svcadm disable application/pkg/server
# svcadm enable application/pkg/server


I hope this is simple enough ;-)

Paul




On 10/25/11 07:47 PM, Frank Allan wrote:
Are there any examples of how to configure and activate a one-time SMF manifest to do post-install customization after an AI install?

I have the install happily working, and I can login and run a script which will configure the system as I want it with several extra users, DNS search path, sudo configuration, sendmail off etc.

How do I get this to be automatically run at (and only at) initial reboot after installation?

From everything I have seen this requires a one-time SMF service?

Has anyone done this? Are there examples around which I can plagiarize?

I still do not understand the reasoning behind not allowing post-install scripting. It seems to just make things more difficult for no added benefit.

Cheers
Frank

_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

--



Paul de Nijs | Principal Software Engineer | Performance Technologies | +1.503.495.7882
Oracle Strategic Applications Engineering (SAE)
3295 NW 211th Terrace | Hillsboro, OR 97124-7110


_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

Reply via email to