Once the base system is installed, additional customization can take place.
In order to achieve this, an script must be run once on the first boot.
The options are:
- A traditional self-destructive initialization script.
This may be simpler but it's deprecated, so better avoid it.
- A transient self-destructive SMF service.
The overall benefits of SMF tend to compensate the hurdles.
For manageability, wrap the SMF service on a non-relocatable SVr4 package.
Make sure to avoid all interactions during package installation and removal.
This way it can be included in the Custom JumpStart general conveniences.
Assume such a package named AZ-1st-boot containing the following:
- A transient service manifest, AZ-1st-boot.xml, describing the transient service.
To be automatically imported into services database on the next reboot,
place this file in /var/svc/manifest/site.
- The first boot script, AZ-1st-boot.sh, is invoked by the transient service.
The /opt directory is the only correct place to put additional software.
The /usr/local is not recommended for anything in Solaris.
IMPORTANT
Incidentally for a first boot script the class manifest must not be used.If in the correct place, the SMF service manifest will be imported on the first boot.
As an example, each file could be as follows:
# cd /pkg/src/AZ-1st-boot
# cat pkginfo
PKG="AZ-1st-boot"NAME="AZ first boot"
ARCH="i386,sparc"
VERSION="1.0"
CATEGORY="system"
DESC="A 1st-boot one-time-only SMF service for finishing installation"
VENDOR="AZ - Learnings on Solaris"
PSTAMP="Oct 11, 2012"
CLASSES="none"
# cat prototype
i pkginfo
f none /var/svc/manifest/site/AZ-1st-boot.xml 0444 root sys
d none /opt/site 0755 root sys
f none /opt/site/AZ-1st-boot.sh 0555 root sys
# cat AZ-1st-boot.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='AZ:1st-boot-svc'>
<service name='site/1st-boot-svc' type='service' version='1'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency
name='multi-user'
grouping='require_all'
restart_on='none' type='service'>
<service_fmri value='svc:/milestone/multi-user:default'/>
</dependency>
<exec_method
type='method'
name='start'
exec='/opt/site/AZ-1st-boot.sh'
timeout_seconds='300'>
<method_context>
<method_credential user='root'/>
</method_context>
</exec_method>
<exec_method
type='method'
name='stop'
exec=':true'
timeout_seconds='30'/>
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='transient'/>
</property_group>
</service>
</service_bundle>
# cat AZ-1st-boot.sh
#!/bin/sh
. /lib/svc/share/smf_include.sh
BIN=/usr/bin
SBIN=/usr/sbin
#.................................................................
# configure and enable SAR
$BIN/ed -s /var/spool/cron/crontabs/sys <<EOF
a
0,5,10,15,20,25,30,35,40,45,50,55 * * * 0-6 /usr/lib/sa/sa1
59 23 * * 0-6 /usr/lib/sa/sa2 -A
.
w
q
EOF
$SBIN/svcadm enable svc:/system/sar:default
#.................................................................
# configure FSS scheduler
$SBIN/dispadmin -d FSS
#.................................................................
# self-destroy
$SBIN/svcadm disable svc:/site/1st-boot-svc:default
$SBIN/svccfg delete -f svc:/site/1st-boot-svc:default
$BIN/ed -s <<EOF
a
mail=
setuid=nocheck
action=nocheck
.
w /tmp/AZ.admin
q
EOF
$SBIN/pkgrm -n -a /tmp/AZ.admin AZ-1st-boot
#.................................................................
# end
$SBIN/shutdown -i6 -g5 -y
exit $SMF_EXIT_OK
# pkgmk -o -d /package
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: missing directory entry for </opt>
WARNING: missing directory entry for </var>
WARNING: missing directory entry for </var/svc>
WARNING: missing directory entry for </var/svc/manifest>
WARNING: missing directory entry for </var/svc/manifest/site>
## Attempting to volumize 3 entries in pkgmap.
part 1 -- 18 blocks, 14 entries
## Packaging one part.
/package/AZ-1st-boot/pkgmap
/package/AZ-1st-boot/pkginfo
/package/AZ-1st-boot/root/opt/site/AZ-1st-boot.sh
/package/AZ-1st-boot/root/var/svc/manifest/site/AZ-1st-boot.xml
## Validating control scripts.
## Packaging complete.