Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afsd / afs.rc.solaris.2.11
CommitLineData
805e021f
CE
1#!/bin/sh
2#
3# afs.rc: rc script for AFS on Solaris 11 or OpenSolaris-based platforms
4#
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
9#
10CONFIG=/usr/vice/etc/config
11AFSDOPT=$CONFIG/afsd.options
12PACKAGE=$CONFIG/package.options
13
14# EXTRAOPTS can be used to enable/disable AFSDB support (-afsdb)
15# and Dynroot (dynamically-generated /afs) support (-dynroot).
16EXTRAOPTS="-afsdb"
17
18LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
19MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
20SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
21
22if [ -f $AFSDOPT ]; then
23 OPTIONS=`cat $AFSDOPT`
24else
25 OPTIONS="$MEDIUM $EXTRAOPTS"
26fi
27
28# Need the commands ps, awk, kill, sleep
29PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
30
31killproc() { # kill the named process(es)
32 awkfield2='$2'
33 pid=`ps -ef | awk "/$1/ && ! /awk/ {print $awkfield2}"`
34 [ "$pid" != "" ] && kill -KILL $pid
35}
36
37case $1 in
38'start')
39
40## Check to see that /bin/isalist exists and is executable
41if [ ! -x /bin/isalist ] ;then
42 echo "/bin/isalist not executable"
43 exit 1;
44fi
45
46## Determine if we are running the 64 bit OS
47## If sparcv9 then the location of the afs and nfs extensions differ
48
49case `/bin/isalist` in
50 *amd64* )
51 nfssrv=/kernel/misc/amd64/nfssrv
52 afs=/kernel/drv/amd64/afs ;;
53 *sparcv9* )
54 nfssrv=/kernel/misc/sparcv9/nfssrv
55 afs=/kernel/drv/sparcv9/afs ;;
56 * )
57 nfssrv=/kernel/misc/nfssrv
58 afs=/kernel/drv/afs ;;
59esac
60
61
62#
63# Load kernel extensions
64#
65# nfssrv has to be loaded first
66
67
68if [ -f $nfssrv ]; then
69 echo "Loading NFS server kernel extensions"
70 modload $nfssrv
71else
72 echo "$nfssrv does not exist. Skipping AFS startup."
73 exit 1
74fi
75
76## Load AFS kernel extensions
77
78if [ -f $afs ]; then
79 if [ -f /kernel/drv/afs.conf ] ; then
80 echo "Kernel afs.conf already exists"
81 else
82 echo "Creating kernel afs.conf"
83 echo 'name="afs" parent="pseudo";' > /kernel/drv/afs.conf
84 fi
85
86 # load the module
87 if grep '^afs ' /etc/name_to_major >/dev/null ; then
88 echo "Loading AFS kernel extensions"
89 modload $afs
90 # this can sometimes be necessary to get the /devices afs device to
91 # attach
92 update_drv afs
93 else
94 echo "Installing AFS driver and loading kernel extensions"
95 add_drv -m '* 0666 root root' afs
96 fi
97
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"
101 else
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
104 devfsadm
105 fi
106else
107 echo "$afs does not exist. Skipping AFS startup."
108 exit 1
109fi
110
111#
112# Start the AFS server processes if a bosserver exists
113#
114
115if [ -x /usr/afs/bin/bosserver ]; then
116 echo "Starting AFS Server processes"
117 /usr/afs/bin/bosserver &
118 OPTIONS="$OPTIONS -nosettime"
119 sleep 30
120fi
121
122#
123# Check that all of the client configuration files exist
124#
125
126for file in /usr/vice/etc/afsd /usr/vice/etc/cacheinfo \
127 /usr/vice/etc/ThisCell /usr/vice/etc/CellServDB
128do
129 if [ ! -f ${file} ]; then
130 echo "${file} does not exist. Not starting AFS client."
131 exit 1
132 fi
133done
134
135#
136# Check that the root directory for AFS (/afs)
137# and the cache directory (/usr/vice/cache) both exist
138#
139
140for dir in `awk -F: '{print $1, $2}' /usr/vice/etc/cacheinfo`
141do
142 if [ ! -d ${dir} ]; then
143 echo "${dir} does not exist. Not starting AFS client."
144 exit 2
145 fi
146done
147
148echo "Starting afsd"
149/usr/vice/etc/afsd $OPTIONS
150
151#
152# Run package to update the disk
153#
154if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
155 /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
156case $? in
1570)
158 (echo "Package completed successfully") > /dev/console 2>&1
159 date > /dev/console 2>&1
160 ;;
1614)
162 (echo "Rebooting to restart system") > /dev/console 2>&1
163 sync
164 /etc/reboot
165 ;;
166*)
167 (echo "Package update failed; continuing") > /dev/console 2>&1
168 ;;
169esac
170
171fi
172
173#
174# Start AFS inetd services
175# (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
176#
177if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
178 /usr/sbin/inetd.afs /etc/inetd.conf.afs
179fi
180
181echo ;;
182
183'stop')
184
185#
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.
190#
191
192echo "Killing inetd.afs"
193killproc inetd.afs
194
195bosrunning=`ps -ef | awk '/bosserver/ && ! /awk/'`
196if [ "${bosrunning}" != "" ]; then
197 echo "Shutting down AFS server processes"
198 /usr/afs/bin/bos shutdown localhost -localauth -wait
199 echo "Killing AFS bosserver"
200 killproc bosserver
201fi
202
203echo ;;
204
205*) echo "Invalid option supplied to $0"
206 exit 1;;
207esac