macos-packaging-using-afs-conf-when-possible-20080121
authorEvan Broder <broder@mit.edu>
Mon, 21 Jan 2008 21:03:48 +0000 (21:03 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 21 Jan 2008 21:03:48 +0000 (21:03 +0000)
LICENSE IPL10
FIXES 81825

switch to afs.conf as other ports use instead of afsd.options,
when possible

src/afsd/afs.rc.darwin
src/packaging/MacOS/OpenAFS.post_install
src/packaging/MacOS/afs.conf [new file with mode: 0644]
src/packaging/MacOS/buildpkg.sh.in

index 9634790..4e3fce3 100644 (file)
@@ -36,19 +36,28 @@ SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
 if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi
 if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi
 
+if [ -f $CONFIG/afs.conf ]; then
+    . $CONFIG/afs.conf
+fi
+
+# Check this file second so that if users have altered the file, it will
+# override the default options
+if [ -f $AFSDOPT ]; then
+    OPTIONS=`cat $AFSDOPT`
+fi
 
 StartService()
 {
     echo "Starting OpenAFS"
 
-    if [ -f $AFSDOPT ]; then
-       OPTIONS=`cat $AFSDOPT`
+    if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
+       AFSD_OPTIONS="$VERBOSE"
     else
-       OPTIONS="$MEDIUM -fakestat"
+       AFSD_OPTIONS="$OPTIONS $VERBOSE"
     fi
 
     if [ "${NETWORKUP}" = "-NO-" ]; then
-        echo $OPTIONS | grep -e '-dynroot' || exit
+        echo $AFSD_OPTIONS | grep -e '-dynroot' || exit
     fi
 
 # Need the commands ps, awk, kill, sleep
@@ -76,7 +85,7 @@ StartService()
     if [ -x /usr/afs/bin/bosserver ]; then
        echo "Starting AFS Server processes"
        /usr/afs/bin/bosserver
-       OPTIONS="$OPTIONS -nosettime"
+       AFSD_OPTIONS="$AFSD_OPTIONS -nosettime"
        sleep 30
     fi
 
@@ -107,7 +116,13 @@ StartService()
     done
 
     echo "Starting afsd"
-    $AFSD $OPTIONS
+    $AFSD $AFSD_OPTIONS
+
+#
+# From /var/db/openafs/etc/config/afs.conf, call a post-init function or
+# command if it's been defined
+#
+    $AFS_POST_INIT
 
 #
 # Call afssettings (if it exists) to set customizable parameters
@@ -118,6 +133,14 @@ StartService()
     fi
 
 #
+# From /var/db/openafs/etc/config/afs.conf, set a sysname list if one was
+# configured.
+#
+    if [ -n "$AFS_SYSNAME" ] ; then
+       fs sysname $AFS_SYSNAME
+    fi
+
+#
 # Run package to update the disk
 #
     if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
@@ -151,6 +174,12 @@ StopService()
 {
     echo "Stopping AFS"
 
+#
+# If a pre-shutdown function was defined in /var/db/openafs/etc/config/afs.conf
+# was defined, then run it
+#
+    $AFS_PRE_SHUTDOWN
+
     if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
        echo "Unmounting /afs"
        umount -f /afs 2>&1 > /dev/console
index 96281e6..6961950 100644 (file)
@@ -44,8 +44,17 @@ if cmp -s config/afsd.options.broken config/afsd.options ; then
 fi
 rm -f config/afsd.options.broken
 
-if [ ! -f config/afsd.options -a -f config/afsd.options.sample ]; then
-   cp config/afsd.options.sample config/afsd.options
+# if the user hasn't changed these settings, then they should just use the new
+# afsd.conf file
+rm -f config/afsd.options.old
+echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' >config/afsd.options.old
+if cmp -s config/afsd.options.old config/afsd.options ; then
+   rm -f config/afsd.options
+fi
+rm -f config/afsd.options.old
+
+if [ ! -f config/afs.conf -a -f config/afs.conf.sample ]; then
+   cp config/afs.conf.sample config/afs.conf
 fi
 
 # testing case -- upgrading from pre 1.2.7, but .last file exists.
diff --git a/src/packaging/MacOS/afs.conf b/src/packaging/MacOS/afs.conf
new file mode 100644 (file)
index 0000000..10ae07c
--- /dev/null
@@ -0,0 +1,94 @@
+# -*- sh -*-
+# WARNING: this file is ignored if /var/db/openafs/etc/config/afsd.options
+# exists. 
+#
+# Copyright 2000, International Business Machines Corporation and others.
+# All Rights Reserved.
+# 
+# This software has been released under the terms of the IBM Public
+# License.  For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
+
+# Configuration information for AFS client.
+
+# Set to "-verbose" for a lot of debugging information from afsd.  Only useful
+# for debugging as it prints a LOT of information.
+VERBOSE=
+
+# AFS client configuration options.
+#
+# Here is a (mostly) complete list of flags that afsd accepts and that are
+# useful here:
+#
+#   -blocks     The number of blocks available in the workstation cache.
+#   -files      The target number of files in the workstation cache (Default:
+#               1000).
+#   -rootvol    The name of the root volume to use.
+#   -stat       The number of stat cache entries.
+#   -hosts      List of servers to check for volume location info FOR THE
+#               HOME CELL.
+#   -memcache   Use an in-memory cache rather than disk.
+#   -cachedir   The base directory for the workstation cache.
+#   -mountdir   The directory on which the AFS is to be mounted.
+#   -confdir    The configuration directory.
+#   -nosettime  Don't keep checking the time to avoid drift (default).
+#   -settime    Keep checking the time to avoid drift.
+#   -verbose    Be chatty.
+#   -debug      Print out additional debugging info.
+#   -daemons    The number of background daemons to start (Default: 2).
+#   -rmtsys     Also fires up an afs remote sys call (e.g. pioctl, setpag)
+#               support daemon 
+#   -chunksize  2^n is the chunksize to be used (Default: use a kernel
+#               module default).
+#   -dcache     The number of data cache entries.
+#   -prealloc   Number of preallocated "small" memory blocks
+#   -waitclose  Make close calls always synchronous (slows them down, though)
+#   -files_per_subdir   Number of files per cache subdir (Default: 2048).
+#
+# Using the memory cache is not recommended.  It's less stable than the disk
+# cache and doesn't improve performance as much as it might sound.
+#
+# The default behavior is to let afsd automatically choose an apporpriate set
+# of flags.  This should produce reasonable behavior for most working sets
+# provided that one is using a modern AFS client (1.4.2 or later).
+#
+# You can override that default behavior by setting OPTIONS to a specific set
+# of flags.
+OPTIONS="-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all"
+
+# The default value for the client sysname (as returned by fs sysname) is
+# determined during the kernel module build and is taken from the architecture
+# and the major Linux kernel version.  Accesses to directories named "@sys" in
+# AFS will be internally redirected to a directory by this name by the AFS
+# client, allowing a single path to resolve to different directories depending
+# on the client architecture.
+#
+# If you would like to override the client sysname, uncomment this line and
+# set the variable to a space-separated list of sysnames.  The AFS client will
+# attempt to resolve @sys to each directory name in the order given.
+AFS_SYSNAME=""
+
+# If you want to prefer particular servers for replicated volumes, you can
+# configure that by defining an afs_server_prefs function here and then
+# uncommenting the setting of AFS_POST_INIT below.  For more information, see
+# fs help setserverprefs and fs getserverprefs (for the current values).
+
+#afs_server_prefs() {
+#    fs setserverprefs <host> <rank>
+#}
+
+# If you want to always run some command after starting OpenAFS, you can put
+# it here.  Note that you cannot run multiple commands, even combined with &&
+# or ; or similar shell meta-characters.  If you want to run multiple
+# commands, define a shell function instead and put the name of the shell
+# function here.
+AFS_POST_INIT=
+
+# Uncomment this line if you defined an afs_server_prefs function.  (If you
+# have other commands that you also want to run, you'll have to put them in
+# that function, as you can only run one function.)
+#AFS_POST_INIT=afs_server_prefs
+
+# If you want to always run some command before shutting down OpenAFS, you can
+# put it here.  The same caveat applies about multiple commands.
+AFS_PRE_SHUTDOWN=
index 4c9cd50..d70c8fd 100644 (file)
@@ -131,7 +131,7 @@ if [ $firstpass = yes ]; then
     else
        echo /Network/afs:/var/db/openafs/cache:30000 > $PKGROOT/private/var/db/openafs/etc/cacheinfo.sample
     fi
-    echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > $PKGROOT/private/var/db/openafs/etc/config/afsd.options.sample
+    cp afs.conf $PKGROOT/private/var/db/openafs/etc/config/afs.conf.sample
 
     strip -X -S $PKGROOT/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.kext/Contents/MacOS/afs