Monday, April 26, 2010

Complete local copy (mirror) of pkg.opensolaris.org

As you are aware with every official release of OpenSolaris, comes a full download of all the IPS packages (7GB), but what happens if you want to work on the pkg.opensolaris.org/dev releases and you want a local mirror. I have found this blog which does it. I have modified it slight since I think it had a couple of errors.

1. Create partition to store the packages. I have been told a complete will be around 65GB, but I am using a cut down version.
$ pfexec zfs create -o atime=off rpool/export/pkg
2. Create repository
pfexec pkgsend -s file:///export/pkg create-repository -–set-property publisher.prefix=opensolaris.org
3. Obtain list of packages you want.  In this case everything currently install and the release (134) I am interested in.
$ cd /export/pkg
$ pfexec pkg list -Hva | egrep “134:|install” > /tmp/pkglist.txt
$ head -1 /tmp/pkglist.txt
pkg://opensolaris.org/SUNWcs@0.5.11,5.11-0.134:20100302T005446Z

$ pfexec cat /tmp/pkglist.txt | sed 's/pkg:\/\/opensolaris\.org\///' \
       | cut -f 1 -d ' ' > /tmp/packages.txt
$ head -1 /tmp/packages.txt
SUNWcs@0.5.11,5.11-0.134:20100302T005446Z

4.Now download IPS package and place it into local repository.
$ for i in $(cat /tmp/packages.txt); 
do 
pfexec pkgrecv -s http://pkg.opensolaris.org/dev -d file:///export/pkg "$i"
done
5. You can test it to see all is there (http://localhost:80)

$ pfexec /usr/lib/pkg.depotd -d /export/pkg -p 80

6. To make sure the repository is always available.

$ pfexec svccfg -s application/pkg/server setprop pkg/inst_root=/export/pkg
$ pfexec svcadm refresh pkg/server
$ pfexec svcadm enable pkg/server

London OpenSolaris User Group (LOSUG) - Finally did a talk

Autoinstaller: Past & Present

I gave a talk at the LOSUG meeting on Autoinstaller in OpenSolaris 2009.06 and will talk about what is new in 2010.03. He will talk about and demonstrate how to use Autoinstaller to install OpenSolaris to your own personnel specification, including Autoinstaller Manifests, pkg repository, creating IPS package and SMF service.

Thursday, January 21, 2010

Step-by-Step guide to Install OpenSolaris with Automated Installer (2009.06)

If you want to install OpenSolaris on to many computers then you will need to use Automated Installer (AI) which allows you to remotely install the Operating System hands free. This article will be a first of a few examples which will show you how to to do this.

To demonstrate the whole procedure of using AI to build and install OpenSolaris, local packages and finish scripts I am going to do this in a closed environment without a network. It is a complete OpenSolaris Automated Install (AI) example. All you will need is a computer (a good specification desktop or laptop) where we will install OpenSolaris and use VirtualBox as the AI install client. You will not require a network to do any this after you have you have download all the software requirements.
  1. Install OpenSolaris
  2. Download all the relevant software and save it on your system
  3. Install VirtualBox
  4. Setup server for static IP address
  5. Reboot
  6. Create a OpenSolaris VirtualBox client
  7. Setup up Automated Install server
  8. Give it a test
  9. Create new AI Manifests
  10. Create local repository to replace pkg.opensolaris.org
  11. Check repository
  12. You can now do your first auto install by booting VirtualBox client
  13. Setup local Repository for your Packages
  14. Create a test package
  15. Create the "jumpstart finish script" package
  16. FINISHpkg package information
  17. Add package to our local repository
  18. Need to alter AI Manifests
  19. Moment of truth..
1. Install OpenSolaris
2. Download all the relevant software and save it on your system
$ pfexec pkg install SUNWinstalladm-tools
$ pfexec mkdir /export/aiserver  /export/aiimages
$ ls -1 /export/aiimages
osol-0906-ai-x86.iso
osol-0906-x86.iso
osol-repo-0906-full.iso
VirtualBox-3.1.2-56127-SunOS.tar.gz

3. Install VirtualBox
$ cd /export/aiimages
$ pfexec gzip -dc VirtualBox-3.1.2-56127-SunOS.tar.gz | tar xf -
$ pfexec pkgadd -d VirtualBox-3.1.2-SunOS-r56127.pkg

4. Setup server for static IP address
$  ifconfig -a
e1000g0: flags=......
vboxnet0: flags=.....   inet 192.168.56.1 netmask ffffff00 broadcast 192.168.56.255
  • Disable auto magic network
$ pfexec svcadm disable network/physical:nwam
  • Edit the following /etc/hosts (hostname which I used was opensolaris)
  • Before
# Internet host table
#
::1  opensolaris opensolaris.local  localhost   loghost
127.0.0.1   opensolaris  opensolaris.local  localhost  loghost
  • After
# Internet host table
#
::1   loghost
127.0.0.1  localhost
192.168.56.1  opensolaris  opensolaris.local    loghost
  • And start up the network service
$ pfexec svcadm enable network/physical:default

5. Reboot (Just to make sure all is working)
  • If you want a network then you can active it (my interface is e1000g0)
  • $ pfexec  ifconfig e1000g0 plumb
    $ pfexec  ifconfig e1000g0 dhcp
    $ pfexec  cp  /etc/nsswitch.dns  /etc/nsswitch.conf
6. Create a OpenSolaris VirtualBox client
  • Ref: PXE booting with NAT , PXE Booting in VirtualBox
  • Start VirtualBox and create a OpenSolaris guest.
  • I will call it ai_client and save virtual disk in default location
  • Minimum disk size is 13GB
  • Set up network boot ai_client-> Settings -> System -> Motherboard (tab) -> Boot Order: (Select) Network
  • Move Network to the top of the list
  • You don't need to do the above, but make sure when you start the client you press F12 for boot menu then select (l) LAN
  • Set up the PXE, TFTP boot
$ mkdir $HOME/.VirtualBox/TFTP
  • Start the ai_client guest and with any luck you will see PXE software message, but it will fail since you have no tftp file to load
  • Now we are going to inform the VirualBox Client where to look for the boot server (note my machine is using the e1000 network interface)
$ VBoxManage setextradata "ai_client" "VBoxInternal/Devices/e1000/0/LUN#0/Config/NextServer" 192.168.56.1
$ VBoxManage getextradata "ai_client" enumerate
VirtualBox Command Line Management Interface Version 3.1.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Key: GUI/AutoresizeGuest, Value: on
Key: GUI/Fullscreen, Value: off
Key: GUI/InfoDlgState, Value: 400,450,normal
Key: GUI/LastCloseAction, Value: powerOff
Key: GUI/LastWindowPostion, Value: 430,184,720,474
Key: GUI/MiniToolBarAlignment, Value: bottom
Key: GUI/MiniToolBarAutoHide, Value: on
Key: GUI/SaveMountedAtRuntime, Value: yes
Key: GUI/Seamless, Value: off
Key: GUI/ShowMiniToolBar, Value: yes
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/NextServer, Value: 192.168.56.1

7. Setup up Automated Install server
$ pfexec installadm create-service -n 0906x86 -s /export/aiimages/osol-0906-ai-x86.iso  /export/aiserver/osol-0906-ai-x86
Setting up the target image at /export/aiserver/osol-0906-ai-x86 ...
Registering the service 0906x86._OSInstall._tcp.local

Detected that DHCP is not set up on this server.
If not already configured, please create a DHCP macro
named dhcp_macro_0906x86 with:
Boot server IP (BootSrvA) : 192.168.56.1
Boot file      (BootFile) : 0906x86
GRUB Menu      (GrubMenu) : menu.lst.0906x86
If you are running Sun's DHCP server, use the following
command to add the DHCP macro, dhcp_macro_0906x86:
/usr/sbin/dhtadm -g -A -m dhcp_macro_0906x86 -d :BootSrvA=192.168.56.1:BootFile=0906x86:GrubMenu=menu.lst.0906x86:

Additionally, if the site specific symbol GrubMenu
is not present, please add it as follows:
/usr/sbin/dhtadm -g -A -s GrubMenu -d Site,150,ASCII,1,0

Note: Be sure to assign client IP address(es) if needed
(e.g., if running Sun's DHCP server, run pntadm(1M)).
adding tftp to /etc/inetd.conf
Converting /etc/inetd.conf
copying boot file to /tftpboot/pxegrub.I86PC.OpenSolaris-1
Service discovery fallback mechanism set up
  • This will start a new service called install/server and populate /export/aiserver/osol-0906-ai-x86 and /tftpboot
  • When VirtualBox Client boots via PXE it will want to download specific file names off this tftpboot server, depending on the name of the VirtualBox client. We will create them manually
  • Before you ask! I am not using installadm install-client since it does not take a hostname
$ cd /tftpboot
$ ls -l
lrwxrwxrwx   1 root     root          27 Aug 28 10:50 0906x86 -> pxegrub.I86PC.OpenSolaris-1
drwxr-xr-x   6 root     sys            9 May 18  2009 I86PC.OpenSolaris-1
-rw-r--r--   1 root     root         325 Aug 28 10:50 menu.lst.0906x86
-rwxr-xr-x   2 root     root      139024 Aug 28 10:50 pxegrub.I86PC.OpenSolaris-1
-rw-r--r--   1 root     root         130 Aug 28 10:50 rm.0906x86

$ pfexec ln -s pxegrub.I86PC.OpenSolaris-1  ai_client.pxe
$ pfexec ln -s menu.lst.0906x86 menu.lst.ai_client.pxe

8. Give it a quick test
  • Try rebooting your client to see if it boots. We are not finished yet, but the VirtualBox Client should load the basic kernel. It will fail!

9. Create new AI Manifests
  • Ref: Administer the Manifest Files
  • Going to use the default Manifest but with a couple of modifications:
  • First point at our local copy of pkg.opensolaris.org repository which will be created next
  • Secondly - which we will leave for a little later - to add our own repository for our software
$ cd /export/aiserver/osol-0906-ai-x86/auto_install
$ pfexec cp default.xml  aibuild.xml
  • Edit aibuild.xml and replace
<main url="http://pkg.opensolaris.org/release" authname="opensolaris.org"/>
  • with
<main url="http://192.168.56.1" authname="opensolaris.org"/>
  • Then we need to process this manifest
$ pfexec /usr/sbin/installadm add -m aibuild.xml -n 0906x86

10. Create local repository to replace pkg.opensolaris.org
$ pfexec zfs create -o compression=on -o atime=off rpool/export/pkg
$ pfexec lofiadm -a /export/aiimages/osol-repo-0906-full.iso
/dev/lofi/1
$ pfexec mount -F hsfs /dev/lofi/1 /mnt
$ pfexec rsync -aP /mnt/repo /export/pkg
...wait....
  • Edit your repo settings
pfexec vi /export/pkg/repo/cfg_cache
  • replace
origins = http://pkg.opensolaris.org/release
  • with
origins = http://192.168.56.1
  • Configure and start the pkg-server
$ pfexec svccfg import /var/svc/manifest/application/pkg-server.xml
$ pfexec svccfg -s application/pkg/server setprop pkg/inst_root=/export/pkg/repo
$ pfexec svccfg -s application/pkg/server setprop pkg/readonly=true
$ pfexec svcadm refresh pkg/server
$ pfexec svcadm enable pkg/server

11. Check repository
  • Open the URL in your browser http://localhost and you should see all the packages

12.
You can now do your first auto install by booting VirtualBox client
  • After some time you should get a working OpenSolaris system in your VirtualBox client, but this is just a standard build
  • Now we want to add our packages and run a finished script to do some systems changes on first boot. At Last!!

13.
Setup local Repository for your Packages
  • Ref: Creating Repositories and Setting Up a Mirror Repository
  • Before we create our own packages you need a local repository
  • Default location is "/var/pkg/repo" since using the existing configuration files. Not sure what needs to exist to use a new location!
$ pfexec svccfg -s pkg/server
svc:/application/pkg/server> add local
svc:/application/pkg/server> select local
svc:/application/pkg/server:local> addpg pkg application
svc:/application/pkg/server:local> addpg start method
svc:/application/pkg/server:local> setprop start/exec= astring: "/usr/lib/pkg.depotd -p %{pkg/port} -d %{pkg/inst_root} -t %{pkg/socket_timeout} -s %{pkg/threads} --log-access=%{pkg/log_access} --log-errors=%{pkg/log_errors}"
svc:/application/pkg/server:local> setprop pkg/inst_root = astring: "/var/pkg/repo"
svc:/application/pkg/server:local> setprop pkg/threads = count: 50
svc:/application/pkg/server:local> setprop pkg/port = count: 9000
svc:/application/pkg/server:local> exit
$ pfexec svcadm refresh pkg/server:local
$ pfexec svcadm enable pkg/server:local
$ svcs pkg/server
STATE          STIME    FMRI
online         12:45:40 svc:/application/pkg/server:local
online         12:44:12 svc:/application/pkg/server:default
  • Any errors can be located in the log file
$ svcs -l pkg/server:local
fmri         svc:/application/pkg/server:local
name         image packaging repository
enabled      true
state        online
next_state   none
state_time   22 January 2010 13:02:15 GMT
logfile      /var/svc/log/application-pkg-server:local.log
restarter    svc:/system/svc/restarter:default
contract_id  120
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   optional_all/none svc:/system/filesystem/autofs (online)
dependency   optional_all/none svc:/network/ntp (disabled)
dependency   require_all/none svc:/milestone/network (online)
  • You can check all is well via the URL http://localhost:9000

14. Create a test package

$ cd /export
# pfexec bash
# mkdir pkgs
# cd pkgs
# mkdir -p opt/local
# echo "Hello" > opt/local/Hello.txt
# chmod 0600 opt/local/Hello.txt
# chmod 0755 opt  opt/local
# chown root:bin opt opt/local opt/local/Hello.txt
# cat > hellopkg.ips
set name=pkg.name            value="Hello"
set name=pkg.description     value="Hello Program"
dir mode=0755 owner=root group=bin path=/opt
dir mode=0755 owner=root group=bin path=/opt/local
file opt/local/Hello.txt mode=0600 owner=root group=bin path=/opt/local/Hello.txt
^D
# eval `pkgsend -s http://localhost:9000 open hellopkg@1.0-0`
# pfexec pkgsend -s http://localhost:9000 include hellopkg.ips
# pkgsend -s http://localhost:9000 close
  • You can then see the package at URL http://localhost:9000

15. Create the "jumpstart finish script" package

  • Now we are going to build a package which will do the job of the old Solaris Jumpstart finish script.
  • The package will be installed at build time.
  • The package will contain files which will setup any personnel settings.
  • The package may overwrite existing files.
  • The package will contain a SMF service which will be executed at first boot to alter the machine at run time

16. FINISHpkg package information

  • Here is an example list of files you can have in such a package, these files would allow for LDAP setup, automount setup, Network Setup, etc
  • The way you would create these files is to install OpenSolaris on a machine and set it up manually to the way you want it and transfer these files to this package.
/lib/svc/method/ai-finish
/etc/nsswitch.conf
/etc/auto_master
/etc/auto_direct
/etc/hosts.allow
/etc/hosts.equiv
/etc/X11/gdm/custom.conf
/etc/defaultdomain
/etc/mail/sendmail.cf
/etc/mail/cf/cf/dcs.mc
/etc/hosts.deny
/etc/resolv.conf
/etc/auto_local
/var/ldap/ldap_client_file
/var/ldap/ldap_client_cred
/var/svc/manifest/system/ai-finish.xml
/var/svc/profile/site.xml
  • In this example I will look at a subset of the above
/etc/X11/gdm/custom.conf
/var/svc/profile/site.xml
/lib/svc/method/ai-finish
/var/svc/manifest/system/ai-finish.xml
  • /etc/X11/gdm/custom.conf - so that we add the Reboot to the Login Window.
  • Staying as root
# cd /export/pkgs
# mkdir FINISHpkg
# cd FINISHpkg
# find /etc/X11/gdm/custom.conf -print | cpio -pdm .
  • Altered file (/export/pkgs/FINISHpkg/etc/X11/gdm/custom.conf) to set the following options:
[daemon]
RBACSystemCommandKeys=

[security]
SupportAutomount=true

[greeter]
SystemMenu=true
  • Add a site.xml file which is used to modify default services on boot.
# cd /export/pkgs/FINISHpkg
# mkdir -p var/svc/profile
# cat /export/pkgs/FINISHpkg/var/svc/profile/site.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type="profile" name="default">

   <!-- lets switch off sendmail -->
   <service name='network/smtp' version='1' type='service'>
      <instance name='sendmail' enabled='false'/>
   </service>

   <!-- Lets Start a service -->
   <service name='network/ftp' version='1' type='service'>
       <instance name='default' enabled='true'/>
   </service>
   -->
</service_bundle>
# cd /export/pkgs/FINISHpkg
# mkdir -p var/svc/manifest/system lib/svc/method
# cat /export/pkgs/FINISHpkg/var/svc/manifest/system/ai-finish.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
 Created by Andrew Watkins 22nd Jan 2010
 References:
    /var/svc/manifest/network
    http://opensolaris.org/os/community/smf
    http://www.sun.com/bigadmin
-->

<service_bundle type='manifest' name='ai-finish'>
<service
    name='system/ai-finish' type='service' version='1'>

    <property_group name='startd' type='framework'>
            <propval name='duration' type='astring' value='transient' />
    </property_group>

    <instance name='install' enabled='true'>
        <dependency name='filesystem-local'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/system/filesystem/local:default' />
        </dependency>

        <!--
            We want the ai-finish service to complete before
            user action begins.
        -->
        <dependent
                name='ai-finish_multi-user'
                grouping='optional_all'
                restart_on='none'>
                <service_fmri
                        value='svc:/milestone/multi-user' />
        </dependent>
        <exec_method
                type='method'
                name='start'
                exec='/lib/svc/method/ai-finish %i'
                timeout_seconds='0' />

        <exec_method
                type='method'
                name='stop'
                exec=':true'
                timeout_seconds='0' />
    </instance>
    <stability value='Unstable' />

    <template>
        <common_name>
                <loctext xml:lang='C'>
                ai-finish
                </loctext>
        </common_name>
        <description>
                <loctext xml:lang='C'>
                        AI finish script
                </loctext>
        </description>
    </template>
</service>

</service_bundle>

# cat /export/pkgs/FINISHpkg/lib/svc/method/ai-finish 

#!/bin/sh -x

. /lib/svc/share/smf_include.sh

LC_ALL=C; export LC_ALL

RM=/usr/bin/rm
SED=/usr/bin/sed
MYHOST=`/usr/bin/hostname`
REBOOT="no"

RETVAL=$SMF_EXIT_OK

install() {
    # Disable nwam & enable dhcp
    # In our network we need this since we use Microsoft DNS/DHCP and nwam does not configure dhcp correctly to pass nodename to DHCP server
    # Not sure what will happen in a VirtualBox client but again it shows what can be done
    if [ -s "/etc/nwam/llp" ]; then
        #If nwam has found a interface it will populate the above file so we will use it
        echo "disable nwam"
        svcadm disable svc:/network/physical:nwam
        INTERFACE=`awk ' { print $1 } ' /etc/nwam/llp`
        echo "Found interface: $INTERFACE"
        if [ -n "$INTERFACE" ]; then
           REBOOT="yes"
           echo "inet $MYHOST" > /etc/hostname.$INTERFACE
           cp /etc/default/dhcpagent /tmp
           sed -e s/#.*CLIENT_ID=/CLIENT_ID=$MYHOST/ -e 's/#.*REQUEST_HOSTNAME=no/REQUEST_HOSTNAME=yes/' /tmp/dhcpagent > /etc/default/dhcpagent
           touch /etc/dhcp.$INTERFACE

           echo "Starrting network/physical:default"
           svcadm enable svc:/network/physical:default

           # reset name_service to ldap to always use ldap
           # In our example this will not run
           if [ -h /var/svc/profile/name_service.xml -a -f  /var/svc/profile/ns_ldap.xml -a -f /var/ldap/ldap_client_file ]; then
              rm /var/svc/profile/name_service.xml
              ln -s /var/svc/profile/ns_ldap.xml /var/svc/profile/name_service.xml
           fi
        fi
    fi
}

case "$1" in
'install')
    # Run it
    install

    # Disable this service so that it doesn't run again.
    /usr/sbin/svcadm disable system/ai-finish

    if [ "$REBOOT" = "yes" ]; then
       echo "Rebooting"
       ( sleep 30; init 6 ) &
    fi
    echo "Finished"
    if [ $? -ne 0 ] ; then
        exit $SMF_EXIT_ERR_CONFIG
    fi
    ;;

*)
    echo "Usage: $0 { install }"
    exit $SMF_EXIT_ERR_CONFIG
    ;;
esac

exit $SMF_EXIT_OK
  • I have not add many comments here but I hope there is enough information to help you
  • Create the manifest for this package
# cd /export/pkgs/FINISHpkg
# cat > /export/pkgs/FINISHpkg/FINISHpkg.ips
set name=pkg.name            value="FINISHpkg"
set name=pkg.description     value="setup machine we want it"
dir  mode=0755 owner=root group=root path=/etc
dir  mode=0755 owner=root group=root path=/etc/X11
dir  mode=0755 owner=root group=root path=/etc/X11/gdm
dir  mode=0755 owner=root group=sys path=/var
dir  mode=0755 owner=root group=sys path=/var/svc
dir  mode=0755 owner=root group=sys path=/var/svc/manifest
dir  mode=0755 owner=root group=sys path=/var/svc/profile
file etc/X11/gdm/custom.conf mode=0644 owner=root group=root path=/etc/X11/gdm/custom.conf
file var/svc/profile/site.xml mode=0644 owner=root group=root path=/var/svc/profile/site.xml
file lib/svc/method/ai-finish mode=0754 owner=root group=bin path=/lib/svc/method/ai-finish
file var/svc/manifest/system/ai-finish.xml mode=0644 owner=root group=sys path=/var/svc/manifest/system/ai-finish.xml
^D

17. Add package to our local repository

# eval `pkgsend -s http://localhost:9000 open FINISHpkg@1.0-0`
# pkgsend -s http://localhost:9000 include FINISHpkg.ips
# pkgsend -s http://localhost:9000 close
  • Check it appears in the repository

18. Need to alter
AI Manifests

  • Here are 2 new manifest files to replace the early one
  • I have highted the changes
# cd /export/aiserver/osol-0906-ai-x86/auto_install
# cat aibuild.xml
<!--
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 2009 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
-->

<ai_criteria_manifest>
<ai_embedded_manifest>
<ai_manifest name="default">
  <ai_pkg_repo_default_authority>
      <main url="http://192.168.56.1" authname="opensolaris.org"/>
      <mirror url=""/>
</ai_pkg_repo_default_authority>
  <ai_pkg_repo_addl_authority>
      <main url="http://192.168.56.1:9000" authname="local"/>
  </ai_pkg_repo_addl_authority>
<!--
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 following
form:

<pkg_name="entire@0.5.11-0.build#/>
-->
<ai_install_packages>
<!--
Due to dependency issues, entire must be listed first
in the package list, followed by SUNWcsd, and then SUNWcs.
Any additional packages must be listed after SUNWcs.
-->
<pkg name="entire"/>
<pkg name="SUNWcsd"/>
<pkg name="SUNWcs"/>
<pkg name="babel_install"/>
      <!-- You can add more packages if you want -->
      <!-- <pkg name="openoffice"/> -->
      <pkg name="FINISHpkg"/>
</ai_install_packages>
<ai_uninstall_packages>
<pkg name="babel_install"/>
<pkg name="slim_install"/>
</ai_uninstall_packages>
<ai_auto_reboot>
      false
  </ai_auto_reboot>
</ai_manifest>
</ai_embedded_manifest>

<sc_manifest_file name="AI" URI="./scbuild.xml"/>

</ai_criteria_manifest>

# cat scbuild.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="profile" name="name">
<service name="ai_properties" version="1" type="service">
<instance name="default" enabled="true">
<property_group name="ai" type="application">
        <propval name="username" type="astring" value="guest"/>
        <!--passwd = letmein -->
        <propval name="userpass" type="astring" value="eAcu7bKjwwxb6"/>
<propval name="description" type="astring" value="default_user"/>
<!--default root passsord -->
<propval name="rootpass" type="astring" value="$5$VgppCOxA$ycFmYW4ObRRHhtsGEygDdexk5bugqgSiaSR9niNCouC"/>
<propval name="timezone" type="astring" value="GB"/>
        <propval name='hostname' type='astring' value='ai_client'/>
</property_group>
</instance>
</service>
</service_bundle>

# /usr/sbin/installadm add -m aibuild.xml -n 0906x86

19. Moment of truth..
  • Now boot your VirtualBox client and lets see what happens...and wait.....
  • login on root/opensolaris
  • monitor the process cat /tmp/install_log
  • You will have to manually reboot the client when finished since I have set auto_reboot=false
  • When you reboot you must make sure you change the setting to boot off disk. either press F12 in intro screen or deselect Network (Settings -> System -> Motherboard (tab) -> Boot Order: (UnSelect) Network

Wednesday, June 17, 2009

Sun Storage 7110 Create a share for Windows & Solaris use

The main reason I got the Sun Storage is to to combine our existing 2 home drives per user down to One (see last week), so that we have access to CIFS shares and NFS shares via the Storage System (well via OpenSolaris)

Mon June 22nd 2009: I have updated it since the ACL were not 100% correct.

1. Create a new project, so that you don't change the default setting and enable the CIFS protocol, NFS is enabled by default.




2. If you want ACL/permissions to be inherited correctly then you need to alter the "Inherited ACL Behavior", which is the ZFS command "zfs set aclinherit=passthrough rpool/ROOT/b114b" for reference.




3. Create a share with all the relevant information, name, uid, group and permissions.




4. Need to set up mapping between our Solaris LDAP server and Windows AD system.




5. It is a straight mapping of LDAP <=> AD for users and groups.




6. Next edit Access ACL for the new share. I think the "Owner" should have full control.




7. Here is a full description of the letters and what they represent in windows.






8. And the final product after a few global ACL's have been added. Plus the owner of the directory should be added as well. This is because if Windows Admin creates a file then you want the owner still to have access.




9. Now lets test it.....

Tuesday, June 09, 2009

Does the Sun Storage 7110 do the job (Introduction)

I have just had a delivery of a Try and Buy Sun Storage 7110 Unified Storage System system. As you are aware this is Sun's new storage system built on top of the OpenSolaris Operating System. I am not going to look at the fancy features of the system which include one of the best GUI I have see and again the best Analytics which you would ever need (I think you could spot what the user had for breakfast with this system).

What I want to know will it do the job of a file server for my mixed Windows and Solaris environment.

Current System
Windows servers with dedicated disk systems and Solaris servers also with
dedicated disk system. The user ends up with 2 home drives (Windows & Solaris), which I want reduced to 1 home directory!!!

Bad News
We recently bought 2 NAS e-open system which set us back £20k which I have to say is a waste of space and it is not just me who says that (Open-E Review, Not a Storage Server
). The main reason is that Linux/Samba does not do it as a Windows server replacement and there is no mapping system between AD and LDAP, so I would have to reconfigure our Solaris system which is not the perfect solution.

Friday, January 23, 2009

Build a DVD Jumpstart image for SXCE/Nevada (OpenSolaris)

I have had a lot of trouble recently getting Jumpstart to work with no PXE server with SXCE/Nevada. The last time I got it to work was with Solaris Express B90 (when Sun releases it)

I need to update my lab of Desktops to a newer version so I decided to build my own DVD with Jumpstart built in. I think at the moment the OpenSolaris/Indiana release does not make this procedure possible, so sticking with SXCE.

This solution is not perfect but it works!

The procedure is:
  1. Obtain the latest iso version
  2. Copy iso to a disk for editing
  3. Extract the mini boot for editing
  4. Replace original sysidcfg with your version
  5. Rebuild miniboot
  6. Edit grub menu
  7. Add your jumpstart features (Packages, Scripts, etc)
  8. Rebuild iso image
  9. Write iso image to DVD

Step by step guide

1. Obtain the latest Nevada/SXCE iso version (or even Solaris)

2. Copy iso to a disk for editing
  • Need to mount the ISO (i.e. sol-nv-b105-x86-dvd.iso)
  • Then copy contents to some where on your hard disk
# lofiadm -a /export/iso/sol-nv-b105-x86-dvd.iso
dev/lofi/1
# mount -o ro -F hsfs -o ro /dev/lofi/1 /mnt
# mkdir /export/dvd
# cd /mnt
# find . -depth -print | cpio -pdm /export/dvd

3. Extract the mini boot for editing
# gzcat /export/dvd/boot/x86.miniroot > /var/tmp/bootfile
# lofiadm -a /var/tmp/bootfile
/dev/lofi/2
# mkdir /tmp/bootfile
# mount /dev/lofi/2 /tmp/bootfile
# ls /tmp/bootfile
a cdrom etc mnt proc sbin ....

4. Replace original sysidcfg with your version
  • My sysidcfg setups ldap, root password, etc...
# cd /tmp/bootfile/etc
# rm sysidcfg
# cat > sysidcfg
network_interface=e1000g0 {primary dhcp protocol_ipv6=no}
security_policy=none
name_service=LDAP {domain_name=dcs.bbk.ac.uk profile=default profile_server=193.xx.yy.zz proxy_dn="cn=proxyagent,ou=profile,dc=dcs,dc=bbk,dc=ac,dc=uk" proxy_password="PLAIN TEXT PASSWORD"}
nfs4_domain=dynamic
root_password="Encrypted Password"
terminal=dtterm
timezone="GB"
timeserver=193.xx.yy.zz
system_locale=C
keyboard=UK-English
service_profile=limited_net
^D
# cd /var/tmp

5. Rebuild miniboot
# umount /tmp/bootfile
# lofiadm -d /dev/lofi/2
# gzip /var/tmp/bootfile
# mv /var/tmp/bootfile.gz /export/dvd/boot/x86.miniroot

6. Edit grub menu
  • Need to add the install option so that performs a hands-off Jumpstart install
  • I have also added another item so that the default is to boot off the disk. i.e. it will not do a install unless you pick Jumpstart items
  • I have also altered it so that it gets the jumpstart scripts from a tar file on the web server
  • edit /export/dvd/boot/grub/menu.lst so it looks like
default=0
timeout=30
min_mem64 1024
title Boot From Disk
    rootnoverify (hd0)
    chainloader +1
title Custom Jumpstart
    verbose
    kernel /boot/platform/i86pc/kernel/unix - install http://193.61.29.21/solaris/config.tar -B install_media=cdrom
    module /boot/x86.miniroot

7. Add your Jumpstart features (Packages, Scripts, etc)
  • With any luck you have this already otherwise please see the Sun docs
  • Basically I have some extra packages (/opt/sfw and some scripts which alter system files)
  • Tar the whole directory and place it on web server
  • Copy any packages to the DVD if required
# cd /export/jumpstart
# tar cf /opt/htdocs/solaris/config.tar .
# cp -rp /export/ExtraPackages /export/dvd

8. Rebuild ISO image
  • Now we have our new grub menu
  • New miniroot
  • Extra Packages on the DVD
  • Now we need to create the ISO
  • You may get some warnings out filename conversions, which I have not solved yet, but I do not use these packages so it is OK.
/usr/bin/mkisofs -d -D -J -l -r -U -relaxed-filenames -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -c .catalog -V "OpenSolaris" -o /var/tmp/output.iso /export/dvd

Using TopicSelectors$Subscri000.class for /var/tmp/dvd/Solaris_11/Produc/SUNWiqdoc/reloc/usr/demo/imq/jm/TopicSelectors$Subscriber$MultipleListener.class (TopicSelectors$Subscriber.class)

1.85% done, estimate finish Thu Jan 15 16:43:42 2009
...
Size of boot image is 4 sectors -> No emulation
1.43% done, estimate finish Thu Jan 15 11:08:14 2009
99.78% done, estimate finish Thu Jan 15 11:15:08 2009
Total translation table size: 2048
Total rockridge attributes bytes: 4369317
Total directory bytes: 23724032
Path table size(bytes): 185830
Max brk space used 23da000
1753844 extents written (3425 MB)
#

9. Write iso image to DVD
# cdrw -i /var/tmp/output.iso


That is it folks.

References:
http://blogs.sun.com/rv/entry/getting_opensolaris_into_an_usb
Creating OpenSolaris USB Sticks Is Easy
reating a Customized Boot CD/DVD for the Solaris Operating System for x86 Platforms

Saturday, November 08, 2008

Getting Wordpress to work with Server2Go

One more topic on Sever2Go and Windows and then I will get back to OpenSolaris.

WordPress is a a popular publishing platform with a focus on aesthetics, web standards, and usability. If you want to get it up and running on a USB stick using Server2Go then read on [see previous post about Server2Go].
  1. Download the latest version in this case 2.6.3

  2. Extract the files to your USB stick under the htdocs directory i.e. \server2go_a2\htdocs

  3. You should now have a directory structure which looks like server2go_a2\htdocs\wordpress

  4. You can now follow the instruction on the wordpress site, but they should go like this:
    • Rename the wp-config-sample.php file to wp-config.php
    • Open wp-config.php in your favorite text editor (Notepad) and edit the top few lines so they look this:
    • define('DB_NAME', 'server2go');
      define('DB_USER', 'root');
      define('DB_PASSWORD', '');
      define('DB_HOST', 'localhost');
      define('DB_CHARSET', 'utf8');
      define('DB_COLLATE', '');



    • Yes username is root and the password is blank.
    • I am using the existing database, but you could create a new one.
    • try the URL http://localhost:4001/wordpress/wp-admin/install.php and see what happens....



    • Well you are on your own now!!!!

Friday, November 07, 2008

Complete Webserver on a USB stick running on Windows (sorry)

I know I said I would never blog about Windows, but this piece of software is so great, I just have to mention it. Server2Go is a Webserver that runs out of the box without any installation and on write protected media if you wish, but I am going show you (step by step guide) how to get it up and running on a USB stick, so you can develop your website and all you need is a PC (or a Mac) and your USB stick:
  1. Download the software (Update 27/2/2012). There are a few different version but I went for "PHP 5.3.2, SQLite, MySQL 5.1.46 and Apache 2.2.15" (server2go_a22_psm.exe).
  2. Extract the downloaded file to your USB drive. It will take at least 200MB of space.
  3. Now you have to be careful since you need to edit a file.
    • You need to edit a file called pms_config.ini in the sub-directory \server2go_a2



    • Use any editor you like put I used Notepad.
    • You need to find the following variables and edit them to the new values.
      • StartLocal = 1
      • LocalMirror = 0
      • Port=8888 (You may have to change port number Update 27/2/2012)
  4. Now start the software by double clicking on \server2go_a2\Server2Go.exe
  5. With any luck the IE will start and will look like:
  6. With the above all done you can create wab pages in the directory \server2go_a2\htdocs and all changes you make to the MySQL will stay

Monday, October 27, 2008

Recap: Live Upgrade with ZFS root using SXCE (Nevada/OpenSolaris)

This is just a follow up to my previous blog entry "Live Upgrade with ZFS root using SXCE (Nevada)". I thought I would just do a quick recap, since I wanted to add a couple of points. For the full example and the output which is expected see the above entry.

Live Upgrade
  1. Preparation
  2. # lofiadm -a /export/iso/sol-nv-b99-x86-dvd.iso
    /dev/lofi/1
    # mount -o ro -F hsfs -o ro /dev/lofi/1 /mnt
    #
    pkgrm SUNWluu SUNWluzone SUNWlur SUNWlucfg
    #
    pkgadd -d /mnt/Solaris_11/Product SUNWlucfg SUNWlur SUNWluu SUNWluzone
  3. Create a new boot environment
    • If this is your first live upgrade then use this command (-c Assigns a name to the current current Boot Environment)
    # lucreate -c b97 -n b99
    # lucurr
    b97
    • Otherwise if you have done live upgrades before you do not need -c
    # lucreate -n b99
  4. Check it
  5. # lustatus
    Boot Environment Is Active Active Can Copy
    Name Complete Now On Reboot Delete Status
    -------------------------- -------- ------ --------- ------ ----------
    b95a yes no no yes -
    b97 yes yes yes no -
    b99 yes no no yes -
  6. Upgrade
  7. # luupgrade -u -n b99 -s /mnt
    # zfs list
    NAME                      USED  AVAIL  REFER  MOUNTPOINT
    rpool 151G 77.5G 41K /rpool
    rpool/ROOT 32.2G 77.5G 18K legacy
    rpool/ROOT/b95a 88.7M 77.5G 12.4G /tmp/.alt.luupdall.6066
    rpool/ROOT/b97 27.8G 77.5G 11.1G /
    rpool/ROOT/b97@20080820 7.77G - 9.51G -
    rpool/ROOT/b97@b97 8.57G - 12.4G -
    rpool/ROOT/b97@20080916 64.9M - 10.9G -
    rpool/ROOT/b97@b98 14.7M - 11.1G -
    rpool/ROOT/b99 4.34G 77.5G 11.2G /tmp/.luupgrade.inf.6336
    rpool/dump 2.97G 77.5G 2.97G -
    rpool/export 113G 77.5G 43.6G /export
    rpool/export/home 69.1G 77.5G 69.1G /export/home
    rpool/swap 2.97G 78.7G 1.75G -
  8. Make it your default boot enviroment
  9. # luactivate b99
  10. Reboot. WARNING must use init command
# init 6


Trouble Shooting:

  • - Error about mount point not empty during a live upgrade or after:
i.e.
ERROR: cannot mount '/.alt.tmp.b-nnb.mnt/': directory is not empty
or
cannot mount '/export/home': directory is not empty
This is most likely that there is a file or directory in this location or a mount point already exist.

Check only current system mounted (NO /.alt.. or /export/home) and then do some cleaning up (WARNING: before doing the "rm -ir" make sure you are happy delete these files)
# df -F zfs
/ (rpool/ROOT/snv_98 )
/export (rpool/export )
/export/home (rpool/export/home )
/rpool (rpool )


# zfs unmount /export/home
# ls -adR
/.alt.tmp.b-nnb.mnt /export/home
# rm -ir /.alt.tmp.b-nnb.mnt /export/home
# zfs unmount /export
# ls -adR /export
# rm -ir /export

# zfs mount /export
# zfs mount /export/home
or
# lumount NV95
# luunmount NV95

Thursday, August 21, 2008

Live Upgrade with ZFS root using SXCE (Nevada)

Couple of weeks ago I did a fresh install of "Solaris Express Community Edition snv_94" and selected ZFS root to see what it was like on my desktop. Then I thought I would upgrade to snv_95, but then I could not see any information about doing a live upgrade, what was I going to do!

After some searching I found a couple of old pages which hinted at it but not a full example, so there was only one way to find out......

Step-by-step guide.
  1. Download latest SXCE in this case sol-nv-b95-x86-dvd.iso
  2. Mount the ISO on the system
  3. # lofiadm -a /export/iso/sol-nv-b95-x86-dvd.iso
    /dev/lofi/1
    # mount -o ro -F hsfs -o ro /dev/lofi/1 /mnt
  4. Upgrade to the latest Live Upgrade Packages
  5. # pkginfo SUNWluu SUNWluzone SUNWlur SUNWlucfg
    application SUNWlucfg Live Upgrade Configuration
    application SUNWlur Live Upgrade (root)
    application SUNWluu Live Upgrade (usr)
    application SUNWluzone Live Upgrade (zones support)

    # pkgrm SUNWluu SUNWluzone SUNWlur SUNWlucfg
    # cd /mnt/Solaris_11/Product
    # pkgadd -d . SUNWlucfg SUNWlur SUNWluu SUNWluzone

  6. Now the fun! Create a new boot environment. lucreate has a new option -p which specifies the ZFS pool
  7. -p zfs_root_pool
    Specifies the ZFS pool in which a new BE will reside.
    This option can be omitted if the source and target BEs are within the same pool.
    e.g. lucreate -c b94 -n b95a -p newpool
    # lucreate -c b94 -n b95a
    Checking GRUB menu...
    System has findroot enabled GRUB
    Analyzing system configuration.
    Comparing source boot environment <b94> file systems with the file
    system(s) you specified for the new boot environment. Determining which
    file systems should be in the new boot environment.
    Updating boot environment description database on all BEs.
    Updating system configuration files.
    Creating configuration for boot environment <b95a>.
    Source boot environment is <b94>.
    Creating boot environment <b95a>.
    Cloning file systems from boot environment <b94> to create boot environment <b95a>.
    Creating snapshot for <rpool/root/snv_94> on <rpool/root/b95a@b95a>.
    Creating clone for <rpool/root/b95a@b95a> on <rpool/root/b95a>.
    Setting canmount=noauto for </> in zone <global> on <rpool/ROOT/b95a>.
    Saving existing file </boot/grub/menu.lst> in top level dataset for BE <b95a> as <mount-point>//boot/grub/menu.lst.prev.
    File </boot/grub/menu.lst> propagation successful
    Copied GRUB menu from PBE to ABE
    No entry for BE <b95a> in GRUB menu
    Population of boot environment <b95a> successful.
    Creation of boot environment <b95a> successful.

  8. Check all is well
  9. # lustatus
    Boot Environment           Is       Active Active    Can    Copy
    Name Complete Now On Reboot Delete Status
    -------------------------- -------- ------ --------- ------ ----------
    b94 yes yes yes no -
    b95a yes no no yes -

    # zfs list
    NAME                       USED  AVAIL  REFER  MOUNTPOINT
    rpool 112G 116G 41K /rpool
    rpool/ROOT 14.7G 116G 18K legacy
    rpool/ROOT/snv_94 14.6G 116G 6.78G /
    rpool/ROOT/b95a 81.8M 116G 9.51G /.alt.tmp.b-Cz.mnt/

  10. Now do the upgrade
  11. # luupgrade -u -n b95a -s /mnt
    System has findroot enabled GRUB
    No entry for BE <b95a> in GRUB menu
    Copying failsafe kernel from media.
    Uncompressing miniroot
    Uncompressing miniroot archive (Part2)
    13364 blocks
    Creating miniroot device
    miniroot filesystem is <ufs>
    Mounting miniroot at </mnt/Solaris_11/Tools/Boot>
    Mounting miniroot Part 2 at </mnt/Solaris_11/Tools/Boot>
    Validating the contents of the media </mnt>.
    The media is a standard Solaris media.
    The media contains an operating system upgrade image.
    The media contains <Solaris> version <11>.
    Constructing upgrade profile to use.
    Locating the operating system upgrade program.
    Checking for existence of previously scheduled Live Upgrade requests.
    Creating upgrade profile for BE <b95a>.
    Checking for GRUB menu on ABE <b95a>.
    Saving GRUB menu on ABE <b95a>.
    Checking for x86 boot partition on ABE.
    Determining packages to install or upgrade for BE <b95a>.
    Performing the operating system upgrade of the BE <b95a>.
    CAUTION: Interrupting this process may leave the boot environment unstable or unbootable.
    Upgrading Solaris: 100% completed
    Installation of the packages from this media is complete.
    Restoring GRUB menu on ABE <b95a>.
    Adding operating system patches to the BE <b95a>.
    The operating system patch installation is complete.
    ABE boot partition backing deleted.
    PBE GRUB has no capability information.
    PBE GRUB has no versioning information.
    ABE GRUB is newer than PBE GRUB. Updating GRUB.
    GRUB update was successful.
    Configuring failsafe for system.
    Failsafe configuration is complete.
    INFORMATION: The file </var/sadm/system/logs/upgrade_log> on boot environment <b95a> contains a log of the upgrade operation.
    INFORMATION: The file </var/sadm/system/data/upgrade_cleanup> on boot environment <b95a> contains a log of cleanup operations required.
    WARNING: <1> packages failed to install properly on boot environment <b95a>.
    INFORMATION: The file </var/sadm/system/data/upgrade_failed_pkgadds> on boot environment <b95a> contains a list of packages that failed to upgrade or install properly.
    INFORMATION: Review the files listed above. Remember that all of the files are located on boot environment <b95a>. Before you activate boot environment <b95a>, determine if any additional system maintenance is required or if additional media of the software distribution must be installed.
    The Solaris upgrade of the boot environment <b95a> is partially complete.
    Installing failsafe
    Failsafe install is complete.

  12. Check status
  13. # lustatus
    Boot Environment           Is       Active Active    Can    Copy      
    Name Complete Now On Reboot Delete Status
    -------------------------- -------- ------ --------- ------ ----------
    b94 yes yes yes no -
    b95a yes no no yes -

  14. If you want to look at the new filesystem
  15. # zfs mount rpool/ROOT/b95a
    # df -F zfs
    /                  (rpool/ROOT/snv_94   ):243553838 blocks 243553838 files
    /export (rpool/export ):243553838 blocks 243553838 files
    /export/home (rpool/export/home ):243553838 blocks 243553838 files
    /rpool (rpool ):243553838 blocks 243553838 files
    .alt.tmp.b-Cz.mnt (rpool/ROOT/b95a ):243553838 blocks 243553838 files
    # zfs unmount rpool/ROOT/b95a

  16. Make it live
  17. # luactivate b95a
    System has findroot enabled GRUB
    Generating boot-sign, partition and slice information for PBE <b94>
    Saving existing file </etc/bootsign> in top level dataset for BE <b94> as <mount-point>//etc/bootsign.prev.
    WARNING: <1> packages failed to install properly on boot environment <b95a>.
    INFORMATION: </var/sadm/system/data/upgrade_failed_pkgadds> on boot environment <b95a> contains a list of packages that failed to upgrade or install properly. Review the file before you reboot the system to determine if any additional system maintenance is required.

    Generating boot-sign for ABE <b95a>
    Saving existing file </etc/bootsign> in top level dataset for BE <b95a> as <mount-point>//etc/bootsign.prev.
    Generating partition and slice information for ABE <b95a>
    Copied boot menu from top level dataset.
    Generating direct boot menu entries for PBE.
    Generating xVM menu entries for PBE.
    Generating direct boot menu entries for ABE.
    Generating xVM menu entries for ABE.
    Disabling splashimage
    Re-enabling splashimage
    No more bootadm entries. Deletion of bootadm entries is complete.
    GRUB menu default setting is unaffected
    Done eliding bootadm entries.

    **********************************************************************
    The target boot environment has been activated. It will be used when you
    reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You
    MUST USE either the init or the shutdown command when you reboot. If you
    do not use either init or shutdown, the system will not boot using the
    target BE.
    **********************************************************************
    In case of a failure while booting to the target BE, the following process
    needs to be followed to fallback to the currently working boot environment:
    1. Boot from Solaris failsafe or boot in single user mode from the Solaris
    Install CD or Network.
    2. Mount the Parent boot environment root slice to some directory (like
    /mnt). You can use the following command to mount:

    mount -Fzfs /dev/dsk/c1d0s0 /mnt

    3. Run <luactivate> utility with out any arguments from the Parent boot environment root slice, as shown below:

    /mnt/sbin/luactivate

    4. luactivate, activates the previous working boot environment and indicates the result.

    5. Exit Single User mode and reboot the machine.

    **********************************************************************

    Modifying boot archive service
    Propagating findroot GRUB for menu conversion.
    File </etc/lu/installgrub.findroot> propagation successful
    File </etc/lu/stage1.findroot> propagation successful
    File </etc/lu/stage2.findroot> propagation successful
    File </etc/lu/GRUB_capability> propagation successful
    Deleting stale GRUB loader from all BEs.
    File </etc/lu/installgrub.latest> deletion successful
    File </etc/lu/stage1.latest> deletion successful
    File </etc/lu/stage2.latest> deletion successful
    Activation of boot environment <b95a> successful.
    #

  18. Reboot I see what happens.....

Wednesday, August 20, 2008

VirtualBox fails to run on snv_95 OpenSolaris

Just upgraded to snv_95 (SXCE: Nevada) and Virtualbox failed to start.

# VirtualBox
ERROR: 0 bytes read from child process

Failed to create the VirtualBox COM object.
Callee RC 0x80470007

After a panic, several reboots I found the web link which get me the solution:

http://www.virtualbox.org/ticket/1840

Summary:
========

Start VBoxSVC with environment variable LD_NODIRECT=1:

# cd /opt/VirtualBox
# mv VBoxSVC VBoxSVC.real
# cat > VBoxSVC
#!/bin/sh
LD_NODIRECT=1
export LD_NODIRECT
exec /opt/VirtualBox/VBoxSVC.real "$@"
^D
# chmod +x VBoxSVC

Friday, May 30, 2008

Solaris SMF manifest for mimedefang

I have been using MIMEDefang for some time and I thought I would write a Solaris SMF manifest so it would fit with the new Solaris 10 services.

I started off looking at a collection of existing manifest files from smtp-sendmail.xml to ssh.xml and a few online pages. So to convert your existing installation to use SMF do:

[updated 3rd July 2008 : init-script.in]

1) Rename the old startup files (you can delete them at a later date):
# ls /etc/rc?.d/*mimedefang
/etc/rc0.d/K38mimedefang /etc/rc1.d/K38mimedefang /etc/rc2.d/S82mimedefang /etc/rcS.d/K38mimedefang
# mv /etc/rc0.d/K38mimedefang etc/rc0.d/_K38mimedefang
# mv /etc/rc1.d/K38mimedefang etc/rc1.d/_K38mimedefang
# mv /etc/rc2.d/S82mimedefang etc/rc2.d/_S82mimedefang
# mv /etc/rcS.d/K38mimedefang etc/rc1.d/_S38mimedefang

2) Copy the startup file to a different location. You could put it in /lib/svc/method where all the Solaris ones are located, but I decided to keep it with the other mimedefang software (if you do change the location make sure you update the manifest file correctly):
# cp /etc/init.d/mimedefang /usr/local/mimedefang/bin/init-mimedefang

3) You can use your existing startup file and it will work with this manifest, but if you want to make full use of the manifest, then use this new version.

4) The download version is a replacement for the "examples/init-script.in" found in the source code directory, so you will need to to be put it in place before you build mimedefang (init-script is built when you run configure) and then copy init-script to in new location.
# cp  examples/init-script   /usr/local/mimedefang/bin/init-mimedefang
Changes are:
- Altered it to get rid of some none Solaris options.
- Altered the stop_it routines so it does a better job (better use of kill and more checking), which means that mimedefang will auto restart if it dies.
- Altered so it makes use of the properties of the service.
# diff -u init-script.orig init-script.in
--- init-script.orig    Thu Oct 18 17:46:05 2007
+++ init-script.in    Thu Jul 3 12:19:29 2008
@@ -1,15 +1,22 @@
#!/bin/sh
#
-# FreeBSD/NetBSD start/stop script for MIMEDefang.
+# Solaris 10 start/stop script for MIMEDefang.
#
# PROVIDE: mimedefang
# REQUIRE: LOGIN
# BEFORE: mail
# KEYWORD: shutdown
+Modified 3rd July 2008
+    - added extra test in stop_it so mimedefang restarts after a "pkill -u defang"

-RETVAL=0
+. /lib/svc/share/smf_include.sh
+
+RETVAL=$SMF_EXIT_OK
prog='mimedefang'
-SPOOLDIR='@SPOOLDIR@'
+
+# Obtain SPOOLDIR (default=/var/spool/MIMEDefang)
+SPOOLDIR=`/usr/bin/svcprop -p config/spooldir $SMF_FMRI`
+SPOOLDIR=${SPOOLDIR:-'@SPOOLDIR@'}
PID="$SPOOLDIR/$prog.pid"
MXPID="$SPOOLDIR/$prog-multiplexor.pid"

@@ -40,7 +47,8 @@
# SOCKET=$SPOOLDIR/mimedefang.sock

# Run the multiplexor and filters as this user, not root. RECOMMENDED
-MX_USER=@DEFANGUSER@
+MX_USER=`/usr/bin/svcprop -p config/mx_user $SMF_FMRI`
+MX_USER=${MX_USER:-'@DEFANGUSER@'}

# Syslog facility
# SYSLOG_FACILITY=mail
@@ -51,6 +59,8 @@

# "yes" turns on the multiplexor relay checking function
# MX_RELAY_CHECK=no
+MX_RELAY_CHECK=`/usr/bin/svcprop -p config/mx_relay_check $SMF_FMRI`
+MX_RELAY_CHECK=${MX_RELAY_CHECK:-'no'}

# "yes" turns on the multiplexor HELO checking function
# MX_HELO_CHECK=no
@@ -57,9 +67,13 @@

# "yes" turns on the multiplexor sender checking function
# MX_SENDER_CHECK=no
+MX_SENDER_CHECK=`/usr/bin/svcprop -p config/mx_sender_check $SMF_FMRI`
+MX_SENDER_CHECK=${MX_SENDER_CHECK:-'no'}

# "yes" turns on the multiplexor recipient checking function
# MX_RECIPIENT_CHECK=no
+MX_RECIPIENT_CHECK=`/usr/bin/svcprop -p config/mx_recipient_check $SMF_FMRI`
+MX_RECIPIENT_CHECK=${MX_RECIPIENT_CHECK:-'no'}

# Set to yes if you want the multiplexor to log events to syslog
MX_LOG=yes
@@ -112,7 +126,8 @@

# Minimum number of processes to keep. The default of 0 is probably
# too low; we suggest 2 instead.
-MX_MINIMUM=2
+MX_MINIMUM=`/usr/bin/svcprop -p config/mx_minimum $SMF_FMRI`
+MX_MINIMUM=${MX_MINIMUM:-'2'}

# Maximum number of processes to run (mail received while this many
# processes are running is rejected with a temporary failure, so be
@@ -119,7 +134,8 @@
# wary of how many emails you receive at a time). This applies only
# if you DO use the multiplexor. The default value of 2 is probably
# too low; we suggest 10 instead
-MX_MAXIMUM=10
+MX_MAXIMUM=`/usr/bin/svcprop -p config/mx_maximum $SMF_FMRI`
+MX_MAXIMUM=${MX_MAXIMUM:-'10'}

# Uncomment to log slave status; it will be logged every
# MX_LOG_SLAVE_STATUS_INTERVAL seconds
@@ -173,29 +189,6 @@
     . @CONFDIR_EVAL@/$prog.conf
fi

-# BSD specific setup
-if [ -f /etc/rc.subr ]
-then
-    . /etc/rc.subr
-
-    name=$prog
-    rcvar=`set_rcvar`
-    # default to not enabled, enable in rc.conf
-    eval $rcvar=\${$rcvar:-NO}
-
-    load_rc_config $name
-
-    pidfile=$MXPID
-    procname=$PROGDIR/$prog-multiplexor
-    start_cmd="start_it"
-    stop_cmd="stop_it"
-    sig_reload="INT"
-    reread_cmd="reread_it"
-    # provide both "reload", the FreeBSD default, with a direct signal to
-    # the multiplexor, and "reread", the MIMEDefang default, using md-mx-ctrl
-    extra_commands="reload reread"
-fi
-
# Make sure required vars are set
SOCKET=${SOCKET:=$SPOOLDIR/$prog.sock}
MX_SOCKET=${MX_SOCKET:=$SPOOLDIR/$prog-multiplexor.sock}
@@ -288,11 +281,32 @@
     # Stop daemon
     printf "%-60s" "Shutting down $prog: "
     if test -f "$PID" ; then
-    kill `cat $PID`
-    RETVAL=$?
+    if kill -0 `cat $PID` > /dev/null 2>&1 ; then
+        kill `cat $PID`
+        RETVAL=$?
+    else
+        echo "mimedefang (`cat $PID`) has already been stopped."
+        # double check kill mimedefang , but all should be OK
+        # is this over the top?
+        RETVAL=$SMF_EXIT_OK
+        pkill -0 -u $MX_USER -x $prog > /dev/null 2>&1
+        if [ $? -eq 0 ]; then
+        pkill -u $MX_USER -x $prog
+        RETVAL=$?
+        fi
+    fi
     else
-    RETVAL=1
+    echo "mimedefang has already been stopped."
+    # double check kill mimedefang , but all should be OK
+    # is this over the top?
+    RETVAL=$SMF_EXIT_OK
+    pkill -0 -u $MX_USER -x $prog > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        pkill -u $MX_USER -x $prog
+        RETVAL=$?
+    fi
     fi
+
     if [ $RETVAL = 0 ] ; then
    echo "[ OK ]"
     else
@@ -302,10 +316,30 @@
     # Stop daemon
     printf "%-60s" "Shutting down $prog-multiplexor: "
     if test -f "$MXPID" ; then
-    kill `cat $MXPID`
-    RETVAL=$?
+    if kill -0 `cat $MXPID` > /dev/null 2>&1 ; then
+        kill `cat $MXPID`
+        RETVAL=$?
+    else
+        echo "mimedefang-multiplexor (`cat $MXPID`) has already stopped."
+        # double check kill mimedefang-mult(iplexor) but all should be OK
+        # is this over the top?
+        RETVAL=$SMF_EXIT_OK
+        pkill -0 -u $MX_USER -x $prog-mult > /dev/null 2>&1
+        if [ $? -eq 0 ]; then
+        pkill -u $MX_USER -x $prog-mult
+        RETVAL=$?
+        fi
+    fi
     else
-    RETVAL=1
+    echo "mimedefang-multiplexor has already stopped."
+    # double check kill mimedefang-mult(iplexor) but all should be OK
+    # is this over the top?
+    RETVAL=$SMF_EXIT_OK
+    pkill -0 -u $MX_USER -x $prog-mult > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        pkill -u $MX_USER -x $prog-mult
+        RETVAL=$?
+    fi
     fi
     if [ $RETVAL = 0 ] ; then
    echo "[ OK ]"


5) Create the manifest file (download version):
# cd /var/svc/manifest/network
# cat > mimedefang.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
  Created by Andrew Watkins 9th May 2008
  References:
    /var/svc/manifest/network
    http://opensolaris.org/os/community/smf
    http://www.sun.com/bigadmin
  Thanks to
    David F. Skoll
    Kimmo Jaskari
  Modified 14th May 2008
    - major rewrite
    - added properties
    - dependent on sendmail
-->

<service_bundle type='manifest' name='mimedefang'>
<service name='network/mimedefang' type='service' version='1'>
    <single_instance />

    <dependency name='fs-local' grouping='require_all' restart_on='none'
        type='service'>
        <service_fmri value='svc:/system/filesystem/local' />
    </dependency>

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

    <dependency name='system-log' grouping='optional_all'
        restart_on='none' type='service'>
        <service_fmri value='svc:/system/system-log' />
    </dependency>

    <dependent name='mimedefang_multi-user'
        grouping='optional_all' restart_on='none'>
        <service_fmri value='svc:/milestone/multi-user' />
    </dependent>

    <dependent name='mimedefang_sendmail'
        grouping='optional_all' restart_on='none'>
        <service_fmri value='svc:/network/smtp:sendmail' />
    </dependent>

    <instance name='default' enabled='false'>
    <!-- instance-specific properties, methods, etc. go here. -->
      <dependency name='config-file' grouping='require_all'
          restart_on='refresh' type='path'>
          <service_fmri
            value='file://localhost/etc/mail/mimedefang-filter' />
      </dependency>

      <exec_method type='method' name='start'
        exec='/usr/local/mimedefang/bin/init-mimedefang start'
        timeout_seconds='60' />

      <exec_method type='method' name='stop'
        exec='/usr/local/mimedefang/bin/init-mimedefang stop'
        timeout_seconds='120' />

      <exec_method type='method' name='refresh'
        exec='/usr/local/mimedefang/bin/init-mimedefang reread'
        timeout_seconds='60' />

      <exec_method type='method' name='restart'
        exec='/usr/local/mimedefang/bin/init-mimedefang restart'
        timeout_seconds='60' />

      <property_group name='startd' type='framework'>
        <propval name='ignore_error' type='astring'
          value='core,signal' />
      </property_group>

      <property_group name='config' type='application'>
        <stability value='Evolving' />
        <propval name='spooldir' type='astring' value='/var/spool/MIMEDefang' />
        <propval name='mx_socket' type='astring' value='mimedefang-multiplexor.sock' />
        <propval name='mx_user' type='astring' value='defang' />
        <propval name='mx_relay_check' type='astring' value='no' />
        <propval name='mx_sender_check' type='astring' value='no' />
        <propval name='mx_recipient_check' type='astring' value='no' />
        <propval name='mx_maximum' type='integer' value='10' />
        <propval name='mx_minimum' type='integer' value='2' />
      </property_group>

      <template>
        <common_name>
            <loctext xml:lang='C'>
            mimedefang filtering e-mail system
            </loctext>
        </common_name>
        <documentation>
            <doc_link name='mimedefang' uri='http://www.mimedefang.org' />
        </documentation>
      </template>

    </instance>
    <stability value='Unstable' />
</service>
</service_bundle>
^D
#


6) Check and setup the manifest:
# svccfg validate /var/svc/manifest/network/mimedefang.xml
# svccfg import /var/svc/manifest/network/mimedefang.xml

7) See if it all worked:
# svcs -a mimedefang
STATE          STIME    FMRI
disabled       16:58:48 svc:/network /mimedefang:default

8) Check what properties are available to be altered:
# /usr/bin/svcprop -p config mimedefang:default
config/mx_socket astring mimedefang-multiplexor.sock
config/spooldir astring /var/spool/MIMEDefang
config/stability astring Evolving
config/mx_maximum integer 10
config/mx_minimum integer 2
config/mx_relay_check astring no
config/mx_sender_check astring no
config/mx_recipient_check astring no
config/mx_user astring defang

9) Change any which need to be altered
# svccfg -s mimedefang:default setprop config/mx_maximum = 10
# svccfg -s mimedefang:default setprop config/mx_user = "defang5"
# svccfg -s mimedefang:default setprop config/mx_relay_check = "yes"
# svccfg -s mimedefang:default setprop config/mx_sender_check = 'yes'
# svccfg -s mimedefang:default setprop config/mx_recipient_check = "yes"
# svcadm refresh mimedefang


10) Start it up
# svcadm enable mimedefang
# svcs -a mimedefang
STATE          STIME    FMRI
online         16:59:48 svc:/network /mimedefang:default


11) Check the log file
# svcs -l mimedefang:default
fmri svc:/network/mimedefang:default
name mimedefang filtering e-mail system
enabled true
state online
next_state none
state_time Tue May 27 15:06:25 2008
logfile /var/svc/log/network-mimedefang:default.log
restarter svc:/system/svc/restarter:default
contract_id 284
dependency require_all/refresh file://localhost/etc/mail/mimedefang-filter (online)
dependency require_all/none svc:/system/filesystem/local (online)
dependency require_all/none svc:/network/service (online)
dependency optional_all/none svc:/system/system-log (online)

# cat /var/svc/log/network-mimedefang:default.log

References
smf(5) Frequently Asked Questions
Solaris Service Management Facility - Service Developer Introduction