Commit | Line | Data |
---|---|---|
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 | # | |
10 | CONFIG=/usr/vice/etc/config | |
11 | AFSDOPT=$CONFIG/afsd.options | |
12 | PACKAGE=$CONFIG/package.options | |
13 | ||
14 | # EXTRAOPTS can be used to enable/disable AFSDB support (-afsdb) | |
15 | # and Dynroot (dynamically-generated /afs) support (-dynroot). | |
16 | EXTRAOPTS="-afsdb" | |
17 | ||
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" | |
21 | ||
22 | if [ -f $AFSDOPT ]; then | |
23 | OPTIONS=`cat $AFSDOPT` | |
24 | else | |
25 | OPTIONS="$MEDIUM $EXTRAOPTS" | |
26 | fi | |
27 | ||
28 | # Need the commands ps, awk, kill, sleep | |
29 | PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin | |
30 | ||
31 | killproc() { # kill the named process(es) | |
32 | awkfield2='$2' | |
33 | pid=`ps -ef | awk "/$1/ && ! /awk/ {print $awkfield2}"` | |
34 | [ "$pid" != "" ] && kill -KILL $pid | |
35 | } | |
36 | ||
37 | case $1 in | |
38 | 'start') | |
39 | ||
40 | ## Check to see that /bin/isalist exists and is executable | |
41 | if [ ! -x /bin/isalist ] ;then | |
42 | echo "/bin/isalist not executable" | |
43 | exit 1; | |
44 | fi | |
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 | ||
49 | case `/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 ;; | |
59 | esac | |
60 | ||
61 | ||
62 | # | |
63 | # Load kernel extensions | |
64 | # | |
65 | # nfssrv has to be loaded first | |
66 | ||
67 | ||
68 | if [ -f $nfssrv ]; then | |
69 | echo "Loading NFS server kernel extensions" | |
70 | modload $nfssrv | |
71 | else | |
72 | echo "$nfssrv does not exist. Skipping AFS startup." | |
73 | exit 1 | |
74 | fi | |
75 | ||
76 | ## Load AFS kernel extensions | |
77 | ||
78 | if [ -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 | |
106 | else | |
107 | echo "$afs does not exist. Skipping AFS startup." | |
108 | exit 1 | |
109 | fi | |
110 | ||
111 | # | |
112 | # Start the AFS server processes if a bosserver exists | |
113 | # | |
114 | ||
115 | if [ -x /usr/afs/bin/bosserver ]; then | |
116 | echo "Starting AFS Server processes" | |
117 | /usr/afs/bin/bosserver & | |
118 | OPTIONS="$OPTIONS -nosettime" | |
119 | sleep 30 | |
120 | fi | |
121 | ||
122 | # | |
123 | # Check that all of the client configuration files exist | |
124 | # | |
125 | ||
126 | for file in /usr/vice/etc/afsd /usr/vice/etc/cacheinfo \ | |
127 | /usr/vice/etc/ThisCell /usr/vice/etc/CellServDB | |
128 | do | |
129 | if [ ! -f ${file} ]; then | |
130 | echo "${file} does not exist. Not starting AFS client." | |
131 | exit 1 | |
132 | fi | |
133 | done | |
134 | ||
135 | # | |
136 | # Check that the root directory for AFS (/afs) | |
137 | # and the cache directory (/usr/vice/cache) both exist | |
138 | # | |
139 | ||
140 | for dir in `awk -F: '{print $1, $2}' /usr/vice/etc/cacheinfo` | |
141 | do | |
142 | if [ ! -d ${dir} ]; then | |
143 | echo "${dir} does not exist. Not starting AFS client." | |
144 | exit 2 | |
145 | fi | |
146 | done | |
147 | ||
148 | echo "Starting afsd" | |
149 | /usr/vice/etc/afsd $OPTIONS | |
150 | ||
151 | # | |
152 | # Run package to update the disk | |
153 | # | |
154 | if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then | |
155 | /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1 | |
156 | case $? in | |
157 | 0) | |
158 | (echo "Package completed successfully") > /dev/console 2>&1 | |
159 | date > /dev/console 2>&1 | |
160 | ;; | |
161 | 4) | |
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 | ;; | |
169 | esac | |
170 | ||
171 | fi | |
172 | ||
173 | # | |
174 | # Start AFS inetd services | |
175 | # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs) | |
176 | # | |
177 | if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then | |
178 | /usr/sbin/inetd.afs /etc/inetd.conf.afs | |
179 | fi | |
180 | ||
181 | echo ;; | |
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 | ||
192 | echo "Killing inetd.afs" | |
193 | killproc inetd.afs | |
194 | ||
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" | |
200 | killproc bosserver | |
201 | fi | |
202 | ||
203 | echo ;; | |
204 | ||
205 | *) echo "Invalid option supplied to $0" | |
206 | exit 1;; | |
207 | esac |