Add src/afsd/afsd.fuse and src/libuafs/afsd to .gitignore
[openafs.git] / src / afsd / afs.rc.alpha_dux40
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 # This script should run after DCE, but before any long running programs
12 # start which use authentication. That is because we will modify the
13 # matrix.conf file.
14 #
15 # Install this script as /sbin/init.d/afs.rc
16 # then make links like this:
17 # ln -s ../init.d/afs.rc /sbin/rc0.d/K66afs
18 # ln -s ../init.d/afs.rc /sbin/rc3.d/S67afs 
19 #
20 CONFIG=/usr/vice/etc/config
21 AFSDOPT=$CONFIG/afsd.options
22 PACKAGE=$CONFIG/package.options
23
24 LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
25 MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
26 SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
27
28 if [ -f $AFSDOPT ]; then
29     OPTIONS=`cat $AFSDOPT`
30 else
31     OPTIONS=$MEDIUM
32 fi
33
34 # Need the commands ps, awk, kill, sleep
35 PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
36
37 killproc() {            # kill the named process(es)
38         awkfield2='$2'
39         pid=`ps -ef | awk "/$1/ && ! /awk/ {print $awkfield2}"`
40         [ "$pid" != "" ] && kill -KILL $pid
41 }
42
43 case $1 in
44 'start')
45
46 #
47 # Start the AFS server processes if a bosserver exists
48 #
49
50 if [ -x /usr/afs/bin/bosserver ]; then
51         echo "Starting AFS Server processes"
52         /usr/afs/bin/bosserver
53         OPTIONS="$OPTIONS -nosettime"
54         sleep 30
55 fi
56
57 #
58 # Check that all of the client configuration files exist
59 #
60
61 for file in /usr/vice/etc/afsd /usr/vice/etc/cacheinfo \
62             /usr/vice/etc/ThisCell /usr/vice/etc/CellServDB
63 do
64         if [ ! -f ${file} ]; then
65                 echo "${file} does not exist. Not starting AFS client."
66                 exit 1
67         fi
68 done
69
70 #
71 # Check that the root directory for AFS (/afs) 
72 # and the cache directory (/usr/vice/cache) both exist
73 #
74
75 for dir in `awk -F: '{print $1, $2}' /usr/vice/etc/cacheinfo`
76 do
77         if [ ! -d ${dir} ]; then
78                 echo "${dir} does not exist. Not starting AFS client."
79                 exit 2
80         fi
81 done
82
83 echo "Starting afsd"
84 /usr/vice/etc/afsd $OPTIONS
85
86 #
87 # Run package to update the disk
88 #
89 if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
90         /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
91 case $? in
92 0)
93         (echo "Package completed successfully") > /dev/console 2>&1
94         date > /dev/console 2>&1
95         ;;
96 4)
97         (echo "Rebooting to restart system") > /dev/console 2>&1
98         sync
99         /etc/reboot
100         ;;
101 *)
102         (echo "Package update failed; continuing") > /dev/console 2>&1
103         ;;
104 esac
105
106 fi
107
108 #
109 # Start AFS inetd services
110 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
111 #
112 if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
113         /usr/sbin/inetd.afs /etc/inetd.conf.afs
114 fi
115
116 # Let AFS get started, then test for the mount.
117 i=30
118 while test $i -gt 0; do
119         if mount | fgrep AFS > /dev/null
120         then
121                 break
122         fi
123
124         sleep 1
125         i=`expr $i - 1`
126 done
127
128 if [ $i -eq 0 ]; then
129         echo "AFS failed to start. Not setting AFS SIA mechanism."
130         exit 1
131 fi
132
133 #
134 # Update SIA matrix if /usr/shlib/libafssiad.so is present. 
135 # Note that this runs *after* DCE so that we're sure to be after DCE in
136 # the matrix.
137 #
138 if [ -f /usr/shlib/libafssiad.so ]; then
139         if [ -f /etc/sia/matrix.conf ]; then
140                 echo Setting SIA matrix
141                 sed -e 's:(AFS,/usr/shlib/libafssiad.so)[^(]*::g; s:,$::; s:(BSD,libc.so):(AFS,/usr/shlib/libafssiad.so),&:; s:(OSFC2,libsecurity.so):(AFS,/usr/shlib/libafssiad.so),&:' /etc/sia/matrix.conf > /etc/sia/AFS_matrix.conf
142                 mv /etc/sia/matrix.conf /etc/sia/AFS_matrix.conf.orig
143                 ln -s AFS_matrix.conf /etc/sia/matrix.conf
144         else
145                 echo No matrix.conf file, not setting AFS SIA mechanism.
146         fi
147 else
148         echo No /usr/shlib/libafssiad.so library, not setting AFS SIA mechanism.
149 fi
150
151 echo ;;
152
153 'stop')
154
155 #
156 # Stop the AFS inetd and server processes
157 # Note that the afsd processes cannot be killed
158 # Digital Unix 4.0 will reset the matrix.conf upon reboot to bsd_matrix.conf
159
160 echo "Killing inetd.afs"
161 killproc inetd.afs
162
163 bosrunning=`ps -ef | awk '/bosserver/ && ! /awk/'`
164 if [ "${bosrunning}" != "" ]; then
165         echo "Shutting down AFS server processes"
166         /usr/afs/bin/bos shutdown localhost -localauth -wait
167         echo "Killing AFS bosserver"
168         killproc bosserver
169 fi
170
171 echo ;;
172
173 *)      echo "Invalid option supplied to $0"
174         exit 1;;
175 esac