All 1 entries tagged Install

View all 3 entries tagged Install on Warwick Blogs | View entries tagged Install at Technorati | There are no images tagged Install on this blog

September 19, 2013

Having fun with Oracle's Solaris 11.1 Automated Installer – Adding a repo for post install scripts

I've been having a go at post install scripts with AI

I needed to do this as I wanted to configure IPMP and this is a post install task.

Actually the notes from oracle on this were much better than the ones on AI: http://docs.oracle.com/cd/E26502_01/html/E28980/firstboot-1.html#scrolltoc

1. You create a run once script.

2. You make it into a run once service

3. Make it available for clients when they are installing in a repo

4. Specify the package in your clients manifest

1. You create a run once script:

The bit you write is in the middle, the rest is part of making it a run once only service.

#!/bin/ksh93 -vx
# Run once post install script
# Sep 2013

# Load SMF shell support definitions
. /lib/svc/share/smf_include.sh

# If nothing to do, exit with temporary disable
completed=`svcprop -p config/completed site/first-boot-script-svc:default`
[ "${completed}" = "true" ] && \
smf_method_exit $SMF_EXIT_TEMP_DISABLE completed "Configuration completed"

# Obtain the active BE name from beadm: The active BE on reboot has an R in
# the third column of 'beadm list' output. Its name is in column one.
bename=`beadm list -Hd|nawk -F ';' '$3 ~ /R/ {print $1}'`
beadm create ${bename}.orig
echo "Original boot environment saved as ${bename}.orig"

# Configure ipmp
/usr/sbin/route -p delete default ROUTER_ADDRESS -ifp net0
/usr/sbin/svcadm restart routing-setup
/usr/sbin/ipadm create-ipmp ipmp0
/usr/sbin/ipadm delete-ip net0
/usr/sbin/ipadm create-ip net0
/usr/sbin/ipadm create-ip net2
/usr/sbin/ipadm add-ipmp -i net0 -i net2 ipmp0
/usr/sbin/ipadm create-addr -a IPADDR/NN ipmp0
/usr/sbin/route -p add default ROUTER_ADDRESS
/usr/sbin/svcadm restart routing-setup

# Record that this script's work is done
svccfg -s site/first-boot-script-svc:default setprop config/completed = true
svcadm refresh site/first-boot-script-svc:default
smf_method_exit $SMF_EXIT_TEMP_DISABLE method_completed "Configuration completed"

2. You make it into a run once service

For speed I used svcbundle to create the service:

# svcbundle -s service-name=site/first-boot-script-svc -s start-method=/opt/site/first-boot-script.sh -s instance-property=config:completed:boolean:false > first-boot-script-svc-manifest.xml

# mkdir -p ../proto/lib/svc/manifest/site
# mkdir -p ../proto/opt/site
# cp first-boot-script-svc-manifest.xml ../proto/lib/svc/manifest/site
# cp first-boot-script.sh ../proto/opt/site

Create first-boot-script.p5m

set name=pkg.fmri value=first-boot-script@1.0,5.11-0
set name=pkg.summary value="first-boot script"
set name=pkg.description value="Script that runs at first boot after AI installation"
set name=info.classification value=\
"org.opensolaris.category.2008:System/Administration and Configuration"
file lib/svc/manifest/site/first-boot-script-svc-manifest.xml \
path=lib/svc/manifest/site/first-boot-script-svc-manifest.xml owner=root \
group=sys mode=0444
dir path=opt/site owner=root group=sys mode=0755
file opt/site/first-boot-script.sh path=opt/site/first-boot-script.sh \
owner=root group=sys mode=0555


3. Make it available for clients when they are installing in a repo

I created a new repo for this:

# pkgrepo create /repo/firstbootrepo
# pkgrepo -s /repo/firstbootrepo add-publisher firstboot
# pkgrepo set -s /repo/firstbootrepo/ publisher/prefix=firstboot

# pkgsend publish -d ../proto -s /repo/firstbootrepo/ first-boot-script.p5m

# svccfg -s pkg/server add firstboot
# svccfg -s pkg/server:firstboot setprop pkg/port=NN
# svccfg -s pkg/server:firstboot setprop pkg/inst_root=/repo/firstbootrepo
# svccfg -s pkg/server:firstboot setprop pkg/readonly=true

# svcadm disable application/pkg/server:firstboot
# svcadm enable application/pkg/server:firstboot

Tip top tip (Sep 2013, Solaris v11.1) whenever you have published anything the service needs to be disabled and re-enabled before you can see the package!

4. Specify the package in your clients manifest

In the <software type="IPS"> section locate <source> and add your publisher, add a <new software_data_action="install">

<software type="IPS">
<destination>
<image>
<!-- Specify locales to install -->
<facet set="false">facet.locale.*</facet>
<facet set="true">facet.locale.en</facet>
<facet set="true">facet.locale.en_GB</facet>
</image>
</destination>
<source>
<publisher name="solaris">
<origin name="http://SERVERNAME/solaris"/>
</publisher>
<publisher name="firstboot">
<origin name="http://SERVERNAME:NN/firstboot"/>
</publisher>
</source>
<!--
By default the latest build available, in the specified IPS
repository, is installed. If another build is required, the
build number has to be appended to the 'entire' package in the
following form:

<name>pkg:/entire@0.5.11-0.build#</name>
-->
<software_data action="install">
<name>pkg:/entire@latest</name>
<name>pkg:/group/system/solaris-large-server</name>
<name>pkg:/system/locale/extra</name>
</software_data>
<software_data action="install">
<name>pkg:/first-boot-script</name>
</software_data>
</software>

November 2019

Mo Tu We Th Fr Sa Su
Oct |  Today  |
            1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30   

Search this blog

Tags

Galleries

Most recent comments

  • hello. i am from poland. i uwielbiam was! by on this entry
  • Hello, It was more for internal consumption, I will check it over and send you a version, can you em… by Maria MacCallum on this entry
  • Hello Maria, i don't see the script setup–zone.sh, can you post it ? I'am looking too for an example… by FRANCISCO on this entry
  • Solaris 11.2 returns the value of SI_MEMSIZE in Mb's now by Maria MacCallum on this entry

Blog archive

Loading…
RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXIX