]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
* Improve the openafs-client init script.
authorRuss Allbery <rra@debian.org>
Thu, 11 Aug 2005 00:29:20 +0000 (00:29 +0000)
committerRuss Allbery <rra@debian.org>
Thu, 11 Aug 2005 00:29:20 +0000 (00:29 +0000)
    - Choose the client options based on the cache size by default.
    - Move the code to build the options string to the init script from
      afs.conf so that afs.conf is pure configuration.
    - Improve the readability of the output on start.
    - Significantly improve the comments in afs.conf.
    - Remove the code to set -nosettime as it's now the default.
  * Move the openafs-client init script and afs.conf file we use into the
    debian directory rather than patching the upstream version.  We've
    diverged so much that there's no point in continuing to merge changes.

debian/afs.conf [new file with mode: 0644]
debian/changelog
debian/openafs-client.init [new file with mode: 0755]
debian/rules
src/afsd/afs.conf.linux
src/afsd/afs.rc.linux

diff --git a/debian/afs.conf b/debian/afs.conf
new file mode 100644 (file)
index 0000000..9a49b9d
--- /dev/null
@@ -0,0 +1,96 @@
+# -*- sh -*-
+# 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.
+
+# The following options are maintained by debconf.  To change them, run
+# dpkg-reconfigure openafs-client.
+#
+#   AFS_CLIENT          Whether to start the AFS client at boot
+#   AFS_AFSDB           Whether to use AFSDB DNS records to find VLDB servers
+#   AFS_CRYPT           Whether to enable fcrypt encryption
+#   AFS_DYNROOT         Whether to use a dynamic /afs directory
+#   AFS_FAKESTAT        Whether to fake stat data for mount points
+
+test -f /etc/openafs/afs.conf.client && . /etc/openafs/afs.conf.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).
+#
+# The default behavior is to pick one of the following option sets based on
+# the size of the AFS cache, as follows:
+#
+#           cache < 128MB       $SMALL
+#   128MB < cache < 512MB       $MEDIUM
+#   512MB < cache < 1GB         $LARGE
+#     1GB < cache < 2GB         $XLARGE
+#     2GB < cache               $XXLARGE
+#
+# You can override that default behavior by setting OPTIONS below.
+XXLARGE="-stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
+XLARGE="-stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
+LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
+MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
+SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
+
+# The default behavior is to pick one of the above settings as described
+# above.  You can override this by setting OPTIONS explicitly to either one of
+# the above variables or to any set of flags that you prefer.
+OPTIONS=AUTOMATIC
+
+# 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
index 3fbcbee0c99ba07e5a3f3513753c69027002efb0..81ccfdf933e73811e2042dd29e9d5588ef0fc7da 100644 (file)
@@ -2,6 +2,16 @@ openafs (1.3.87-1) unstable; urgency=low
 
   * New upstream version.
   * Add support for ppc64, thanks Andreas Jochens.  (Closes: #322020)
+  * Improve the openafs-client init script.
+    - Choose the client options based on the cache size by default.
+    - Move the code to build the options string to the init script from
+      afs.conf so that afs.conf is pure configuration.
+    - Improve the readability of the output on start.
+    - Significantly improve the comments in afs.conf.
+    - Remove the code to set -nosettime as it's now the default.
+  * Move the openafs-client init script and afs.conf file we use into the
+    debian directory rather than patching the upstream version.  We've
+    diverged so much that there's no point in continuing to merge changes.
   * Diagnose unsupported architectures earlier and with a clearer error.
   * Suppress error messages from a missing kernel version header since
     they occur normally when doing the regular package build and are just
diff --git a/debian/openafs-client.init b/debian/openafs-client.init
new file mode 100755 (executable)
index 0000000..c495ccb
--- /dev/null
@@ -0,0 +1,198 @@
+#! /bin/sh
+# Modified by Sam Hartman <hartmans@mit.edu> for Debian
+# 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
+
+# This init script bears little resemblence to the regular upstream init
+# script at this point and is therefore maintained as a Debian-specific file.
+# The upstream init script assumes Red Hat paths and uses insmod to load the
+# module directly rather than using modprobe.
+
+CACHEINFO=${CACHEINFO:-/etc/openafs/cacheinfo}
+MODULEDIR=${MODULEDIR:-/lib/modules/`uname -r`/fs}
+
+exec 3>/dev/null
+exec </dev/null
+
+# Gather up options and post startup script name, if present
+if [ -f /etc/openafs/afs.conf ]; then
+    . /etc/openafs/afs.conf
+fi
+
+# Return 1 if the argument is "true".
+is_on() {
+    if [ x"$1" = x"true" ] ; then
+        return 0
+    else
+        return 1
+    fi
+}
+
+# If choose_client can't correctly determine which client to use, set
+# LIBAFS manually.
+choose_client() {
+    # Use the second field of the uname -v output instead of just doing a
+    # match on the whole thing to protect against matching a timezone named
+    # SMP -- I don't know of one, but let's be paranoid.
+    set X `uname -v`; shift
+    case $2 in
+    SMP) MP=.mp ;;      # MP system
+    *)   MP=    ;;      # SP system
+    esac
+
+    # The Debian OpenAFS packages do not add the .mp by default as of 1.3, but
+    # modules obtained from other sources may.  If a module with the .mp
+    # exists and this is an SMP system, use it; otherwise, use the default
+    # value.  Unset $MP if not using it so that we can use it later in the
+    # call to modprobe.
+    if [ -n "$MP" -a -f "$MODULEDIR/openafs${MP}.o" ] ; then
+        LIBAFS=openafs${MP}.o
+    elif [ -n "$MP" -a -f "$MODULEDIR/openafs${MP}.ko" ] ; then
+        LIBAFS=openafs${MP}.ko
+    elif [ -f "$MODULEDIR/openafs.ko" ] ; then
+        MP=
+        LIBAFS=openafs.ko
+    else
+        MP=
+        LIBAFS=openafs.o
+    fi
+}
+
+# Load the AFS client module if it's not already loaded.  Set $MODULEDIR and
+# $LIBAFS to override the default location and module name.
+load_client() {
+    if [ -z "$LIBAFS" ] ; then
+        choose_client
+    fi
+    if [ ! -f "$MODULEDIR/$LIBAFS" ] ; then
+        echo ""
+        cat <<EOF >&2
+AFS module $MODULEDIR/$LIBAFS does not exist.
+Not starting AFS.  Please consider building kernel modules using
+instructions in /usr/share/doc/openafs-client/README.modules
+EOF
+        exit 1
+    fi
+    LOADED=`/sbin/lsmod | fgrep openafs`
+    if [ -z "$LOADED" ] ; then
+        modprobe openafs${MP}
+        status=$?
+        if [ $status = 0 ] ; then
+            echo -n " openafs"
+        fi
+        return $status
+    fi
+    return 0
+}
+
+# Determine which afsd options to use.  /etc/openafs/afs.conf contains the
+# settings that are checked here.
+choose_afsd_options() {
+    if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
+        CACHESIZE=`awk -F: '{print $3}' < /etc/openafs/cacheinfo`
+        if [ $CACHESIZE -lt 131072 ] ; then
+            OPTIONS=$SMALL
+        elif [ $CACHESIZE -lt 524288 ] ; then
+            OPTIONS=$MEDIUM
+        elif [ $CACHESIZE -lt 1048576 ] ; then
+            OPTIONS=$LARGE
+        elif [ $CACHESIZE -lt 2097152 ] ; then
+            OPTIONS=$XLARGE
+        else
+            OPTIONS=$XXLARGE
+        fi
+    fi
+    AFSD_OPTIONS="$OPTIONS $VERBOSE"
+
+    # These variables are from /etc/openafs/afs.conf.client and are managed
+    # automatically by debconf.
+    if is_on $AFS_AFSDB ; then
+        AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"
+    fi
+    if is_on $AFS_DYNROOT ; then
+        AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"
+    fi
+    if is_on $AFS_FAKESTAT ; then
+        AFSD_OPTIONS="$AFSD_OPTIONS -fakestat"
+    fi
+}
+
+# Start afsd.  Be careful not to start it if another one is already running,
+# as that has a bad tendency to hang the system.
+start_client() {
+    if pidof /usr/sbin/afsd >/dev/null ; then
+        echo "."
+    else
+        choose_afsd_options
+        echo " afsd."
+        start-stop-daemon --start --quiet --exec /usr/sbin/afsd \
+            -- $AFSD_OPTIONS
+    fi
+
+    # From /etc/openafs/afs.conf.client, whether to enable fcrypt encryption.
+    if is_on $AFS_CRYPT ; then
+        fs setcrypt on
+    fi
+}
+
+
+case "$1" in 
+start)
+    if is_on $AFS_CLIENT && test -x /usr/sbin/afsd ; then
+        echo -n "Starting AFS services:"
+        if load_client ; then
+            start_client
+            $AFS_POST_INIT
+        else
+            echo ""
+            echo "Failed to load AFS kernel module, not starting AFS" >&2
+            exit 1
+        fi
+    fi
+    ;;
+
+force-start)
+    if test -x /usr/sbin/afsd ; then
+        echo -n "Starting AFS services:"
+        if load_client ; then
+            start_client
+            $AFS_POST_INIT
+        else
+            echo ""
+            echo "Failed to load AFS kernel module, not starting AFS" >&2
+            exit 1
+        fi
+    fi
+    ;;
+
+stop|force-stop)
+    echo -n "Stopping AFS services:"
+    if mount | grep -q '^AFS' ; then
+        umount /afs
+        echo -n " afsd"
+    fi
+    pidof /usr/sbin/afsd >/dev/null && afsd -shutdown
+
+    LIBAFS=`/sbin/lsmod | awk 'BEGIN { FS = " " } /openafs/ { print $1 }'`
+    if [ -n "$LIBAFS" ] ; then
+        /sbin/rmmod $LIBAFS
+        echo -n " openafs"
+    fi
+    echo "."
+    ;;
+
+restart|force-reload)
+    "$0" stop
+    "$0" start
+    ;;
+
+*)
+    echo Usage: \
+        'openafs-client {start|force-start|stop|restart|force-reload}' >&2
+    exit 1
+
+esac
index 2875a06ea2a910b67b511c6505b905317e2eb184..cffb2665b8b7c877e83be2db68ab0809cd771646 100755 (executable)
@@ -89,7 +89,7 @@ clean:
        rm -f build-stamp configure-stamp configure-modules-stamp
        rm -f build-modules-stamp
        -$(MAKE) -ki distclean
-       -rm -rf dest $(SYS_NAME) @sys debian/openafs-client.init src/pic
+       -rm -rf dest $(SYS_NAME) @sys src/pic
        dh_clean
 
 install: DH_OPTIONS=
@@ -114,9 +114,7 @@ install: build
            debian/libpam-openafs-kaserver/lib/security/pam_afs.so
        install -m 644 -c debian/CellServDB \
            debian/openafs-client/usr/share/openafs
-       install -m 755 -c dest/root.client/usr/vice/etc/afs.rc \
-           debian/openafs-client.init
-       install -m 644 -c dest/root.client/usr/vice/etc/afs.conf \
+       install -m 644 -c debian/afs.conf \
            debian/openafs-client/etc/openafs/afs.conf
 
        install -d debian/openafs-dbserver/usr/share/man/man8
index 413985fb068eb5d949d0624f52acc66d7047f956..4494024d253a74b67f410b08ec5cd65dedea2bf0 100644 (file)
@@ -1,4 +1,4 @@
-
+#! /bin/sh
 # Copyright 2000, International Business Machines Corporation and others.
 # All Rights Reserved.
 # 
@@ -6,29 +6,66 @@
 # License.  For details, see the LICENSE file in the top-level source
 # directory or online at http://www.openafs.org/dl/license10.html
 
+############################################################################
+# On most linuces copy this file to
+#        /etc/sysconfig/afs
+# so afs.rc can use it as config file.
+############################################################################
+
 # Configuration information for AFS client
 
 # AFS_CLIENT and AFS_SERVER determine if we should start the client and or
-# the bosserver. Possible values are true and false.
-# These are loaded from files written by debconf
-# AFS_NOSETTIME is currently defaulted to auto because we believe  this is a reasonable default
-AFS_NOSETTIME=auto
-test -f /etc/openafs/afs.conf.client && . /etc/openafs/afs.conf.client
-
+# the bosserver. Possible values are on and off.
+AFS_CLIENT=on
 AFS_SERVER=off
 
 # ENABLE_AFSDB and ENABLE_DYNROOT determine whether AFSDB support and
 # Dynroot support (dynamically generated /afs), respectively, should be
 # enabled in the AFS client.
 ENABLE_AFSDB=on
-ENABLE_DYNROOT=off
+ENABLE_DYNROOT=on
 
 # AFS client configuration options:
-XXLARGE="-stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
-XLARGE="-stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
-LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
-MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
-SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
+# ---------------------------------------------------------------------------
+# possible AFS client afsd configuration options (from 1.3.74) are
+#      -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.
+#      -verbose     Be chatty.
+#      -debug     Print out additional debugging info.
+#      -kerndev    [OBSOLETE] The kernel device for AFS.
+#      -dontfork   [OBSOLETE] Don't fork off as a new process.
+#      -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 [n]   2^n is the chunksize to be used.  0 is default.
+#      -dcache    The number of data cache entries.
+#      -biods     Number of bkg I/O daemons (AIX3.1 only)
+#      -prealloc  Number of preallocated "small" memory blocks
+#      -pininodes Number of inodes which can be spared from inode[] for
+#                 pointing at Vfiles.  If this is set too high, you may have
+#                 system problems, which can only be ameliorated by changing
+#                 NINODE (or equivalent) and rebuilding the kernel.
+#                 This option is now disabled.
+#      -logfile   Place where to put the logfile (default in <cache>/etc/AFSLog.
+#      -waitclose make close calls always synchronous (slows em down, tho)
+#      -files_per_subdir [n]   number of files per cache subdir. (def=2048)
+#      -shutdown  Shutdown afs daemons
+# ---------------------------------------------------------------------------
+XXLARGE="-fakestat -stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
+XLARGE="-fakestat -stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
+LARGE="-fakestat -stat 2800 -dcache 2400 -daemons 5 -volumes 128"
+MEDIUM="-fakestat -stat 2000 -dcache 800 -daemons 3 -volumes 70"
+SMALL="-fakestat -stat 300 -dcache 100 -daemons 2 -volumes 50"
 
 # cachesize and according options are set by /afs/rc.d/init.d/afs
 #   * if you set CACHESIZE to "AUTOMATIC", it will automatically be chosen
@@ -37,46 +74,20 @@ SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
 #     of options based on the cache size
 # otherwise the values specified here will be used. So be careful!
 # Note: if you leave these as-is, no changes are made.
-CACHESIZE=
-OPTIONS=$MEDIUM
+CACHESIZE=AUTOMATIC
+#CACHESIZE=50000
+OPTIONS=AUTOMATIC
+#OPTIONS=$SMALL
 
-# if we're looking for ntp, what files do we look for?
-TIME_SBIN_PROGS="ntptime ntpd   chronyd"
-
-# Should we support afsdb?
-if [ "x$AFS_AFSDB" = "xtrue" ] ; then
-    AFSDB="-afsdb"
-    else AFSDB=""
-    fi
-if [ "x$AFS_DYNROOT" = "xtrue" ] ; then
-    DYNROOT="-dynroot"
-    else DYNROOT=""
-    fi
-if [ "x$AFS_FAKESTAT" = "xtrue" ] ; then
-    FAKESTAT="-fakestat"
-    else FAKESTAT=""
-    fi
-if [ "x$AFS_NOSETTIME" = "xtrue" ] ; then
-    NOSETTIME="-nosettime"
-  elif [ "x$AFS_NOSETTIME" = "xauto" ] ; then
-    for f in $TIME_SBIN_PROGS; do
-       test -e "/usr/sbin/$f" && {
-           NOSETTIME="-nosettime"
-           break
-       }
-    done
-  else
-    NOSETTIME=""
-  fi
+# you should never need to change these settings
+AFSDIR=/afs
+CACHEDIR=/usr/vice/cache
+CACHEINFO=/usr/vice/etc/cacheinfo
 
 # Set to "-verbose" for a lot of debugging information from afsd. Only
 # useful for debugging as it prints _a lot_ of information.
 VERBOSE=
 
-# OPTIONS are the options passed to afsd.
-OPTIONS="$OPTIONS $VERBOSE $DYNROOT $FAKESTAT $AFSDB $NOSETTIME"
-
-
 # Sample server preferences function. Set server preferences using this.
 # afs_serverprefs() {
 #    /usr/afsws/etc/fs setserverprefs <host> <rank>
index 8f8f7759cb42aa86f940d96114e93ec20cee99f0..5b2405df8b2d1cbd238f80ae6b0985fb7095274f 100644 (file)
@@ -1,5 +1,4 @@
 #! /bin/sh
-# Modified by Sam Hartman <hartmans@mit.edu> for Debian
 # Copyright 2000, International Business Machines Corporation and others.
 # All Rights Reserved.
 # 
 # AFS  Start and stop AFS components
 # 
 # 
-# chkconfig: 345 60 20
+# chkconfig: 35 60 20
 # description:  AFS is a distributed file system which provides location
 #              transparency, caching and secure authentication.
 #              Additional configuration can be done in the /etc/sysconfig/afs
 #              file. Read the documentation in that file for more information.
 #
+# The following section is used at least by SuSE insserv(8)
+### BEGIN INIT INFO
+# Provides: afs
+# Required-Start: $network
+# Required-Stop: $network
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Description:  AFS is a distributed file system which provides location
+#              transparency, caching and secure authentication.
+#              Additional configuration can be done in the /etc/sysconfig/afs
+#              file. Read the documentation in that file for more information.
+### END INIT INFO
+#
 # Note that AFS does not use a pid file in /var/run. It is turned off by
 # unmounting /afs.
 
-exec 3>/dev/null
-exec </dev/null
 
+# check for special bootup functions
+if [ -f /etc/rc.d/init.d/functions ] ; then
+       . /etc/rc.d/init.d/functions
+       afs_rh=1
+else
+       # special (RedHat) functions not available...
+       # so I provide neccessary replacements (e.g. for SuSE)
+
+       function echo_failure () { echo -n " - failed." ; }
+
+       function echo_success () { echo -n " - successful." ; }
+
+       # these are hopefully all functions I use...
+fi
+
+runcmd() {
+   echo -n "$1 "
+   shift
+   if [ "$BOOTUP" = "color" ]; then
+      $* && echo_success || echo_failure
+   else
+      $*
+   fi
+   echo
+}
+
+SYSCNF=/etc/sysconfig/afs
+KERNEL_VERSION=`uname -r`
 
 # Gather up options and post startup script name, if present
-if [ -f /etc/openafs/afs.conf ]; then
-       . /etc/openafs/afs.conf
+if [ -f $SYSCNF ] ; then
+       . $SYSCNF
 fi
 
-# is_on returns 1 if value of arg is "true"
+CACHEINFO=${CACHEINFO:-/usr/vice/etc/cacheinfo}
+CACHE=${CACHEDIR:-/usr/vice/cache}
+AFS=${AFSDIR:-/afs}
+
+# is_on returns 1 if value of arg is "on"
 is_on() {
-       if  test "$1" = "true" ; then return 0
+       if  test "$1" = "on" ; then return 0
        else return 1
-       fi
+        fi
+}
+
+on_network() {
+    ADDRS=`LANG=C ifconfig -a | grep 'inet addr' | grep -v 127.0.0.1 | wc -l`
+    if [ "$ADDRS" = "" ]; then
+       echo afs: No interfaces with IP address 1>&2
+       return 1
+    elif [ $ADDRS = 0 ]; then
+       echo afs: No interfaces with IP address 1>&2
+       return 1
+    fi
+    return 0
 }
 
 # If choose_client can't correctly determine which client to use, set
@@ -51,24 +105,14 @@ choose_client() {
        esac
 
        # For now, just use uname -r to get the module version. 
-       VERSION=`uname -r`
-
-        # The Debian OpenAFS packages do not add the .mp by default as of 1.3,
-        # but modules obtained from other sources may.  If a module with the
-        # .mp exists and this is an SMP system, use it; otherwise, use the
-        # default value.  Unset $MP if not using it so that we can use it
-        # later in the call to modprobe.
-        if [ -n "$MP" -a -f "$MODLOADDIR/openafs${MP}.o" ] ; then
-                LIBAFS=openafs${MP}.o
-        elif [ -n "$MP" -a -f "$MODLOADDIR/openafs${MP}.ko" ] ; then
-                LIBAFS=openafs${MP}.ko
-        elif [ -f "$MODLOADDIR/openafs.ko" ] ; then
-                MP=
-                LIBAFS=openafs.ko
-        else
-                MP=
-                LIBAFS=openafs.o
-        fi
+       case $KERNEL_VERSION in
+         [1-2].[0-5].*)
+               LIBAFS=libafs-$KERNEL_VERSION$MP.o
+               ;;
+         *)
+               LIBAFS=libafs-$KERNEL_VERSION$MP.ko
+               ;;
+       esac
 }
 
 #
@@ -79,8 +123,14 @@ choose_client() {
 # unregister_filesystem_Rsmp_b240cad8 is a typcial SMP version string from
 # a kernel built from ftp.kernel.org
 #
-
-KSYMS_FILE=/proc/ksyms
+case $KERNEL_VERSION in
+  [1-2].[0-5].*)
+       KSYMS_FILE=/proc/ksyms
+       ;;
+  *)
+       KSYMS_FILE=/proc/kallsyms
+       ;;
+esac
 SEARCH_STR="unregister_filesystem"
 DEFAULT_SMP_PREFIX="smp_" # Redhat kernels need "smp" instead
 PREFIX="" # none needed for UP with <= 1Gig memory
@@ -91,8 +141,16 @@ set_prefix()
        h8="$h$h$h$h$h$h$h$h"
        prefix_set=0
 
-       set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift
-       str=$2
+       set X `egrep "\<$SEARCH_STR" $KSYMS_FILE 2> /dev/null`; shift
+       
+       case $KERNEL_VERSION in
+         [1-2].[0-5].*)
+               str=$2
+               ;;
+         *)
+               str=$3
+               ;;
+       esac
        case $str in
        ${SEARCH_STR}_R$h8)
                # No prefix required
@@ -125,8 +183,7 @@ set_prefix()
        esac
 }
 
-
-MODLOADDIR=/lib/modules/`uname -r`/fs
+MODLOADDIR=/usr/vice/etc/modload
 # load_client loads the AFS client module if it's not already loaded. 
 load_client() {
        # If LIBAFS is set, use it.
@@ -136,38 +193,83 @@ load_client() {
        fi
     
        if [ ! -f "$MODLOADDIR/$LIBAFS" ] ; then
-                cat <<EOF
-AFS module $MODLOADDIR/$LIBAFS does not exist.
-Not starting AFS.  Please consider building kernel modules using
-instructions in /usr/share/doc/openafs-client/README.modules
-EOF
-               exit 0
+               echo AFS module $MODLOADDIR/$LIBAFS does not exist. Not starting AFS.
+               exit 1
        fi
 
-       # use the prefix command if required
-#      set_prefix
-       LOADED=`/sbin/lsmod | fgrep openafs`
-       if [ -z "$LOADED" ] ; then
-                modprobe openafs${MP}
+       if [ -f $KSYMS_FILE ]; then
+               # use the prefix command if required
+               case $KERNEL_VERSION in
+                 [1-2].[0-5].*)
+                       set_prefix
+                       /sbin/insmod ${PREFIX:+-P $PREFIX} -f -m $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+                       ;;
+                 *)
+                       /sbin/insmod $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+                       ;;
+               esac
+       else
+               /sbin/insmod $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
        fi
 }
 
-# start_client() -- run afsd
-start_client() {
-               if pidof /usr/sbin/afsd >/dev/null ; then : 
-                   else
-                   start-stop-daemon --start --quiet --exec /usr/sbin/afsd \
-                       -- ${OPTIONS}
-                   echo -n " afsd"
-                   fi
-               if [ x$AFS_CRYPT = xtrue ] ; then
-                   fs setcrypt on
-                   fi
+generate_cacheinfo() {
+    if [ "$CACHESIZE" = "AUTOMATIC" ]; then
+       LINE=`df -k $CACHE | tail -1`
+       PART=`echo $LINE | awk '{ if ( ($NF != "/usr")  && ($NF != "/") ) print $NF; else print "NONE";}'`
+       if [ "$PART" = "NONE" ]; then
+           echo "$CACHE or /usr/vice is not a separate partition"
+           echo "you have to change the cachesize in $SYSCNF by hand"
+           echo "AFS will be started with a VERY small cache of 8Mb."
+           CACHESIZE=8000
+       else
+           # Check to see if df has pretty-printed for long dev (i.e. LVM)
+            FCHAR=`echo $LINE | cut -c 1`
+            if [ "$FCHAR" = "/" ]; then
+                PARTSIZE=`echo $LINE | awk '{print $2}'`
+            else
+                PARTSIZE=`echo $LINE | awk '{print $1}'`
+           fi
+           CACHESIZE=`echo $PARTSIZE | awk '{printf "%d",int(($1*.8)/1000)*1000}'`
+       fi
+    fi
+    if [ "x$CACHESIZE" != "x" ]; then
+       echo $AFS:$CACHE:$CACHESIZE >$CACHEINFO
+       chmod 0644 $CACHEINFO
+    else
+       CACHESIZE=`awk -F: '{print $3}' < $CACHEINFO`
+    fi
 }
 
+choose_afsdoptions() {
+       if [ -z "$OPTIONS" -o "$OPTIONS" = "AUTOMATIC" ]; then
+               if [ $CACHESIZE -lt 131072 ]; then
+                       OPTIONS=$SMALL
+               elif [ $CACHESIZE -lt 524288 ]; then
+                       OPTIONS=$MEDIUM
+               elif [ $CACHESIZE -lt 1048576 ]; then
+                       OPTIONS=$LARGE
+               elif [ $CACHESIZE -lt 2097152 ]; then
+                       OPTIONS=$XLARGE
+               else
+                       OPTIONS=$XXLARGE
+               fi
+       fi
+       AFSD_OPTIONS="$OPTIONS $VERBOSE"
+       if is_on $ENABLE_AFSDB; then
+               AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"
+       fi
+       if is_on $ENABLE_DYNROOT; then
+               AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"
+       fi
+}
 
 case "$1" in 
   start)
+    if [ ! "$afs_rh" -o ! -f /var/lock/subsys/afs ]; then
+        if [ `echo "$OPTIONS" | grep -c dynroot` = 0 ]; then
+            on_network || exit 1
+        fi
        # Load kernel extensions
        if  load_client  ; then :
        else
@@ -175,59 +277,64 @@ case "$1" in
                exit 1
        fi
 
-       # Start AFS client
-       if  is_on $AFS_CLIENT && test -x /usr/sbin/afsd  ; then
-           echo -n "Starting AFS services: "
-       start_client
-               echo "."
-               $AFS_POST_INIT
-       fi
-
-       ;;
-
-force-start)
-       # Load kernel extensions
-       if  load_client  ; then :
-       else
-               echo Failed to load AFS client, not starting AFS services.
-               exit 1
+       echo "Starting AFS services..... "
+       # Start bosserver, it if exists
+       if  is_on $AFS_SERVER && test -x /usr/afs/bin/bosserver  ; then
+               /usr/afs/bin/bosserver 
+               test "$afs_rh" && touch /var/lock/subsys/afs
        fi
 
        # Start AFS client
-       if test -x /usr/sbin/afsd  ; then
-           echo -n "Starting AFS services: "
-       start_client
-               echo "."
+       if  is_on $AFS_CLIENT && test -x /usr/vice/etc/afsd  ; then
+               generate_cacheinfo
+               choose_afsdoptions
+               /usr/vice/etc/afsd ${AFSD_OPTIONS}
+               test "$afs_rh" && touch /var/lock/subsys/afs
                $AFS_POST_INIT
        fi
-       ;;
-  stop|force-stop)
+    fi
+       ;;
+
+  stop)
+    if [ ! "$afs_rh" -o -f /var/lock/subsys/afs ]; then
        # Stop AFS
-       echo -n "Stopping AFS services: "
+       echo "Stopping AFS services..... "
 
-       if  mount |grep -q \^AFS  ; then
+       if  is_on $AFS_CLIENT  ; then
+               if [ -x /usr/vice/etc/killafs ] ; then
+                       runcmd "Sending all processes using /afs the TERM signal ..." /usr/vice/etc/killafs TERM
+                       runcmd "Sending all processes using /afs the KILL signal ..." /usr/vice/etc/killafs KILL
+               fi
                umount /afs
-               echo -n " afsd"
        fi
-       pidof /usr/sbin/afsd >/dev/null &&afsd -shutdown
 
-       LIBAFS=`/sbin/lsmod | fgrep openafs`
+       if  is_on $AFS_SERVER && test -x /usr/bin/bos ; then
+               echo "Stopping AFS bosserver"
+               /usr/bin/bos shutdown localhost -localauth -wait
+               killall -HUP bosserver
+       fi
+
+       LIBAFS=`/sbin/lsmod | fgrep libafs`
        if [ -n "$LIBAFS" ] ; then
                LIBAFS=`echo $LIBAFS | awk 'BEGIN { FS = " " } { print $1 }'`
                /sbin/rmmod $LIBAFS
-               echo -n " libafs"
        fi
-       echo "."
 
+       rm -f /var/lock/subsys/afs
+    fi
        ;;
 
-  restart|force-reload)
-       "$0" stop
-       "$0" start
+  restart)
+       # Restart AFS
+       $0 stop
+       $0 start
        ;;
 
   *)
-       echo Usage: 'openafs-client <start|stop>'
+       echo Usage: 'afs <start|stop|restart>'
 
 esac
 
+exit 0
+
+action fool the Red Hat initscripts