[OpenAFS] OpenAFS 1.4.8pre3 on Solaris 10 x86

Tony D'Amato tdamato@odu.edu
Thu, 23 Oct 2008 16:16:35 -0400


This is a multi-part message in MIME format.
--------------050303090207070505040600
Content-Type: multipart/alternative;
 boundary="------------050800030505050700090809"


--------------050800030505050700090809
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Rich Sudlow wrote:
> Tony D'Amato wrote:
>   
>> I've just installed OpenAFS 1.4.8pre3 on my Solaris 10 x86 workstation
>> at work... so far, so good...
>>
>> I know there was a discussion some time ago about using SMF to manage
>> OpenAFS, and I believe I've got it stable enough to share with the group
>> if anyone is interested...
>>
>>     
>
> Hi Tony
>         I'm interested in SMF also - If you could send it to me or
> preferably to the list I think others would appreciate it.
>   

Okay... you've talked me into it *grin*

Please note that my SMF support is from the client side at this point. 
I'm preparing some Solaris 10 OpenAFS servers, so I'll have a chance to 
begin to play there. This SMF support has been pieced together from 
various mailing lists and thus include the original author's names - I 
take no credit for the original code except that this version works for 
me. YMMV.

Basically, I use two files, a manifest and an exec method, attached below:

   openafs-client.xml, saved as /var/svc/manifest/network/openafs/client.xml

   openafs-client.sh, saved as /usr/vice/etc/openafs-client

After copying them in place, I issue

    svccfg -v import /var/svc/manifest/network/openafs/client.xml
    svcadm -v enable network/openafs/client

to fire it up. (The comparable server versions would have 'client' 
replaced with 'server', but I'm not prepared to share those yet, unless 
you really want to play with untested code...)

Here they are. If anyone has any comments/concerns/gotchas that I may be 
unaware of, please let me know (and please be nice to me *grin*) Thanks!

-- 
Tony D'Amato, SCSA (it's Exchange that puts "Nicholas" there)
Senior UNIX Systems Administrator
Server Support Group, OCCS
Old Dominion University


--------------050800030505050700090809
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rich Sudlow wrote:
<blockquote cite="mid:4900CED0.9050601@nd.edu" type="cite">
  <pre wrap="">Tony D'Amato wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I've just installed OpenAFS 1.4.8pre3 on my Solaris 10 x86 workstation
at work... so far, so good...

I know there was a discussion some time ago about using SMF to manage
OpenAFS, and I believe I've got it stable enough to share with the group
if anyone is interested...

    </pre>
  </blockquote>
  <pre wrap=""><!---->
Hi Tony
        I'm interested in SMF also - If you could send it to me or
preferably to the list I think others would appreciate it.
  </pre>
</blockquote>
<br>
Okay... you've talked me into it *grin*<br>
<br>
Please note that my SMF support is from the client side at this point.
I'm preparing some Solaris 10 OpenAFS servers, so I'll have a chance to
begin to play there. This SMF support has been pieced together from
various mailing lists and thus include the original author's names - I
take no credit for the original code except that this version works for
me. YMMV.<br>
<br>
Basically, I use two files, a manifest and an exec method, attached
below:<br>
<br>
&nbsp;&nbsp; openafs-client.xml, saved as
/var/svc/manifest/network/openafs/client.xml<br>
<br>
&nbsp;&nbsp; openafs-client.sh, saved as /usr/vice/etc/openafs-client<br>
<br>
After copying them in place, I issue<br>
<br>
&nbsp;&nbsp;&nbsp; svccfg -v import /var/svc/manifest/network/openafs/client.xml<br>
&nbsp;&nbsp;&nbsp; svcadm -v enable network/openafs/client<br>
<br>
to fire it up. (The comparable server versions would have 'client'
replaced with 'server', but I'm not prepared to share those yet, unless
you really want to play with untested code...)<br>
<br>
Here they are. If anyone has any comments/concerns/gotchas that I may
be unaware of, please let me know (and please be nice to me *grin*)
Thanks!<br>
<pre class="moz-signature" cols="72">-- 
Tony D'Amato, SCSA (it's Exchange that puts "Nicholas" there)
Senior UNIX Systems Administrator
Server Support Group, OCCS
Old Dominion University
</pre>
</body>
</html>

--------------050800030505050700090809--

--------------050303090207070505040600
Content-Type: text/xml;
 name="openafs-client.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="openafs-client.xml"

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
	manifest for openafs/client service
	based upon manifests created by Coy Hile and
	Waltraut.Niepraschk@desy.de and heavily modified
	by Tony D'Amato <tdamato@odu.edu>
-->
<service_bundle type='manifest' name='openafs:client'>

<service
	name='network/openafs/client'
	type='service'
	version='1'>

	<create_default_instance enabled='false' />

	<single_instance />

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

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

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

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

	<dependency
		name='afsd'
		grouping='require_all'
		restart_on='none'
		type='path'>
		    <service_fmri 
			 value='file://localhost/usr/vice/etc/afsd' />
	</dependency> 

	<dependency
		name='ThisCell'
		grouping='require_all'
		restart_on='none'
		type='path'>
		    <service_fmri 
			 value='file://localhost/usr/vice/etc/ThisCell' />
	</dependency> 

	<dependency
		name='CellServDB'
		grouping='require_all'
		restart_on='none'
		type='path'>
		    <service_fmri 
			 value='file://localhost/usr/vice/etc/CellServDB' />
	</dependency>

	<dependency
		name='cacheinfo'
		grouping='require_all'
		restart_on='none'
		type='path'>
		    <service_fmri 
			 value='file://localhost/usr/vice/etc/cacheinfo' />
	</dependency>
	
	<!--
		Make svc:/system/zones depend on OpenAFS client.  This
		is necessary so that any zones that are pseudo AFS clients
		can see /afs
	-->
	<dependent
		name='zones'
		grouping='require_all'
		restart_on='none'>
			<service_fmri
			    value='svc:/system/zones' />
	</dependent>

	<!--
		Make svc:/system/console-login optionally dependent
		on OpenAFS client. This is necessary in case someone
		who needs /afs tries to log in
	-->
	<!--    gets error for now.
	<dependent
		name='console-login'
		grouping='optional_all'
		restart_on='none'>
			<service_fmri
			    value='svc:/system/console-login'/>
	</dependent>
	-->

	<exec_method
		type='method'
		name='start'
		exec='/usr/vice/etc/openafs-client start'
		timeout_seconds='3600' />

	<exec_method
		type='method'
		name='stop'
		exec='/usr/vice/etc/openafs-client stop'
		timeout_seconds='60' />

	<!--
		Set the 'transient' property so that smf(5) doesn't
		try to restart the afsd daemons.
	-->
	<property_group
		name='startd'
		type='framework'>
		<propval name='duration' type='astring' value='transient' />
	</property_group>

	<property_group name='OpenAFS' type='application'>
		<stability value='Unstable' />
		<propval name='afsdb' type='boolean' value='true' />
		<propval name='dynroot' type='boolean' value='false' />
		<propval name='fakestat' type='boolean' value='false' />
	</property_group>

	<template>
		<common_name>
			<loctext xml:lang='C'>
			OpenAFS client
			</loctext>
		</common_name>
		<documentation>
		</documentation>
	</template>
</service>

</service_bundle>

--------------050303090207070505040600
Content-Type: text/plain;
 name="openafs-client.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="openafs-client.sh"

#!/bin/sh
#
# Copyright 2005. Coy Hile. All Rights Reserved
# ident	"@(#)openafs-client.sh	1.4	05/10/20"
#
# Service Management method for OpenAFS client
#
# We assume that the application is being installed using Transarc
# paths.

. /lib/svc/share/smf_include.sh

AFSDB=`svcprop -p OpenAFS/afsdb svc:/network/openafs/client`
DYNROOT=`svcprop -p OpenAFS/dynroot svc:/network/openafs/client`
FAKESTAT=`svcprop -p OpenAFS/fakestat svc:/network/openafs/client`

case "$1" in
start)
    #
    # Make sure an entry for afs exists in /etc/name_to_sysnum. If not,
    # add it and reboot the system so that the changes take effect.  
    #
    if grep -s "afs" /etc/name_to_sysnum > /dev/null; then
        echo "Entry for afs already exists in /etc/name_to_sysnum"
    else
        echo "Creating entry for afs in /etc/name_to_sysnum"
        cp /etc/name_to_sysnum /etc/name_to_sysnum.orig
        sed '/nfs/i\
afs                     65' /etc/name_to_sysnum > /tmp/name_to_sysnum
        mv /tmp/name_to_sysnum /etc/name_to_sysnum
        #### don't automatically reboot ####
        #echo "Rebooting now for new /etc/name_to_sysnum to take effect"
        #sync; sync; sync
        #/etc/reboot
        echo ""
        echo "#######################################################################"
        echo ""
        echo "   'afs' entry was added/updated in /etc/name_to_sysnum."
        echo "    You will need to reboot prior to running OpenAFS."
        echo "    Skipping OpenAFS startup."
        echo ""
        echo "#######################################################################"
        echo ""
        echo "'afs' entry was added/updated in /etc/name_to_sysnum." >> /dev/console
        echo "You will need to reboot prior to running OpenAFS." >> /dev/console
        echo "Skipping OpenAFS startup." >> /dev/console
        exit 1
    fi

    # Check that /bin/isalist is executable
    if [ ! -x /bin/isalist ]; then
	echo "/bin/isalist is not executable; skipping startup"
	exit 1;
    fi

    # Determine the right locations for the kernel modules and load them
    case `/bin/isalist` in
	*amd64* )
	    nfssrv=/kernel/misc/amd64/nfssrv
	    afs=/kernel/fs/amd64/afs
	    ;;
	*sparcv9* )
	    nfssrv=/kernel/misc/sparcv9/nfssrv
	    afs=/kernel/fs/sparcv9/afs
	    ;;
	* )
	    nfssrv=/kernel/misc/nfssrv
	    afs=/kernel/fs/afs
	    ;;
    esac

    if [ -f $nfssrv ]; then
        modid=`modinfo | awk '/nfssrv/ {print $1}'`
        if [ ! -z "$modid" ] ; then
            echo "NFS kernel extensions already loaded"
        else
	    echo "Loading NFS server kernel module"
	    modload $nfssrv
        fi
    else
	echo "$nfssrv does not exist. skipping AFS startup"
	exit 1
    fi
    if [ -f $afs ]; then
        modid=`modinfo | awk '/afs .* filesystem/ {print $1}'`
        if [ ! -z "$modid" ] ; then
            echo "AFS kernel extensions already loaded"
        else
	    echo "Loading AFS kernel module"
	    modload $afs
        fi
    else
	echo "$afs does not exist. skipping AFS startup"
	exit 1
    fi

    # Set up the server options and start the bosserver.
    OPTIONS=
    if [ "$AFSDB" = true ]; then
	OPTIONS="-afsdb"
    fi
    if [ "$DYNROOT" = true ]; then
	OPTIONS="$OPTIONS -dynroot"
    fi
    if [ "$FAKESTAT" = true ]; then
	OPTIONS="$OPTIONS -fakestat"
    fi

    # Check that the root directory for AFS and the client cache 
    # directories both exist
    #
    for dir in `/usr/bin/awk -F: '{print $1,$2}' /usr/vice/etc/cacheinfo `
    do
	if [ ! -d ${dir} ]; then
	    echo "${dir} does no exist. Not starting AFS client"
	    exit 2
	fi
    done

    pgrep -f /usr/vice/etc/afsd >/dev/null
    if [ $? -eq 0 ]; then
        echo "AFS already running - not starting afsd"
        exit 0
    else
        echo "Starting afsd"
        /usr/vice/etc/afsd $OPTIONS
    fi
    # end of start method
    ;;

stop )
    echo "Shutting down AFS client processes"
    cd /
    umount /afs
    /usr/vice/etc/afsd -shutdown -waitclose
    sleep 10

    ################################################
    ## WARNING - DO NOT unload the module!
    ##   Causes Kernel Panics!
    ################################################

    # unload kernel module
    #   but not for afs server

    #if [ -x /usr/afs/bin/bosserver ]; then
    #    echo "Kernel module not unloaded due to this machine is an afs server"
    #else
    #    modid=`modinfo | awk '/afs .* filesystem/ {print $1}'`
    #    if [ ! -z "$modid" ]; then
    #        modunload -i $modid
    #        [ $? -eq 0 ] && echo "Kernel module unloaded."
    #    else
    #        echo "No AFS kernel module loaded"
    #    fi
    #fi
    ;;

*)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

--------------050303090207070505040600--