3 # afs.rc: rc script for AFS on Solaris 11 or OpenSolaris-based platforms
5 # Install this script as /etc/init.d/afs.rc
6 # then make links like this:
7 # ln -s ../init.d/afs.rc /etc/rc0.d/K66afs
8 # ln -s ../init.d/afs.rc /etc/rc2.d/S70afs
10 CONFIG
=/usr
/vice
/etc
/config
11 AFSDOPT
=$CONFIG/afsd.options
12 PACKAGE
=$CONFIG/package.options
14 # EXTRAOPTS can be used to enable/disable AFSDB support (-afsdb)
15 # and Dynroot (dynamically-generated /afs) support (-dynroot).
18 LARGE
="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
19 MEDIUM
="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
20 SMALL
="-stat 300 -dcache 100 -daemons 2 -volumes 50"
22 if [ -f $AFSDOPT ]; then
23 OPTIONS
=`cat $AFSDOPT`
25 OPTIONS
="$MEDIUM $EXTRAOPTS"
28 # Need the commands ps, awk, kill, sleep
29 PATH
=${PATH}${PATH:+:}/sbin
:/bin
:/usr
/bin
31 killproc
() { # kill the named process(es)
33 pid
=`ps -ef | awk "/$1/ && ! /awk/ {print $awkfield2}"`
34 [ "$pid" != "" ] && kill -KILL $pid
40 ## Check to see that /bin/isalist exists and is executable
41 if [ ! -x /bin
/isalist
] ;then
42 echo "/bin/isalist not executable"
46 ## Determine if we are running the 64 bit OS
47 ## If sparcv9 then the location of the afs and nfs extensions differ
49 case `/bin/isalist` in
51 nfssrv
=/kernel
/misc
/amd64
/nfssrv
52 afs
=/kernel
/drv
/amd64
/afs
;;
54 nfssrv
=/kernel
/misc
/sparcv
9/nfssrv
55 afs
=/kernel
/drv
/sparcv
9/afs
;;
57 nfssrv
=/kernel
/misc
/nfssrv
58 afs
=/kernel
/drv
/afs
;;
63 # Load kernel extensions
65 # nfssrv has to be loaded first
68 if [ -f $nfssrv ]; then
69 echo "Loading NFS server kernel extensions"
72 echo "$nfssrv does not exist. Skipping AFS startup."
76 ## Load AFS kernel extensions
79 if [ -f /kernel
/drv
/afs.conf
] ; then
80 echo "Kernel afs.conf already exists"
82 echo "Creating kernel afs.conf"
83 echo 'name="afs" parent="pseudo";' > /kernel
/drv
/afs.conf
87 if grep '^afs ' /etc
/name_to_major
>/dev
/null
; then
88 echo "Loading AFS kernel extensions"
90 # this can sometimes be necessary to get the /devices afs device to
94 echo "Installing AFS driver and loading kernel extensions"
95 add_drv
-m '* 0666 root root' afs
98 # Create the /dev/afs link
99 if grep name
=afs
/etc
/devlink.tab
>/dev
/null
; then
100 echo "Entry for afs already exists in /etc/devlink.tab"
102 echo "Adding entry for afs in /etc/devlink.tab"
103 echo "type=ddi_pseudo;name=afs;addr=0;minor=afs \D" >> /etc
/devlink.tab
107 echo "$afs does not exist. Skipping AFS startup."
112 # Start the AFS server processes if a bosserver exists
115 if [ -x /usr
/afs
/bin
/bosserver
]; then
116 echo "Starting AFS Server processes"
117 /usr
/afs
/bin
/bosserver
&
118 OPTIONS
="$OPTIONS -nosettime"
123 # Check that all of the client configuration files exist
126 for file in /usr
/vice
/etc
/afsd
/usr
/vice
/etc
/cacheinfo \
127 /usr
/vice
/etc
/ThisCell
/usr
/vice
/etc
/CellServDB
129 if [ ! -f ${file} ]; then
130 echo "${file} does not exist. Not starting AFS client."
136 # Check that the root directory for AFS (/afs)
137 # and the cache directory (/usr/vice/cache) both exist
140 for dir
in `awk -F: '{print $1, $2}' /usr/vice/etc/cacheinfo`
142 if [ ! -d ${dir} ]; then
143 echo "${dir} does not exist. Not starting AFS client."
149 /usr
/vice
/etc
/afsd
$OPTIONS
152 # Run package to update the disk
154 if [ -f /usr
/afsws
/etc
/package
-a -f $PACKAGE ]; then
155 /usr
/afsws
/etc
/package
-v -o `cat $PACKAGE` > /dev
/console
2>&1
158 (echo "Package completed successfully") > /dev
/console
2>&1
159 date > /dev
/console
2>&1
162 (echo "Rebooting to restart system") > /dev
/console
2>&1
167 (echo "Package update failed; continuing") > /dev
/console
2>&1
174 # Start AFS inetd services
175 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
177 if [ -f /usr
/sbin
/inetd.afs
-a -f /etc
/inetd.conf.afs
]; then
178 /usr
/sbin
/inetd.afs
/etc
/inetd.conf.afs
186 # Stop the AFS inetd and server processes
187 # We do not kill the afsd process here. It should be possible to do now, but we
188 # don't do it yet. Note that you need to parse 'modinfo | grep afs' output and
189 # give the id to modunload, in order to unload the kernel module.
192 echo "Killing inetd.afs"
195 bosrunning
=`ps -ef | awk '/bosserver/ && ! /awk/'`
196 if [ "${bosrunning}" != "" ]; then
197 echo "Shutting down AFS server processes"
198 /usr
/afs
/bin
/bos shutdown localhost
-localauth -wait
199 echo "Killing AFS bosserver"
205 *) echo "Invalid option supplied to $0"