summaryrefslogtreecommitdiff
path: root/AFSConfig
blob: 0c68cbd33209ade840a6fc59e96a99c58d6dad17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/bin/sh
#
# $Id: AFSConfig,v 1.2 99/05/09 14:49:54 abe Exp $
#
# AFSConfig: configure for AFS

AFSD=/usr/vice/etc/afsd
AH=AFSHeaders
AV=AFSVersion
STD=/usr/afsws/include

# Establish trap and stty handling.

ISIG=":"
trap 'rm -f $AH $AV; $ISIG; exit 1'  1 2 3 15
stty -a 2>&1 | grep isig > /dev/null
if test $? -eq 0
then
  stty -a 2>&1 | egrep -e -isig > /dev/null
  if test $? -eq 0
  then
    ISIG="stty -isig"
    stty isig
  fi
fi

# Decide how to use echo.

ECHO=`echo -n ""`
if test "X$ECHO" = "X-n "
then
  EC="\c"
  EO=""
else
  EC=""
  EO="-n"
fi

# Decide (perhaps for a second time) that AFS is installed.

CELL=""
if test -r /usr/vice/etc/ThisCell
then
  cell=`awk '{print $1}' /usr/vice/etc/ThisCell`
  if test -d /afs/$cell
  then
    CELL=$cell
  else
    CELL=`echo $cell | sed 's/\([^.]*\)\..*/\1/'`
    if test "X$CELL" != "X"
    then
      if test ! -d /afs/$CELL
      then
        CELL=""
      fi
    fi
  fi
fi
if test "X$CELL" = "X"
then
  echo ""
  echo "This system does not appear to have AFS installed."
  exit 1
fi

# See if AFS configuration is wanted.

cat << .CAT_MARK

AFS appears to be installed on this system; cell name "$CELL".

Lsof needs to be configured for AFS by identifying: 1) the directory
that includes the AFS header files needed to compile AFS support into
lsof; and 2) the version of AFS that is installed.
.CAT_MARK

END=0
while test $END = 0
do
  echo ""
  echo $EO "Do you want to configure lsof for AFS (y|n) [y]? $EC"
  read ANS EXCESS
  if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
  then
    exit 1
  fi
  if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
  then
    END=1
  else
    echo ""
    echo "Please answer y or n."
  fi
done

# See if $AH exists and points to a likely place.

AHOK=""
echo ""
echo "====================================================================="
echo ""
if test -r $AH
then
  AHP=`cat $AH`
  if test -r $AHP
  then
    if test -r $AHP/afs/afs.h
    then
      cat << .CAT_MARK
The location of the AFS header files required by lsof has been
previously identified as "$AHP".

Since <afs/afs.h> can be found there, that's probably correct.
.CAT_MARK

      END=0
      while test $END = 0
      do
	echo ""
	echo $EO "Do you want to use $AHP again (y|n) [y]? $EC"
	read ANS EXCESS
	if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
	then
	  AHOK="ok"
	  END=1
	else
	  if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
	  then
	    rm -f $AH
	    AHP=""
	    END=1
	  else
	    echo ""
	    echo "Please answer y or n."
	  fi
	fi
      done
    else
      echo "\"$AHP\" has been previously specified as the location of the"
      echo "AFS header files, but it lacks an afs/afs.h header file."
      rm -f $AH
      AHP=""
    fi
  else
    echo "The file ./$AH exists, but has no AFS header file path in it."
    rm -f $AH
    AHP=""
  fi
else
  echo "No previous header location has been specified."
  rm -f $AH
  AHP=""
fi

# See if the header files are in the "standard" place.

if test "X$AHOK" != "Xok"
then
  if test -r $STD
  then
    echo ""
    echo "====================================================================="
    echo ""
    echo "The AFS header files appear to be in the \"standard\" location --"
    echo "i.e.: \"$STD\"."
    END=0
    while test $END = 0
    do
      echo ""
      echo $EO "Do you want to let lsof use them (y|n) [y]? $EC"
      read ANS EXCESS
      if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
      then
	echo $STD > $AH
	AHOK="ok"
	END=1
      else
	if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
	then
	  END=1
	else
	  echo ""
	  echo "Please answer y or n."
	fi
      fi
    done
  fi
fi

# Ask for the AFS header file location.

if test "X$AHOK" != "Xok"
then
  echo ""
  echo "====================================================================="
  echo ""
  echo "Please specify the full path where lsof can find the AFS header"
  echo "files.  A possible location is: \"/afs/$CELL/<sysname>/include\"."
  cat << .CAT_MARK
The <sysname> component of the path is the AFS system name that
was used to configure and build AFS on this system.  It is usually
constructed from a manufacturer or Unix operating system designation,
followed by a version number -- e.g., hp800_ux90, sun4m_54, vax_ul43,
etc.  You may have to consult your AFS documentation to determine
what <sysname> applies to your configuration.
.CAT_MARK

  END=0
  while test $END = 0
  do
    echo ""
    echo $EO "Do you want to see the contents of /afs/$CELL (y|n) [y]? $EC"
    read ANS EXCESS
    if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
    then
      END=1
    else
      if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
      then
	echo ""
	ls -C /afs/$CELL
	END=1
      else
	echo ""
	echo "Please answer y or n."
      fi
    fi
  done
  END=0
  while test $END = 0
  do
    echo ""
    echo $EO "AFS header file path: $EC"
    read ANS EXCESS
    fc=`expr "${ANS}X" : '\(.\).*'`
    if test "X$fc" = "X/"
    then
      if test -r $ANS/afs/afs.h
      then
	echo $ANS > $AH
	AHOK="ok"
	END=1
      else
	echo ""
	echo "$ANS/afs/afs.h doesn't exist."
	echo "Please enter a path whose afs subdirectory contains afs.h"
      fi
    else
      echo ""
      echo "Please enter an absolute path name."
    fi
  done
fi
if test "X$AHOK" != "Xok"
then
  echo "AFSConfig: unknown error"
  exit 1
fi

# Determine AFS version.

if test -r $AV
then
  echo ""
  echo "====================================================================="
  echo ""
  AVN=`cat $AV`
  cat << .CAT_MARK
The AFS version was previously specified as: $AVN
.CAT_MARK

  END=0
  while test $END = 0
  do
    echo ""
    echo $EO "Is this the correct version number (y|n) [y]? $EC"
    read ANS EXCESS
    if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
    then
      exit 0
    fi
    if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
    then
      rm -f $AV
      END=1
    else
      echo "Please answer y or n."
    fi
  done
fi

# See if the version number can be determined.

if test -r $AFSD
then
  ANS=`strings $AFSD | grep "Base configuration afs" | sed 's/^.*ion afs\([^ ]*\) .*/\1/'`
  TV=`echo $ANS | sed 's/^\([0-9]*\)\.\([0-9]*\)\(.*\)/\1 \2 \3/' | awk '{printf "%d.%d%s\n",$1,$2,$3}'`
  if test "X$ANS" = "X$TV"
  then
    echo ""
    echo "====================================================================="
    echo ""
    cat << .CAT_MARK
Examining $AFSD the AFS version number appears to be: $TV
.CAT_MARK

    END=0
    while test $END = 0
    do
      echo ""
      echo $EO "Do you want to use this version number (y/n) [y]? $EC"
      read ANS EXCESS
      if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
      then
	END=1
      else
	if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
	then
	  echo $TV > $AV
	  exit 0
	else
	  echo ""
	  echo "Please answer y or n."
	fi
      fi
    done
  fi
fi

# Ask for the version number.

echo ""
echo "====================================================================="
END=0
while test $END = 0
do
  echo ""
  echo $EO "Please enter the AFS version number: $EC"
  read ANS EXCESS
  TV=`echo $ANS | sed 's/^\([0-9]*\)\.\([0-9]*\)\(.*\)/\1 \2 \3/' | awk '{printf "%d.%d%s\n",$1,$2,$3}'`
  if test "X$ANS" = "X$TV"
  then
    echo $TV > $AV
    exit 0
  fi
done