Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afsd / afs.rc.alpha
CommitLineData
805e021f
CE
1#!/bin/sh
2# Copyright 2000, International Business Machines Corporation and others.
3# All Rights Reserved.
4#
5# This software has been released under the terms of the IBM Public
6# License. For details, see the LICENSE file in the top-level source
7# directory or online at http://www.openafs.org/dl/license10.html
8
9# afs.rc: rc script for AFS on OSF/1 platforms
10# This script assumes that you have AFS built into the kernel.
11#
12# Install this script as /sbin/init.d/afs.rc
13# then make links like this:
14# ln -s ../init.d/afs.rc /sbin/rc0.d/K66afs
15# ln -s ../init.d/afs.rc /sbin/rc3.d/S90afs
16#
17CONFIG=/usr/vice/etc/config
18AFSDOPT=$CONFIG/afsd.options
19PACKAGE=$CONFIG/package.options
20
21LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
22MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
23SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
24
25if [ -f $AFSDOPT ]; then
26 OPTIONS=`cat $AFSDOPT`
27else
28 OPTIONS=$MEDIUM
29fi
30
31# Need the commands ps, awk, kill, sleep
32PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
33
34killproc() { # kill the named process(es)
35 awkfield2='$2'
36 pid=`ps -ef | awk "/$1/ && ! /awk/ {print $awkfield2}"`
37 [ "$pid" != "" ] && kill -KILL $pid
38}
39
40case $1 in
41'start')
42
43#
44# Start the AFS server processes if a bosserver exists
45#
46
47if [ -x /usr/afs/bin/bosserver ]; then
48 echo "Starting AFS Server processes"
49 /usr/afs/bin/bosserver
50 OPTIONS="$OPTIONS -nosettime"
51 sleep 30
52fi
53
54#
55# Check that all of the client configuration files exist
56#
57
58for file in /usr/vice/etc/afsd /usr/vice/etc/cacheinfo \
59 /usr/vice/etc/ThisCell /usr/vice/etc/CellServDB
60do
61 if [ ! -f ${file} ]; then
62 echo "${file} does not exist. Not starting AFS client."
63 exit 1
64 fi
65done
66
67#
68# Check that the root directory for AFS (/afs)
69# and the cache directory (/usr/vice/cache) both exist
70#
71
72for dir in `awk -F: '{print $1, $2}' /usr/vice/etc/cacheinfo`
73do
74 if [ ! -d ${dir} ]; then
75 echo "${dir} does not exist. Not starting AFS client."
76 exit 2
77 fi
78done
79
80echo "Starting afsd"
81/usr/vice/etc/afsd $OPTIONS
82
83#
84# Run package to update the disk
85#
86if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
87 /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
88case $? in
890)
90 (echo "Package completed successfully") > /dev/console 2>&1
91 date > /dev/console 2>&1
92 ;;
934)
94 (echo "Rebooting to restart system") > /dev/console 2>&1
95 sync
96 /etc/reboot
97 ;;
98*)
99 (echo "Package update failed; continuing") > /dev/console 2>&1
100 ;;
101esac
102
103fi
104
105#
106# Start AFS inetd services
107# (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
108#
109if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
110 /usr/sbin/inetd.afs /etc/inetd.conf.afs
111fi
112
113echo ;;
114
115'stop')
116
117#
118# Stop the AFS inetd and server processes
119# Note that the afsd processes cannot be killed
120#
121
122echo "Killing inetd.afs"
123killproc inetd.afs
124
125bosrunning=`ps -ef | awk '/bosserver/ && ! /awk/'`
126if [ "${bosrunning}" != "" ]; then
127 echo "Shutting down AFS server processes"
128 /usr/afs/bin/bos shutdown localhost -localauth -wait
129 echo "Killing AFS bosserver"
130 killproc bosserver
131fi
132
133echo ;;
134
135*) echo "Invalid option supplied to $0"
136 exit 1;;
137esac