"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/scripts/venus-setup.in" (27 Jul 2009, 6713 Bytes) of package /linux/misc/old/coda-6.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 # Coda client installation script
    4 # Made for Linux coda-client rpm distribution 
    5 # Peter J. Braam, Dec 1996
    6 # included suggestions from Elliot Lee, may 1997.
    7 #
    8 # Usage: venus-setup default-realm-name cachesize-in-kb
    9 #
   10 # the script will verify that the necessary directories and /etc/services
   11 # are present.
   12 #
   13 # BUGS: need to substitute /etc/coda with @sysconfdir@ and have configure
   14 #   splice in the right location of the venus.conf file.
   15 prefix=@prefix@
   16 exec_prefix=@exec_prefix@
   17 
   18 OS=`uname -s | cut -c1-5`
   19 
   20 if [ $OS = CYGWI ] ; then
   21     if [ $# != 3 ]; then
   22     echo "Usage: $0 default-realm-name cachesize-in-kb drive-letter"
   23     exit 1
   24     fi
   25 else
   26     if [ $# != 1 -a $# != 2 ]; then
   27     echo "Usage: $0 default-realm-name [cachesize-in-kb]"
   28     exit 1
   29     fi
   30 fi
   31 
   32 REALM=$1
   33 if [ x$2 != x ] ; then
   34     CACHESIZE=$2
   35 else
   36     CACHESIZE=100000
   37 fi
   38 if [ x$3 != x ] ; then
   39     MOUNTPOINT=`echo $3 | cut -c1`
   40     if [ $MOUNTPOINT \< A -o $MOUNTPOINT \> z -o \
   41          \( $MOUNTPOINT \> Z -a $MOUNTPOINT \< a \) ] ; then
   42     echo "Drive letter must be a letter!"
   43     exit 1;
   44     fi
   45 fi
   46 
   47 #
   48 # Allowing the user to edit venus.conf before creating all the various
   49 # directories might be nice, but breaks the existing `half-automatic'
   50 # installation
   51 #
   52 #restart=0
   53 #[ ! -f /etc/coda/venus.conf ] && restart=1
   54 
   55 [ "$REALM" ] && @sbindir@/codaconfedit venus.conf realm $REALM
   56 @sbindir@/codaconfedit venus.conf cacheblocks $CACHESIZE
   57 
   58 conf="`@sbindir@/codaconfedit venus.conf`"
   59 
   60 #if [ $restart = 1 ] ; then
   61 #    echo "We just created an initial configuration file /etc/coda/venus.conf"
   62 #    echo "You might want to look it over and modify some of the default paths"
   63 #    echo "Rerun 'venus-setup $SERVERS $CACHESIZE' if you're happy"
   64 #    exit
   65 #fi
   66 
   67 # default paths
   68 errorlog=/usr/coda/etc/console
   69 cachedir=/usr/coda/venus.cache
   70 checkpointdir=/usr/coda/spool
   71 logfile=/usr/coda/etc/venus.log
   72 marinersocket=/usr/coda/spool/mariner
   73 pid_file=/usr/coda/venus.cache/pid
   74 run_control_file=/usr/coda/venus.cache/VENUS_CTRL
   75 rvm_log=/usr/coda/LOG
   76 rvm_data=/usr/coda/DATA
   77 mountpoint=/coda
   78 
   79 # override with user defined paths
   80 if [ x${conf} != x/dev/null ] ; then
   81     . ${conf}
   82 fi
   83 
   84 #
   85 # we need to make sure we have the following directories so that venus can
   86 # create the files that live in them.
   87 #
   88 errlogdir=`dirname $errorlog`
   89 logfiledir=`dirname $logfile`
   90 marinersocketdir=`dirname $marinersocket`
   91 pid_filedir=`dirname $pid_file`
   92 run_control_file_dir=`dirname $run_control_file`
   93 rvm_logdir=`dirname $rvm_log`
   94 rvm_datadir=`dirname $rvm_data`
   95 
   96 # Darn, mkdir -p -m 700 /path/to/new/dir only sets the mode of the last
   97 # created directory correctly. The following function sets the mode of all
   98 # newly created directories.
   99 makedir () {
  100   [ "$2" = "" ] && return
  101   while [ ! -d $2 ] ; do
  102     dir=$2
  103     # find first existing parent
  104     while [ "$dir" != "" -a ! -d $dir ] ; do
  105     newdir=`basename $dir`
  106     dir=`dirname $dir`
  107     done
  108     echo "=> Creating $dir/$newdir, mode $1"
  109     if ! mkdir $dir/$newdir ; then
  110         echo "  Could not make \"$dir/$newdir\".  Aborting...."
  111         exit 1
  112     fi
  113     if [ $dir = / ] ; then
  114         dir=
  115     fi
  116     chmod $1 $dir/$newdir
  117   done
  118 }
  119 
  120 makedir 755 $checkpointdir
  121 makedir 755 $marinersocketdir
  122 makedir 700 $cachedir
  123 makedir 700 $errorlogdir
  124 makedir 700 $logfiledir
  125 makedir 700 $pid_filedir
  126 makedir 700 $run_control_file_dir
  127 makedir 700 $rvm_logdir
  128 makedir 700 $rvm_datadir
  129 
  130 contains () {
  131     grep "$2" "$1" > /dev/null 2>&1
  132 }
  133 
  134 # tell the kernel about the new module 
  135 if [ X$OS = XLinux ] ; then
  136     # make sure the module dependencies are current
  137     /sbin/depmod -a
  138     # udev managed /dev
  139     if [ -d /dev/.udevdb -o -f /dev/.udev.tdb ] ; then
  140     # udev relies on modules being autoloaded because their hardware got
  141     # detected. But since there is no hardware for the Coda kernel module
  142     # we have to make sure it is loaded automatically at boot
  143 
  144     # FC3
  145     if contains /etc/rc.sysinit /etc/rc.modules ; then
  146         if [ ! -f /etc/rc.modules ] ; then
  147         echo "#!/bin/sh" > /etc/rc.modules
  148         chmod 755 /etc/rc.modules
  149         fi
  150         if ! contains /etc/rc.modules coda ; then
  151         echo "/sbin/modprobe coda" >> /etc/rc.modules
  152         fi
  153 
  154     # debian
  155     elif ! contains /etc/modules coda ; then
  156         echo "=> Adding 'coda' to /etc/modules so that the kernel module is"
  157         echo "   loaded automatically whenever the system boots"
  158         echo coda >> /etc/modules
  159     fi
  160     # since we aren't booting this time, make sure the module is loaded
  161     echo "== Loading coda kernel module."
  162     /sbin/modprobe coda && sleep 5
  163     fi
  164     # devfs managed /dev
  165     if [ -d /etc/devfs ] ; then
  166     if ! contains /etc/devfs/devices cfs0 ; then
  167         echo "=> Adding 'cfs0' to /etc/devfs/devices so that devfs creates"
  168         echo "   an entry for /dev/cfs0 so that the Coda kernel module"
  169         echo "   can be autoloaded when the /dev/cfs0 or /dev/coda/0"
  170         echo "   device is accessed"
  171         echo "cfs0 c 67 0 root root 0200" >> /etc/devfs/devices
  172         /etc/init.d/devfsd restart
  173     fi
  174     fi
  175     # static /dev
  176     if /sbin/modinfo -V | grep modutils > /dev/null || [ -z $(/sbin/modinfo -F alias coda) ] ; then
  177     # kernel module does not encode an alias for us
  178     if [ -f /etc/modules.conf ] ; then
  179         MODULES=/etc/modules.conf
  180     else
  181         MODULES=/etc/conf.modules
  182     fi
  183     if ! contains $MODULES coda ; then
  184         echo "=> Adding aliases to $MODULES so that modprobe can"
  185         echo "   handle autoloading of the Coda kernel module when"
  186         echo "   /dev/cfs0 is accessed"
  187         echo >> $MODULES
  188         echo 'alias char-major-67 coda' >> $MODULES
  189         echo 'alias /dev/coda coda' >> $MODULES
  190     fi
  191     fi
  192 fi
  193 
  194 if [ $OS = CYGWI ]; then
  195 
  196   # setup the drive mapping
  197 
  198   rm -rf /coda
  199 
  200   ln -s /cygdrive/$MOUNTPOINT /coda
  201 
  202   @sbindir@/codaconfedit venus.conf mapprivate 0
  203   @sbindir@/codaconfedit venus.conf mountpoint $MOUNTPOINT:
  204   @sbindir@/codaconfedit venus.conf cache_prefix /??/`mount | grep ' / ' | cut -d' ' -f1 | tr \\\\\\\\ /`
  205 
  206 else
  207 
  208   makedir 755 $mountpoint
  209 
  210   # set up the /coda root if it isn't there yet
  211   if [ ! -f $mountpoint/NOT_REALLY_CODA ]; then 
  212     echo 'If you can see this file, venus is not running.' > \
  213     $mountpoint/NOT_REALLY_CODA
  214   fi
  215 
  216   # make the psdev, on udev and devfs systems the device should exist by now
  217   if [ ! -c /dev/cfs0 -a ! -c /dev/coda/0 ] ; then
  218     if [ ! -x /dev/MAKEDEV ] ; then
  219       echo 'You need a character device for the Coda kernel module'
  220       echo 'On *BSD systems you probably have to run "mknod /dev/cfs0 c 93 0"'
  221     else
  222       ( cd /dev ; ./MAKEDEV cfs )
  223     fi
  224   fi
  225 fi
  226 
  227 # next run will always initialize
  228 touch $cachedir/INIT
  229 
  230 if [ -f /usr/coda/etc/vstab ] ; then
  231     echo "To avoid confusion, remove /usr/coda/etc/vstab, we have switched to"
  232     echo "the /etc/coda/venus.conf file for configuring the client."
  233 fi
  234