Commit | Line | Data |
---|---|---|
805e021f CE |
1 | #!/bin/ksh |
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 | ##Installation and setup script for AFS Web Secure for the APACHE server | |
10 | ## | |
11 | PRODUCT_NAME="AFS Web Security Pack" | |
12 | ||
13 | message=" | |
14 | Use this script for configuring and setting up $PRODUCT_NAME for use | |
15 | with the Apache Web server. Before executing this script, be sure to | |
16 | read the Transarc $PRODUCT_NAME documentation provided in the | |
17 | AFSWebSecure_docs.tar file (the html documentation for $PRODUCT_NAME) | |
18 | ||
19 | Users should have some familiarity with Apache configuration, | |
20 | especially for troubleshooting purposes. Users must also have | |
21 | appropriate permissions in the relevant directories. | |
22 | ||
23 | NOTE: This script does not configure other features of the Apache | |
24 | server or SSL implementation for Apache. See related documentation for | |
25 | setting up Apache with SSL. | |
26 | ||
27 | This script prompts you to perform three operations: | |
28 | ||
29 | 1) Set up the configuration file for compiling $PRODUCT_NAME into | |
30 | the Apache source code and linking it with the appropriate | |
31 | libraries. Configure and build the Apache server binary. | |
32 | ||
33 | 2) Set up the Apache run-time directives configuration file with | |
34 | the directives required for $PRODUCT_NAME (configurable parameters) | |
35 | See the Transarc $PRODUCT_NAME documentation for explanations of these | |
36 | parameters and be sure you understand what each of them do. | |
37 | ||
38 | 3) Set up the startup and shutdown scripts for the Web server and | |
39 | starts up the server if you want it to. | |
40 | ||
41 | Default parameters are provided wherever appropriate. Please make sure | |
42 | you read the prompts and give the FULL PATH name (PATHNAME) where required. | |
43 | If you are familiar with Apache configuration and prefer to add the | |
44 | required parameters to the configuration files with a text editor, | |
45 | you can do so as with any other Apache module. | |
46 | " | |
47 | ||
48 | case $# in | |
49 | 1) show_welcome=1 ;; | |
50 | 2) set -x;; | |
51 | esac | |
52 | ||
53 | ||
54 | PRODUCT="AFS_Web_Security_Pack" | |
55 | COMPANY="IBM Transarc" | |
56 | aplib=libapacheafs.a | |
57 | syslib=libsys.a | |
58 | cp=/bin/cp | |
59 | rm=/bin/rm | |
60 | mv=/bin/mv | |
61 | more=/bin/more | |
62 | AFSModule=mod_afs.o | |
63 | prog=INSTALL.$PRODUCT | |
64 | ||
65 | os=`/bin/uname -s` | |
66 | osver=`/bin/uname -v` | |
67 | osrev=`/bin/uname -r` | |
68 | ||
69 | case $os in | |
70 | AIX) platform=${os}_${osver}.${osrev} ;; | |
71 | SunOS) platform=${os}_${osver} ;; | |
72 | *) echo "$prog:Unsupported Platform $os"; exit 0 ;; | |
73 | esac | |
74 | ||
75 | ## | |
76 | ##Defaults | |
77 | ## | |
78 | Log=$prog.log | |
79 | ||
80 | ServerRoot_default=`pwd` | |
81 | Apache_src_default=`pwd`/src | |
82 | ||
83 | ConfigScript_default=Configure | |
84 | Weblog_Starter_default=${ServerRoot_default}/weblog_starter | |
85 | make_conf_default=Configuration | |
86 | run_conf_default=httpd.conf | |
87 | binary_default=httpsd | |
88 | startscr_default=start.httpd | |
89 | stopscr_default=stop.httpd | |
90 | DocRoot_default=htdocs | |
91 | fs=/usr/afsws/bin/fs | |
92 | while [ ! -x $fs ] | |
93 | do | |
94 | echo "$fs:No such file or directory" | |
95 | echo $ac_n "Enter full path and filename for the fs binary on"\ | |
96 | " this AFS client machine: [$fs] $ac_c" | |
97 | read in | |
98 | test $in && fs=$in | |
99 | done | |
100 | ||
101 | default_cell_name=`$fs wscell | awk -F"'" '{ print $2 }'` | |
102 | case $default_cell_name in | |
103 | '') default_cell_name="CellName" ;; | |
104 | esac | |
105 | ||
106 | ## | |
107 | ## Display a nice fancy header prompt | |
108 | ## | |
109 | init_prompt() | |
110 | { | |
111 | colen=${#COMPANY} | |
112 | title="$PRODUCT_NAME SETUP AND INSTALLATION" | |
113 | titlen=${#title} | |
114 | clear | |
115 | echo | |
116 | echo | awk 'BEGIN { len="'$colen'" ; pos=(80-len)/2 } | |
117 | { for (i=0; i<pos; i++) { printf " " } | |
118 | } ' | |
119 | echo $ac_n "$COMPANY $ac_c" | |
120 | echo | |
121 | echo | awk 'BEGIN { len="'$titlen'" ; pos=(80-len)/2 } | |
122 | { for (i=0; i<pos; i++) { printf " " } | |
123 | } ' | |
124 | echo $ac_n "$title $ac_c" | |
125 | echo | |
126 | echo | awk '{ for (i=0; i < 80; i++) { printf "-" } }' | |
127 | echo; echo | |
128 | } | |
129 | ||
130 | ||
131 | ## | |
132 | ## Attempt to change the defaults in this file | |
133 | ## | |
134 | change_default() | |
135 | { | |
136 | args=2 | |
137 | rn=change_defaults | |
138 | case $# in | |
139 | $args) ;; | |
140 | *) echo "$rn: incorrect arguments:$#" ; | |
141 | return ;; | |
142 | esac | |
143 | file=$0 | |
144 | tempfile=/tmp/$file.$$ | |
145 | if [ ! -x $file ] | |
146 | then | |
147 | echo "$file not found for automatic update" | |
148 | return | |
149 | fi | |
150 | $cp -p $file $tempfile | |
151 | def=$1 | |
152 | val=$2 | |
153 | awk -F= 'BEGIN { d="'$def'" | |
154 | v="'$val'" | |
155 | } | |
156 | { | |
157 | if ($1 == d) { | |
158 | printf "# %s\n", $0 | |
159 | printf "%s=%s\n", d, v | |
160 | } | |
161 | else { | |
162 | print $0 | |
163 | } | |
164 | }' $tempfile > $file | |
165 | $rm -f $tempfile | |
166 | } | |
167 | ||
168 | ||
169 | ## | |
170 | ## Exit with the error message provided as the argument with exit status 1 | |
171 | ## | |
172 | die() | |
173 | { | |
174 | echo "$*" | |
175 | exit 1 | |
176 | } | |
177 | ||
178 | ## | |
179 | ## Insert text into a file in various ways - wrapper around an awk script | |
180 | ## | |
181 | insertfield() | |
182 | { | |
183 | # set -x | |
184 | rn=insertfield; | |
185 | args=4 | |
186 | ||
187 | case $# in | |
188 | $args) ;; | |
189 | *) die "incorrect number of arguments to $rn - $args expected. \ | |
190 | $# given";; | |
191 | esac | |
192 | ||
193 | file=$1 | |
194 | tempfile=/tmp/${file##*/}.$$ | |
195 | line=$2 | |
196 | type=$3 | |
197 | field=$4 | |
198 | ||
199 | case $type in | |
200 | "-f") #echo "$rn:$line in $file IN $field" | |
201 | ;; | |
202 | "-p") #echo "$rn:$line in $file AFTER $field" | |
203 | ;; | |
204 | "-n") #echo "$rn:$line in $file AT:$field" | |
205 | ;; | |
206 | "-pn") #echo "$rn:$line in $file AFTER LINE $field" | |
207 | ;; | |
208 | *) die "$rn:unrecognized option $type";; | |
209 | esac | |
210 | ||
211 | $cp -p $file $tempfile | |
212 | retval=$? | |
213 | test $retval -eq 0 || die "$rn:copy failed" | |
214 | ||
215 | awk ' | |
216 | BEGIN { | |
217 | done = 0 | |
218 | type = "'$type'" | |
219 | field = "'$field'" | |
220 | line = "'$line'" | |
221 | version = "'$apache_version'" | |
222 | } | |
223 | { if ( type == "-f" ) { | |
224 | split($0,str,"=") | |
225 | if ( field == str[1] ) { | |
226 | printf "%s %s\n", $0, line | |
227 | done=1 | |
228 | } | |
229 | else { | |
230 | print $0 | |
231 | } | |
232 | } | |
233 | else if ( type == "-n" ) { | |
234 | if (NR == field) { | |
235 | printf "%s\n%s\n", line, $0 | |
236 | done=1 | |
237 | } | |
238 | else { | |
239 | print $0 | |
240 | } | |
241 | } | |
242 | else if ( type == "-p" ) { | |
243 | split($0,str,"="); | |
244 | if ( field == str[1] ) { | |
245 | printf "%s\n%s=\n", $0, line | |
246 | done=1 | |
247 | } | |
248 | else { | |
249 | print $0 | |
250 | } | |
251 | } | |
252 | else if ( type == "-pn") { | |
253 | if ( field == $2 ) { | |
254 | if ( version == "1.3") { | |
255 | printf "%s\nAddModule %s\n", $0,line | |
256 | } | |
257 | else { | |
258 | printf "%s\nModule afs_module\t %s\n", $0,line | |
259 | } | |
260 | done=1 | |
261 | } | |
262 | else { | |
263 | print $0 | |
264 | } | |
265 | } | |
266 | } | |
267 | END { | |
268 | if ( done != 1 ) { | |
269 | if ( type == "-f" ) { | |
270 | printf "%s=%s\n",field,line | |
271 | } | |
272 | else { | |
273 | printf "%s\n",line | |
274 | } | |
275 | } | |
276 | } | |
277 | ' $tempfile > $file | |
278 | ||
279 | retval=$? | |
280 | if [ $retval -eq 0 ] | |
281 | then | |
282 | $rm -f $tempfile | |
283 | else | |
284 | if [ -f $tempfile ] | |
285 | then | |
286 | $mv -f /tmp/$file.$$ $file | |
287 | fi | |
288 | die "rn:AWK ERROR" | |
289 | fi | |
290 | } | |
291 | ||
292 | ||
293 | ## | |
294 | ## Used for Configuring run-time AFS directives | |
295 | ## | |
296 | read_directives() | |
297 | { | |
298 | rn=read_directives | |
299 | case $# in | |
300 | 0) die "$rn:Insufficient Arguments provided" | |
301 | esac | |
302 | ||
303 | file=$1;shift | |
304 | ||
305 | while test "$1" != "" | |
306 | do | |
307 | directive=$1;shift | |
308 | value=$1; shift | |
309 | echo $ac_n "$directive [$value]:$ac_c" | |
310 | read in | |
311 | test $in && value=$in | |
312 | echo "$directive $value" >> $file | |
313 | done | |
314 | } | |
315 | ||
316 | ## | |
317 | ## Given the Directive name ($2) it returns the value from the given | |
318 | ## file name ($1) - only for Directives beginning with SetAFS | |
319 | ## | |
320 | get_afsdirective() | |
321 | { | |
322 | args=2 | |
323 | rn=get_afsdirective | |
324 | case $# in | |
325 | 2) ;; | |
326 | *) die "$rn:Incorrect args:$#" ;; | |
327 | esac | |
328 | ||
329 | awk '/SetAFS.*/ { | |
330 | if ( $1 == "'$2'" ) { | |
331 | print $2 | |
332 | } | |
333 | }' $1 | |
334 | } | |
335 | ||
336 | ## | |
337 | ## Given the Directive name ($2) it returns the value from the given | |
338 | ## file name ($1) - FOR ALL DIRECTIVES | |
339 | ## | |
340 | get_directive() | |
341 | { | |
342 | args=2 | |
343 | rn=get_directive | |
344 | case $# in | |
345 | 2) ;; | |
346 | *) die "$rn:Incorrect args:$#" ;; | |
347 | esac | |
348 | ||
349 | awk '{ | |
350 | if ( $1 == "'$2'" ) { | |
351 | print $2 | |
352 | } | |
353 | }' $1 | |
354 | } | |
355 | ||
356 | ## | |
357 | ## Replace or insert single Directive value pair | |
358 | ## | |
359 | put_directive() | |
360 | { | |
361 | rn=put_directive | |
362 | args=3 | |
363 | case $# in | |
364 | $args) file=$1; directive=$2; value=$3 ;; | |
365 | *) die "$rb:Incorrect args: $args - $#" | |
366 | esac | |
367 | ttempfile=/tmp/${prog}_${rn}.${file##*/}.$$ | |
368 | ed=`grep $directive $file | grep -v '^#'` | |
369 | ediff=`echo $ed | awk '{ print $2 }'` | |
370 | echo $ac_n "$directive ($ediff) [$value]:$ac_c" | |
371 | read in | |
372 | case $in in | |
373 | '') ;; | |
374 | *) value=$in ;; | |
375 | esac | |
376 | case $ediff in | |
377 | '') echo "$directive $value" >> $file | |
378 | ;; | |
379 | *) if [ ! $ediff = $value ] | |
380 | then | |
381 | awk '{ if ($1 == "'$directive'") { | |
382 | printf "%s %s\n", $1, "'$value'" | |
383 | } | |
384 | else { print $0 } | |
385 | }' $file > $ttempfile | |
386 | $mv -f $ttempfile $file | |
387 | retval=$? | |
388 | case $retval in | |
389 | 0) ;; | |
390 | *) die "$rn: mv failed: $retval" | |
391 | esac | |
392 | fi ;; | |
393 | esac | |
394 | } | |
395 | ||
396 | ||
397 | ## | |
398 | ## Replace directives if they exist with new values or create the Directive | |
399 | ## value pair if none exists in the run-time configuration file | |
400 | ## | |
401 | put_directives() | |
402 | { | |
403 | rn=put_directives | |
404 | case $# in | |
405 | 0) die "$rn: incorrect arguments: $#" ;; | |
406 | esac | |
407 | ||
408 | file=$1 ; shift | |
409 | ttempfile=/tmp/${prog}_${rn}.${file##*/}.$$ | |
410 | ||
411 | echo; echo | |
412 | echo "Use the following syntax" | |
413 | echo "<Enter> or <space> to accept [default] value" | |
414 | echo "<-> to keep (Existing) value" | |
415 | echo "<#> to comment out directive" | |
416 | ||
417 | while test "$1" != "" | |
418 | do | |
419 | directive=$1;shift | |
420 | value=$1; shift | |
421 | edir=`grep $directive $file | grep -v '^#'` | |
422 | ediff=`echo $edir | awk '{ print $2 }'` | |
423 | case $ediff in | |
424 | '') t=`grep $directive $file|grep '^#'` ; | |
425 | case $t in | |
426 | '') existprompt="NO EXISTING DIRECTIVE" ;; | |
427 | *) existprompt="DIRECTIVE COMMENTED OUT" ;; | |
428 | esac | |
429 | ;; | |
430 | *) existprompt=$ediff | |
431 | ;; | |
432 | esac | |
433 | echo $ac_n "$directive ($existprompt) [$value]:$ac_c" | |
434 | read in | |
435 | case $in in | |
436 | '') echo "Default $value unchanged" | |
437 | ;; | |
438 | '#') echo "This directive $directive will be commented out" | |
439 | ediff='#' | |
440 | ;; | |
441 | '-') echo "Existing $ediff unchanged" ; | |
442 | if [ ! -z $ediff ] | |
443 | then | |
444 | value=$ediff | |
445 | else | |
446 | value='#' | |
447 | fi | |
448 | ;; | |
449 | *) value=$in | |
450 | ;; | |
451 | esac | |
452 | case $ediff in | |
453 | '') #search for commented out directive first | |
454 | if [ ! $value = '#' ] | |
455 | then | |
456 | edir=`grep $directive $file|grep $value|grep '^#'` | |
457 | case $edir in | |
458 | '') echo "$directive $value" >> $file | |
459 | ;; | |
460 | *) edir=`echo $edir|sed 's/.*#//g'|sed 's/^ //g'` | |
461 | edir2=`echo $edir|awk '{ print $2 }'` | |
462 | if [ $edir2 = $value ] | |
463 | then | |
464 | #TO DO | |
465 | echo "$directive $value" >> $file | |
466 | #echo "Uncommented: $edir" | |
467 | fi | |
468 | ;; | |
469 | esac | |
470 | fi | |
471 | ;; | |
472 | '#') echo "Commenting out $directive" ; | |
473 | awk '{ if ($1 == "'$directive'") { | |
474 | printf "# %s\n", $0 | |
475 | } | |
476 | else { print $0 } | |
477 | }' $file > $ttempfile ; | |
478 | $mv -f $ttempfile $file ; | |
479 | retval=$? ; | |
480 | case $retval in | |
481 | 0) ;; | |
482 | *) die "$rn: mv failed: $retval" ;; | |
483 | esac | |
484 | ;; | |
485 | ||
486 | *) if [ ! $ediff = $value ] | |
487 | then | |
488 | echo "Changing: $directive $ediff $value" | |
489 | awk '{ if ($1 == "'$directive'") { | |
490 | printf "%s %s\n", $1, "'$value'" | |
491 | } | |
492 | else { print $0 } | |
493 | }' $file > $ttempfile | |
494 | ||
495 | $mv -f $ttempfile $file | |
496 | retval=$? | |
497 | case $retval in | |
498 | 0) ;; | |
499 | *) die "$rn: mv failed: $retval" ;; | |
500 | esac | |
501 | fi ;; | |
502 | esac | |
503 | done | |
504 | } | |
505 | ||
506 | ||
507 | set_compiler() | |
508 | { | |
509 | rn=set_compiler | |
510 | args=1 | |
511 | case $# in | |
512 | $args) ;; | |
513 | *) die "$rn: Incorrect args:$#" | |
514 | esac | |
515 | ||
516 | case $os in | |
517 | AIX) insertfield $1 /bin/cc -f CC ;; | |
518 | *) ;; | |
519 | esac | |
520 | } | |
521 | ||
522 | ## | |
523 | ## Add a module to the Configuration file - prompt to go to main menu and | |
524 | ## reconfigure and re-compile. If module commented out - uncomment it | |
525 | ## | |
526 | add_module() | |
527 | { | |
528 | rn=add_module | |
529 | args=3 | |
530 | case $# in | |
531 | $args) f=$1; mn=$2 mf=$3 ;; | |
532 | *) die "$rn: Incorrect args:$#" | |
533 | esac | |
534 | ||
535 | cmf=$mf.c | |
536 | omf=$mf.o | |
537 | if [ ! -f $Apache_src/$cmf ] | |
538 | then | |
539 | echo "Module file $Apache_src/$cmf does not exist" | |
540 | echo "Ensure you have this C source file in the " \ | |
541 | "apache src ($Apache_src)directory" | |
542 | return 2 | |
543 | fi | |
544 | ||
545 | tf=/tmp/${prog}_${rn} | |
546 | ed=`grep $mn $f` | |
547 | case $ed in | |
548 | '') echo "Module $mn not found"; | |
549 | echo "Choose a module after which module you wish to insert " \ | |
550 | "this module. Note that modules are prioritised bottom-up"; | |
551 | echo "See Apache documentation for more details"; | |
552 | val=Y; | |
553 | modulelist=`grep Module $f | grep -v '^#'` ; | |
554 | echo $ac_n "View a list of current modules: [$val] $ac_c"; | |
555 | read in; test $in && val=$in; | |
556 | case $val in | |
557 | y|Y) echo "$modulelist" | more | |
558 | ;; | |
559 | *) ;; | |
560 | esac | |
561 | echo $ac_n "Enter module name to enter this module after: $ac_c" | |
562 | read aftm | |
563 | test $aftm || { echo "No module entered ... returning"; return 2; } | |
564 | eg=`echo "$modulelist" | grep $aftm` ; | |
565 | case $eg in | |
566 | '') echo "Module $aftm not found in list" | |
567 | echo "$modulelist" | |
568 | echo "... returning"; | |
569 | return 2;; | |
570 | *) echo "$aftm found in $modulelist" | |
571 | ;; | |
572 | esac | |
573 | $cp -p $f $tf | |
574 | awk ' | |
575 | BEGIN { | |
576 | after="'$aftm'" | |
577 | mname="'$mn'" | |
578 | mfile="'$omf'" | |
579 | } | |
580 | { | |
581 | if ( $2 == after ) { | |
582 | printf "%s\nModule %s\t%s\n", $0,mname,mfile | |
583 | } | |
584 | else { | |
585 | print $0 | |
586 | } | |
587 | }' $tf > f; | |
588 | $rm -f $tf; | |
589 | return 1 | |
590 | ;; | |
591 | *) jk=`echo $ed | grep '^#'` ; | |
592 | case $jk in | |
593 | '') echo "Module already exists: $ed. Returning"; | |
594 | return 0 | |
595 | ;; | |
596 | *) $cp -p $f $tf; | |
597 | awk '{ if (( $2 == "'$mn'" )||( $3 == "'$mn'" )) { | |
598 | printf "Module %s\t%s\n", "'$mn'", "'$omf'" | |
599 | } | |
600 | else { | |
601 | print $0 | |
602 | } | |
603 | }' $tf > $f; | |
604 | $rm -f $tf; | |
605 | return 1; | |
606 | ;; | |
607 | esac | |
608 | esac | |
609 | } | |
610 | ||
611 | config_makefile() | |
612 | { | |
613 | init_prompt; | |
614 | echo ; echo | |
615 | echo "Configuring Makefile" | |
616 | echo; | |
617 | ||
618 | mc=' ' | |
619 | make_conf_dir=${make_conf%/*} | |
620 | while [[ ! -f $mc ]] | |
621 | do | |
622 | echo $ac_n "Configuration file name [$make_conf]:$ac_c" | |
623 | read uconf | |
624 | case $uconf in | |
625 | '') ;; | |
626 | /*) make_conf=$uconf ; | |
627 | make_conf_dir=${make_conf%/*} | |
628 | ;; | |
629 | *) make_conf=${make_conf_dir}/${uconf}; | |
630 | make_conf_dir=${make_conf%/*} | |
631 | ;; | |
632 | esac | |
633 | mc=$make_conf | |
634 | test -f $mc || echo "$mc: does not exist" | |
635 | done | |
636 | ||
637 | # Back up original Configuration file | |
638 | backup=$make_conf.BEFOREAFS | |
639 | number=0 | |
640 | while [ -f $backup ] | |
641 | do | |
642 | backup=$make_conf.BEFOREAFS.$number | |
643 | number=$(($number+1)) | |
644 | done | |
645 | ||
646 | $cp -p $make_conf $backup | |
647 | ||
648 | ( do_reconfig_makefile $make_conf ) | |
649 | ||
650 | case $? in | |
651 | 0) echo "Configured $make_conf successfully";; | |
652 | *) $mv -f $backup $make_conf ; | |
653 | die "Configuration for Makefile FAILED: Exiting" ;; | |
654 | esac | |
655 | ||
656 | ConfigScript=$ConfigScript_default | |
657 | val=Y | |
658 | echo $ac_n "Run Configuration script ($ConfigScript):"\ | |
659 | " [$val] $ac_c" | |
660 | read i | |
661 | test $i && val=$i | |
662 | if [ $val = Y ] || [ $val = y ] | |
663 | then | |
664 | while [[ ! -x ${make_conf_dir}/${ConfigScript} ]] | |
665 | do | |
666 | echo "$ConfigScript: not found or not "\ | |
667 | "executable in $make_conf_dir" | |
668 | echo $ac_n "Enter Configure script name"\ | |
669 | ":[$ConfigScript]$ac_c" | |
670 | read in | |
671 | test $in && ConfigScript=$in | |
672 | done | |
673 | ||
674 | ( cd $make_conf_dir; $ConfigScript -file $make_conf ) | |
675 | ||
676 | case $? in | |
677 | 0) echo "Configuration succesful";; | |
678 | *) die "Configuration FAILED - Exiting";; | |
679 | esac | |
680 | fi | |
681 | val=Y | |
682 | echo $ac_n "Compile: [$val] $ac_c" | |
683 | read i | |
684 | test $i && val=$i | |
685 | if [ $val = Y ] || [ $val = y ] | |
686 | then | |
687 | ( cd $Apache_src ; make ) | |
688 | test $? != 0 && die "ERROR: make failed" | |
689 | fi | |
690 | } | |
691 | ||
692 | ||
693 | configure_and_compile() | |
694 | { | |
695 | ConfigScript=$ConfigScript_default | |
696 | val=Y | |
697 | echo $ac_n "Run Configuration script ($ConfigScript):[$val] $ac_c" | |
698 | read i | |
699 | test $i && val=$i | |
700 | if [ $val = Y ] || [ $val = y ] | |
701 | then | |
702 | while [[ ! -x ${make_conf_dir}/${ConfigScript} ]] | |
703 | do | |
704 | echo "$ConfigScript: not found or not "\ | |
705 | "executable in $make_conf_dir" | |
706 | echo $ac_n "Enter Configure script name"\ | |
707 | ":[$ConfigScript]$ac_c" | |
708 | read in | |
709 | test $in && ConfigScript=$in | |
710 | done | |
711 | ||
712 | ( cd $make_conf_dir; ./$ConfigScript -file $make_conf ) | |
713 | ||
714 | case $? in | |
715 | 0) echo "Configuration successful";; | |
716 | *) die "Configuration FAILED - Exiting";; | |
717 | esac | |
718 | fi | |
719 | val=Y | |
720 | echo $ac_n "Compile: [$val] $ac_c" | |
721 | read i | |
722 | test $i && val=$i | |
723 | if [ $val = Y ] || [ $val = y ] | |
724 | then | |
725 | ( cd $Apache_src ; make ) | |
726 | test $? != 0 && die "ERROR: make failed" | |
727 | fi | |
728 | } | |
729 | ||
730 | ||
731 | ## | |
732 | ## Make a symbolic link from arg1 to arg2 | |
733 | ## check if it exists first and present options if it does | |
734 | ## | |
735 | make_symlink() | |
736 | { | |
737 | rn=make_symlink | |
738 | case $# in | |
739 | 2) target=$2; source=$1 ;; | |
740 | *) die "$rn:Incorrect number of args:$#" ;; | |
741 | esac | |
742 | if [ -h $source ] | |
743 | then | |
744 | ## symlink already exists - leave it or change it? | |
745 | echo "Symbolic Link already exists" ; | |
746 | ls -l $source ; | |
747 | return 1 | |
748 | else | |
749 | if [ -d $target ] | |
750 | then | |
751 | echo "Creating Symbolic Link $source->$target" | |
752 | else | |
753 | val=N ; | |
754 | echo $ac_n "WARNING: $target is not a directory. Create anyway:[$val]" $ac_c; | |
755 | read in ; | |
756 | test $in && val=$in ; | |
757 | case $val in | |
758 | N|n) return 1;; | |
759 | *) ;; | |
760 | esac | |
761 | fi | |
762 | ln -s $target $source ; | |
763 | case $? in | |
764 | 0) ;; | |
765 | *) return 2 ;; | |
766 | esac | |
767 | fi | |
768 | } | |
769 | ||
770 | ||
771 | ||
772 | ## | |
773 | ## Edit run time configuration file | |
774 | ## | |
775 | do_run_time() | |
776 | { | |
777 | rn=do_run_time; | |
778 | case $# in | |
779 | 1) conf=$1;; | |
780 | 2) conf=$1; tempfile=$2;; | |
781 | *) die "$rn:Incorrect number of args:$#" ;; | |
782 | esac | |
783 | ||
784 | test -f $conf || die "No Configuration file called $conf found" | |
785 | ||
786 | ## | |
787 | ## Check for AFS Directives | |
788 | ## | |
789 | ap=SetAFS | |
790 | afsdirective="AFSAuthType AFS" | |
791 | line=`grep -i "$afsdirective" $conf | grep -v '^#'` | |
792 | case $line in | |
793 | "") #echo "Editing $conf to add AFS Directives" | |
794 | ;; | |
795 | *) echo "AFS Directives already found in file $conf \n\n$line" ; | |
796 | echo ; | |
797 | exit 10 ;; | |
798 | esac | |
799 | ||
800 | tempfile=${tempfile:-/tmp/$prog.$$} | |
801 | #echo "Tempfile:$tempfile" | |
802 | ||
803 | echo "##" >> $tempfile | |
804 | echo "##AFS Authentication Directives for $PRODUCT_NAME $product_version" >> $tempfile | |
805 | echo "##Inserted by installation script $prog\n##" >> $tempfile | |
806 | echo >> $tempfile | |
807 | ||
808 | afsdirectives="${ap}DefaultCell $default_cell_name ${ap}CacheExpiration 120 ${ap}TokenExpiration 600 ${ap}WeblogPath $Weblog_Starter_default" ; | |
809 | AFSModuleFile=afs_module.c | |
810 | ||
811 | echo "<ifmodule $AFSModuleFile>" >> $tempfile | |
812 | read_directives $tempfile $afsdirectives | |
813 | ||
814 | ## | |
815 | ## Check to ensure WebLogPath exists and is executable | |
816 | ## | |
817 | loc=`get_directive $tempfile ${ap}WeblogPath` | |
818 | while [[ ! -x $loc ]] | |
819 | do | |
820 | echo "${ap}WeblogPath: $loc Does not exist or not executable" | |
821 | echo "Make sure you copy both binaries weblog and "\ | |
822 | "weblog_starter into the same dir that you specify the"\ | |
823 | " FULL path to here - see installation instructions" | |
824 | echo $ac_n "Enter full path to weblog_starter: [$loc] $ac_c" | |
825 | read in | |
826 | test $in && loc=$in | |
827 | new_directive="${ap}WeblogPath $loc" | |
828 | # echo $tempfile; cat $tempfile | |
829 | put_directives $tempfile $new_directive | |
830 | # echo $tempfile; cat $tempfile | |
831 | done | |
832 | ||
833 | ||
834 | ## | |
835 | ## Get the SetAFSLocation directive's value and put AFSAuthType AFS | |
836 | ## | |
837 | AFSAuthDirective="AFSAuthType AFS" | |
838 | loc=/afs | |
839 | echo $ac_n "Enter a Location for which AFS Authentication is desired: [$loc] $ac_c" | |
840 | read in | |
841 | test $in && loc=$in | |
842 | ## | |
843 | ## Make a symlink from documentRoot to afs mount points | |
844 | ## | |
845 | val=Y | |
846 | echo $ac_n "Make a symbolic link from the DocumentRoot " \ | |
847 | "directory to the directory where the AFS cell mount points" \ | |
848 | " for this AFS client machine are stored: [$val] $ac_c" | |
849 | read in | |
850 | test $in && val=$in | |
851 | case $val in | |
852 | y|Y) echo "Making symbolic link" | |
853 | directive=`grep -i "DocumentRoot" $conf | grep -v '^#'`; | |
854 | if [ ! "$directive" ] || [ "$directive" = "" ] || [ -z "$directive" ] | |
855 | then | |
856 | echo "No directive for DocumentRoot exists in $conf" | |
857 | echo $ac_n "Document Root Directory (full path):[$DocRoot] $ac_c" | |
858 | read in | |
859 | test $in && DocRoot=$in | |
860 | echo "DocumentRoot $DocRoot" >> $tempfile | |
861 | else | |
862 | DocRoot=`echo $directive | awk '{ print $2 }'` | |
863 | fi; | |
864 | test -d "$DocRoot" || die "$DocRoot not a Directory"; | |
865 | mtp=$DocRoot/$loc ; | |
866 | ||
867 | afsdir=/afs ; | |
868 | echo $ac_n "Enter directory where AFS mount points are: [$afsdir] $ac_c"; | |
869 | read in ; | |
870 | test $in && afsdir=$in ; | |
871 | test -d $afsdir || die "ERROR:$afsdir is not a directory"; | |
872 | make_symlink $mtp $afsdir | |
873 | case $? in | |
874 | 0) ;; | |
875 | 1) echo "Symlink Exists or cancelled" ;; | |
876 | *) die "ERROR making symlink from $mtp to $afsdir."\ | |
877 | "Exiting" | |
878 | ;; | |
879 | esac | |
880 | ;; | |
881 | *) ;; | |
882 | esac | |
883 | ||
884 | echo "<Location $loc>" >> $tempfile | |
885 | echo $AFSAuthDirective >> $tempfile | |
886 | authname_default='"AFS Login (user@<%ccellname>)"' | |
887 | echo "Set the AuthName directive to customize the Login prompt" \ | |
888 | "that users will see" | |
889 | echo "You may use text intersperced with the following " \ | |
890 | "expressions (these should be enclosed in angle brackets):" | |
891 | echo "%c to specify the AFS cell name where the requested file resides" | |
892 | echo "%u to specify the first two components of the URL" | |
893 | echo "%d to specify the default cell" | |
894 | echo "Consult documentation for more details" | |
895 | echo $ac_n "AFSLoginPrompt [$authname_default]" $ac_c | |
896 | read n | |
897 | case $n in | |
898 | '') ;; | |
899 | *) authname_default="$n" ;; | |
900 | esac | |
901 | echo AFSLoginPrompt $authname_default >> $tempfile | |
902 | echo "</Location>" >> $tempfile | |
903 | ||
904 | val=N | |
905 | echo $ac_n "Log access denied requests: [$val] $ac_c" | |
906 | read in ; test $in && val=$in | |
907 | case $val in | |
908 | y|Y) accesslogfile=$ServerRoot/logs/forbiddenlog ; | |
909 | echo $ac_n "Log file: [$accesslogfile]" $ac_c; | |
910 | read in ; test $in && accesslogfile=$in; | |
911 | echo "SetAFSAccessLog $accesslogfile">>$tempfile | |
912 | ;; | |
913 | *) ;; | |
914 | esac | |
915 | ||
916 | if [ $apache_version != 1.3 ] | |
917 | then | |
918 | ud=`grep -i UserDir $conf` | |
919 | case $ud in | |
920 | '') val=Y ; | |
921 | echo $ac_n "Add support for User Directories: [$val] $ac_c"; | |
922 | read in ; test $in && val=$in | |
923 | case $val in | |
924 | y|Y) userdir=/usr/ ; | |
925 | echo $ac_n "UserDir: [$userdir]" $ac_c; | |
926 | read in ; test $in && userdir=$in; | |
927 | echo "UserDir $userdir">>$tempfile; | |
928 | echo "Need to ensure userdir_module is included" | |
929 | echo "in the Makefile configuration .... " | |
930 | mc=' '; | |
931 | make_conf_dir=${make_conf%/*} ; | |
932 | while [[ ! -f $mc ]] | |
933 | do | |
934 | echo $ac_n "Makefile Configuration file name [$make_conf]:$ac_c" | |
935 | read uconf | |
936 | case $uconf in | |
937 | '') ;; | |
938 | /*) make_conf=$uconf ; | |
939 | make_conf_dir=${make_conf%/*}; | |
940 | ;; | |
941 | *) make_conf=${make_conf_dir}/${uconf}; | |
942 | make_conf_dir=${make_conf%/*}; | |
943 | ;; | |
944 | esac | |
945 | mc=$make_conf | |
946 | test -f $mc || echo "$mc: does not exist" | |
947 | done | |
948 | add_module $make_conf userdir_module mod_userdir; | |
949 | case $? in | |
950 | 1) echo "Need to reconfigure and recompile"; | |
951 | configure_and_compile | |
952 | ;; | |
953 | 2) echo "Failed to add module userdir_module" | |
954 | ;; | |
955 | 0) ;; | |
956 | esac | |
957 | ;; | |
958 | *) ;; | |
959 | esac ;; | |
960 | *) ;; | |
961 | esac | |
962 | fi # /* if Apache 1.3 */ | |
963 | ||
964 | echo "</ifmodule>" >> $tempfile | |
965 | echo "##\n##End AFS Authentication Directives for $PRODUCT_NAME \n##" >> $tempfile | |
966 | ||
967 | ## | |
968 | ## Append tempfile to run time config file and remove tempfile | |
969 | ## | |
970 | cat $tempfile >> $conf | |
971 | $rm -f $tempfile | |
972 | } | |
973 | ||
974 | ||
975 | ## | |
976 | ## Configures the Configuration file for the Apache Makefile | |
977 | ## | |
978 | do_config_makefile() | |
979 | { | |
980 | rn=do_config_makefile | |
981 | case $# in | |
982 | 1) ;; | |
983 | *) die "Incorrect number of args given to $rn: $#";; | |
984 | esac | |
985 | ||
986 | conf=$1 | |
987 | ||
988 | ## | |
989 | ## see if there is a line for EXTRA_LIBS and add | |
990 | ## EXTRA_LIBS=libsys.a and libapacheafs.a | |
991 | ## or append to whatever was there before | |
992 | ## | |
993 | currfield=EXTRA_LIBS | |
994 | elib=`grep $currfield $conf | grep -v '^#'` | |
995 | case $elib in | |
996 | '') prevfield="EXTRA_CFLAGS"; | |
997 | echo "WARNING: No $currfield line was found in $conf" ; | |
998 | echo "Attempting to insert $currfield after $prevfield" ; | |
999 | echo "Ensure you have a $currfield entry in $conf" ; | |
1000 | r=Y ; | |
1001 | echo $ac_n "Go ahead with this: [$r] $ac_c" ; | |
1002 | read in ; | |
1003 | test $in && r=$in ; | |
1004 | if [ $r != "Y" ] || [ $r != "y" ] | |
1005 | then | |
1006 | die "Edit $conf and add $currfield =" | |
1007 | fi ; | |
1008 | insertfield $conf $currfield -p $prevfield | |
1009 | ;; | |
1010 | *) ;; | |
1011 | esac | |
1012 | ||
1013 | elib=`awk ' | |
1014 | { | |
1015 | split($0,str,"="); | |
1016 | if (str[1] == "'$currfield'") | |
1017 | { | |
1018 | split($0,str,"="); | |
1019 | print str[2] | |
1020 | } | |
1021 | } ' $conf` | |
1022 | ||
1023 | libpath=$ServerRoot | |
1024 | for lib in $aplib $syslib | |
1025 | do | |
1026 | elibval=`echo $elib | grep "$lib"` | |
1027 | if [ ! "$elibval" ]||[ "$elibval" = "" ]||[ -z "$elibval" ] | |
1028 | then | |
1029 | #echo "$lib doesn't exist in $currfield $elib" | |
1030 | libfull=' ' | |
1031 | until [[ -f $libfull ]] | |
1032 | do | |
1033 | case $lib in | |
1034 | $syslib) libpath="/usr/afsws/lib/afs/" | |
1035 | ;; | |
1036 | $aplib) libpath=$ServerRoot ;; | |
1037 | esac | |
1038 | ||
1039 | echo $ac_n "Enter only the path" \ | |
1040 | " (not the filename) for $lib:[$libpath]$ac_c " | |
1041 | read in | |
1042 | test $in && libpath=$in | |
1043 | libfull=$libpath/$lib | |
1044 | if [ ! -f $libfull ] | |
1045 | then | |
1046 | echo "$libfull DOESN'T EXIST" | |
1047 | fi | |
1048 | done | |
1049 | insertfield $conf $libfull -f $currfield | |
1050 | else | |
1051 | echo "$lib Exists in $elib" >> $Log | |
1052 | fi | |
1053 | done | |
1054 | ||
1055 | ## | |
1056 | ## Check for afs_module | |
1057 | ## | |
1058 | if [ $apache_version = 1.3 ] | |
1059 | then | |
1060 | AFSModule=modules/extra/afs_module.o | |
1061 | else | |
1062 | AFSModule=afs_module.o | |
1063 | fi | |
1064 | ||
1065 | AFSModuleName="afs_module" | |
1066 | tmod=`grep $AFSModuleName $conf | grep -v '^#' | awk '{ if ($2 == "'$AFSModuleName'" ) printf "%d:%s\n", NR, $0 }'` | |
1067 | if [ "$tmod" ] | |
1068 | then | |
1069 | echo "AFS module already exists in file $conf" >> $Log | |
1070 | echo "Line: $tmod" >> $Log | |
1071 | else | |
1072 | ## | |
1073 | ## List the active modules and prompt user where to insert AFS MODULE | |
1074 | ## | |
1075 | echo | |
1076 | echo | |
1077 | echo "YOUR LIST OF CURRENT MODULES IS" | |
1078 | awk '{ if ($1 == "Module" || $1 == "AddModule") print $0 }' $conf | $more | |
1079 | if [ $apache_version = 1.3 ] | |
1080 | then | |
1081 | defmod=modules/standard/mod_auth.o | |
1082 | else | |
1083 | defmod=auth_module | |
1084 | fi | |
1085 | echo $ac_n "After which module would you like to put the AFS Module [$defmod]: $ac_c" | |
1086 | read after_module | |
1087 | test $after_module || after_module=$defmod | |
1088 | tmod=`awk '{ if ($2 == "'$after_module'") print $0 }' $conf` | |
1089 | echo $tmod | |
1090 | test ! "$tmod" || test "$tmod" = "" || test -z "$tmod" && die "Module $after_module NOT FOUND IN MODULE LIST" | |
1091 | while true | |
1092 | do | |
1093 | case $tmod in | |
1094 | '') ;; | |
1095 | *) break ;; | |
1096 | esac | |
1097 | done | |
1098 | insertfield $conf "$AFSModule" -pn $after_module | |
1099 | fi | |
1100 | ||
1101 | ## | |
1102 | ## Attempt to set the correct compiler according to OSTYPE | |
1103 | ## | |
1104 | set_compiler $conf | |
1105 | } | |
1106 | ||
1107 | ## | |
1108 | ## Edit the start and stop scripts | |
1109 | ## | |
1110 | do_start_stop() | |
1111 | { | |
1112 | rn=do_start_stop | |
1113 | args=3 | |
1114 | case $# in | |
1115 | $args) file=$2 ;; | |
1116 | *) die "rn: Incorrect number of parameters supplied: $#";; | |
1117 | esac | |
1118 | ||
1119 | case $1 in | |
1120 | START) start=1; bin=$3 ;; | |
1121 | STOP) start=0; run_conf=$3; edit=0 ;; | |
1122 | E_STOP) start=0; run_conf=$3; edit=1 ;; | |
1123 | *) die "$rn: Incorrect type of ARG passed: $1" ;; | |
1124 | esac | |
1125 | ||
1126 | until [[ -f $run_conf ]] | |
1127 | do | |
1128 | echo; echo | |
1129 | echo "No run_time configuration file $run_conf found" | |
1130 | echo $ac_n "Run-time conf file:[$run_conf]$ac_c" | |
1131 | read in | |
1132 | test $in && run_conf=$in | |
1133 | done | |
1134 | ||
1135 | if [ $start = 1 ] | |
1136 | then | |
1137 | echo "#!/bin/sh" > $file | |
1138 | echo "##" >> $file | |
1139 | echo "##Apache $PRODUCT_NAME StartUp" >> $file | |
1140 | echo "##" >> $file | |
1141 | echo "$bin -f $run_conf" >> $file | |
1142 | echo >> $file | |
1143 | chmod +x $file | |
1144 | ||
1145 | else | |
1146 | pfl=`grep -i pidfile $run_conf | grep -v "#"` | |
1147 | ||
1148 | test ! "$pfl" || test "$pfl" = "" || test -z "$pfl" && die "No PidFile specified in $run_conf. Edit this file and specify the PidFile directive. Exiting" | |
1149 | pid_file=`echo $pfl| awk '{ print $2 }'` | |
1150 | ||
1151 | test ! "$pid_file" || test "$pid_file" = "" || test -z "$pid_file" && die "No PidFile specified in $run_conf. Edit this file and specify the PidFile directive. Exiting" | |
1152 | ||
1153 | ||
1154 | if [ $edit = 0 ] | |
1155 | then | |
1156 | echo "#!/bin/sh" > $file | |
1157 | echo "##" >> $file | |
1158 | echo "##Apache $PRODUCT_NAME Shutdown">>$file | |
1159 | echo "##" >> $file | |
1160 | echo "kill -TERM \`cat $pid_file.afs\`">>$file | |
1161 | echo "kill -TERM \`cat $pid_file\`" >> $file | |
1162 | echo >> $file | |
1163 | chmod +x $file | |
1164 | ||
1165 | else | |
1166 | if [ ! -x $file ] | |
1167 | then | |
1168 | die "$file: does not exist"\ | |
1169 | " or is not executable. Exiting" | |
1170 | fi | |
1171 | ||
1172 | t=`grep -i "\.afs" $file` | |
1173 | if [ ! "$t" ] || [ -z "$t" ] || [ "$t" = "" ] | |
1174 | then | |
1175 | temp=/tmp/${prog}stopd.$$ | |
1176 | $cp -f $file $temp | |
1177 | awk '{ line[NR]=$0 } | |
1178 | END { | |
1179 | printf "kill -TERM `%s.afs`\n", "'$pid_file'" | |
1180 | for (i=1; i <= NR; i++) { | |
1181 | printf "%s\n", line[i] } | |
1182 | }' $temp > $file | |
1183 | $rm $temp | |
1184 | fi | |
1185 | fi | |
1186 | fi | |
1187 | } | |
1188 | ||
1189 | ||
1190 | configure_makefile_forwebsecure() | |
1191 | { | |
1192 | val=Y | |
1193 | echo $ac_n "Change Apache Configuration file [$val]:$ac_c" | |
1194 | read in | |
1195 | test $in && val=$in | |
1196 | ||
1197 | if [ $val = Y ] || [ $val = y ] | |
1198 | then | |
1199 | mc=' ' | |
1200 | make_conf_dir=${make_conf%/*} | |
1201 | while [[ ! -f $mc ]] | |
1202 | do | |
1203 | echo $ac_n "Configuration file name [$make_conf]:$ac_c" | |
1204 | read uconf | |
1205 | case $uconf in | |
1206 | '') ;; | |
1207 | /*) make_conf=$uconf ; | |
1208 | make_conf_dir=${make_conf%/*}; | |
1209 | ;; | |
1210 | *) make_conf=${make_conf_dir}/${uconf}; | |
1211 | make_conf_dir=${make_conf%/*}; | |
1212 | ;; | |
1213 | esac | |
1214 | mc=$make_conf | |
1215 | test -f $mc || echo "$mc: does not exist" | |
1216 | done | |
1217 | ||
1218 | # Back up original Configuration file | |
1219 | backup=$make_conf.BEFOREAFS | |
1220 | number=0 | |
1221 | while [ -f $backup ] | |
1222 | do | |
1223 | backup=$make_conf.BEFOREAFS.$number | |
1224 | number=$(($number+1)) | |
1225 | done | |
1226 | ||
1227 | $cp -p $make_conf $backup | |
1228 | ||
1229 | ( do_config_makefile $make_conf ) | |
1230 | ||
1231 | case $? in | |
1232 | 0) echo "Configured $make_conf successfully";; | |
1233 | *) $mv -f $backup $make_conf ; | |
1234 | die "Configuration for Makefile FAILED: Exiting" ;; | |
1235 | esac | |
1236 | ||
1237 | ConfigScript=$ConfigScript_default | |
1238 | val=Y | |
1239 | echo $ac_n "Run Configuration script ($ConfigScript):"\ | |
1240 | " [$val] $ac_c" | |
1241 | read i | |
1242 | test $i && val=$i | |
1243 | if [ $val = Y ] || [ $val = y ] | |
1244 | then | |
1245 | while [[ ! -x ${make_conf_dir}/${ConfigScript} ]] | |
1246 | do | |
1247 | echo "$ConfigScript: not found or not "\ | |
1248 | "executable in $make_conf_dir" | |
1249 | echo $ac_n "Enter Configure script name"\ | |
1250 | ":[$ConfigScript]$ac_c" | |
1251 | read in | |
1252 | test $in && ConfigScript=$in | |
1253 | done | |
1254 | ||
1255 | ( cd $make_conf_dir; ./$ConfigScript -file $make_conf ) | |
1256 | ||
1257 | case $? in | |
1258 | 0) echo "Configuration successful";; | |
1259 | *) die "Configuration FAILED - Exiting";; | |
1260 | esac | |
1261 | fi | |
1262 | ||
1263 | # Before compiling - check afs_module is in appropriate directory | |
1264 | if [ $apache_version = 1.3 ] | |
1265 | then | |
1266 | sd=${Apache_src}/modules/extra/afs_module.c | |
1267 | else | |
1268 | sd=${Apache_src}/afs_module.c | |
1269 | fi | |
1270 | while [ ! -f $sd ] | |
1271 | do | |
1272 | echo "File $sd does not exist" | |
1273 | val=`pwd`/afs_module.c | |
1274 | while [ ! -f $val ] | |
1275 | do | |
1276 | echo $ac_n "Enter the location of the source file afs_module.c that came with the $PRODUCT_NAME distribution [ $val ] $ac_c" | |
1277 | read in | |
1278 | test $in && val=$in | |
1279 | done | |
1280 | echo "Copying $val to $sd" | |
1281 | cp -p $val $sd | |
1282 | done | |
1283 | ||
1284 | val=Y | |
1285 | echo $ac_n "Compile: [$val] $ac_c" | |
1286 | read i | |
1287 | test $i && val=$i | |
1288 | if [ $val = Y ] || [ $val = y ] | |
1289 | then | |
1290 | ( cd $Apache_src ; make ) | |
1291 | test $? != 0 && die "ERROR: make failed" | |
1292 | echo "Successful compilation." | |
1293 | echo "NOTE: If necessary do a make install after this script finishes" | |
1294 | fi | |
1295 | fi | |
1296 | } | |
1297 | ||
1298 | configure_runtime_forwebsecure() | |
1299 | { | |
1300 | rc=' ' | |
1301 | run_conf_dir=${run_conf%/*} | |
1302 | while [[ ! -f $rc ]] | |
1303 | do | |
1304 | echo $ac_n "Run time configuration file name "\ | |
1305 | "[$run_conf]:$ac_c" | |
1306 | read uconf | |
1307 | case $uconf in | |
1308 | '') ;; | |
1309 | /*) run_conf=$uconf ; | |
1310 | run_conf_dir=${run_conf%/*}; | |
1311 | ;; | |
1312 | *) run_conf=${run_conf_dir}/${uconf}; | |
1313 | run_conf_dir=${run_conf%/*}; | |
1314 | ;; | |
1315 | esac | |
1316 | rc=$run_conf | |
1317 | test -f $rc || echo "$rc: does not exist" | |
1318 | done | |
1319 | ||
1320 | # Back up original Configuration file | |
1321 | backup=$run_conf.BEFOREAFS | |
1322 | number=0 | |
1323 | while [ -f $backup ] | |
1324 | do | |
1325 | backup=$run_conf.BEFOREAFS.$number | |
1326 | number=$(($number+1)) | |
1327 | done | |
1328 | ||
1329 | $cp -p $run_conf $backup | |
1330 | ||
1331 | tempfile=/tmp/$prog.$$ | |
1332 | #( do_run_time $run_conf $tempfile ) | |
1333 | ( do_run_time $run_conf ) | |
1334 | case $? in | |
1335 | 0) echo "Run time configuration complete."\ | |
1336 | " File $run_conf" ;; | |
1337 | 10) $rm -f $backup; | |
1338 | echo "Run-Time configuration not required" ;; | |
1339 | *) $rm -f $tempfile; | |
1340 | mv -f $backup $run_conf; | |
1341 | die "RUN_TIME CONFIGURATION FAILED";; | |
1342 | esac | |
1343 | # fi | |
1344 | } | |
1345 | ||
1346 | ||
1347 | ||
1348 | unconfigure() | |
1349 | { | |
1350 | if [ -f $Apache_src/*.BEFOREAFS* ] | |
1351 | then | |
1352 | eg=`grep "mod_afs.o" $Apache_src/*` | |
1353 | case $eg in | |
1354 | '') ;; | |
1355 | *) | |
1356 | echo "Found backup config file for Makefile Configuration" ; | |
1357 | /bin/ls -l $Apache_src/*.BEFORE* ; | |
1358 | echo "You may have a previously installed version of AFS WebSecure" ; | |
1359 | echo "This may conflict with installing this version." ; | |
1360 | echo "Please restore all the configuration files to the state they" \ | |
1361 | "were before WebSecure was installed. " \ | |
1362 | "Remove *.BEFOREAFS* in the Apachesrc directory and re-run this script"; | |
1363 | die "Exiting..." | |
1364 | ;; | |
1365 | esac | |
1366 | fi | |
1367 | ||
1368 | if [ -f $ServerRoot/conf/*.BEFOREAFS* ] | |
1369 | then | |
1370 | eg=`grep -i setafslocation $ServerRoot/conf/*` | |
1371 | case $eg in | |
1372 | '') ;; | |
1373 | *) echo "Found backup for run-time configuration" ; | |
1374 | /bin/ls -l $ServerRoot/conf/*.BEFOREAFS* | |
1375 | echo "You may have a previously installed version of AFS WebSecure" | |
1376 | echo "Please restore all the configuration files to the state " \ | |
1377 | "they were before WebSecure was installed. " \ | |
1378 | "Remove *.BEFOREAFS* in the Apache conf directory " \ | |
1379 | "and re-run this script." ; | |
1380 | die "Exiting ... " ;; | |
1381 | *) ;; | |
1382 | esac | |
1383 | fi | |
1384 | } | |
1385 | ||
1386 | ||
1387 | install_web_secure() | |
1388 | { | |
1389 | product_version=1.0 | |
1390 | unconfigure | |
1391 | ||
1392 | configure_makefile_forwebsecure | |
1393 | configure_runtime_forwebsecure | |
1394 | echo "$product Configuration Complete" | |
1395 | } | |
1396 | ||
1397 | ||
1398 | make_start_stop() | |
1399 | { | |
1400 | A="Create new Startup Script" | |
1401 | B="Create new ShutDown Script" | |
1402 | C="Edit existing Shutdown Script to shutdown AFS Web Secure" | |
1403 | ||
1404 | select c in "$A" "$B" "$C" | |
1405 | do | |
1406 | case $c in | |
1407 | $A) echo $ac_n "Full path to webserver binary:"\ | |
1408 | " [$binary]$ac_c" ; | |
1409 | read in; | |
1410 | test $in && binary=$in; | |
1411 | if [ ! -x $binary ] | |
1412 | then | |
1413 | echo; echo | |
1414 | echo "$binary does not exist" | |
1415 | echo "Check the path or compile Apache first" | |
1416 | return | |
1417 | fi | |
1418 | echo $ac_n "Full path to new script: [$startscr]$ac_c"; | |
1419 | read in; | |
1420 | test $in && startscr=$in; | |
1421 | if [ -x $startscr ] | |
1422 | then | |
1423 | die "$startscr already exists. Exiting" | |
1424 | fi; | |
1425 | ( do_start_stop START $startscr $binary ); | |
1426 | break | |
1427 | ;; | |
1428 | $B) echo $ac_n "Full path to new script:[$stopscr] $ac_c"; | |
1429 | read in; | |
1430 | test $in && stopscr=$in; | |
1431 | if [ -x $stopscr ] | |
1432 | then | |
1433 | die "$stopscr already exists. Exiting" | |
1434 | fi; | |
1435 | ( do_start_stop STOP $stopscr $run_conf ); | |
1436 | break | |
1437 | ;; | |
1438 | $C) echo $ac_n "Existing script:[$stopscr] $ac_c"; | |
1439 | read in; | |
1440 | test $in && stopscr=$in; | |
1441 | if [ ! -x $stopscr ] | |
1442 | then | |
1443 | die "$stopscr doesn't exist. Exiting" | |
1444 | fi; | |
1445 | ( do_start_stop E_STOP $stopscr $run_conf ); | |
1446 | break | |
1447 | ;; | |
1448 | esac | |
1449 | done | |
1450 | ||
1451 | ret=$? | |
1452 | if [ $ret -eq 0 ] | |
1453 | then | |
1454 | echo "Done" | |
1455 | else | |
1456 | die "ERROR: Editing Start and Stop scripts. Exiting" | |
1457 | fi | |
1458 | } | |
1459 | ||
1460 | start_apache() | |
1461 | { | |
1462 | val=Y | |
1463 | echo $ac_n "Start up the server: [$val] $ac_c" | |
1464 | read in | |
1465 | test $in && val=$in | |
1466 | if [ $val = Y ] || [ $val = y ] | |
1467 | then | |
1468 | exec $startscr | |
1469 | fi | |
1470 | } | |
1471 | ||
1472 | ||
1473 | ||
1474 | main() | |
1475 | { | |
1476 | ||
1477 | if [ $firsttime = 0 ] | |
1478 | then | |
1479 | firsttime=1 | |
1480 | clear | |
1481 | else | |
1482 | prompt=M | |
1483 | echo; echo; echo; echo | |
1484 | echo | awk '{ for (i=0; i < 80; i++) { printf "-" } }' | |
1485 | echo | |
1486 | echo $ac_n "Main menu (M) or Exit (X): [$prompt] $ac_c" | |
1487 | read in | |
1488 | test $in && prompt=$in | |
1489 | test $prompt = 'X' || test $prompt = 'x' && exit 0; | |
1490 | fi | |
1491 | init_prompt | |
1492 | echo; echo; echo | |
1493 | ||
1494 | A="AFS Web Secure Setup" | |
1495 | E="Make or Edit start and stop scripts" | |
1496 | F="Start up Apache Server" | |
1497 | G="Exit" | |
1498 | ||
1499 | select choice in "$A" "$E" "$F" "$G" | |
1500 | do | |
1501 | case $choice in | |
1502 | $A) install_web_secure ;; | |
1503 | $E) make_start_stop ;; | |
1504 | $F) start_apache ;; | |
1505 | $G) exit 0 ;; | |
1506 | esac | |
1507 | break | |
1508 | done | |
1509 | } | |
1510 | ||
1511 | welcome_screen() | |
1512 | { | |
1513 | echo; echo; echo; echo | |
1514 | init_prompt | |
1515 | echo "Thank you for downloading $PRODUCT_NAME for Apache." | |
1516 | echo "This script will help you install this product." | |
1517 | echo "Please read the documentation accompanying this product before continuing." | |
1518 | echo "Also ensure that you have installed the source files, " | |
1519 | echo "libraries and binaries in the recommended directories" | |
1520 | echo | |
1521 | echo "Contact $COMPANY for licensing information" | |
1522 | echo "11 Stanwix Street" | |
1523 | echo "Pittsburgh, PA 15222" | |
1524 | ||
1525 | echo | |
1526 | val=Y; echo $ac_n "Continue? [$val] $ac_c" | |
1527 | read in ; test $in && val=$in | |
1528 | case $val in | |
1529 | Y|y) clear ; break ;; | |
1530 | *) echo "Exiting $prog" ; exit 0 ;; | |
1531 | esac | |
1532 | ||
1533 | echo "$message" | more | |
1534 | echo | |
1535 | ||
1536 | val=Y; echo $ac_n "Continue? [$val] $ac_c" | |
1537 | read in ; test $in && val=$in | |
1538 | case $val in | |
1539 | Y|y) clear; break ;; | |
1540 | *) exit 0;; | |
1541 | esac | |
1542 | } | |
1543 | ||
1544 | ############################################################################# | |
1545 | ## | |
1546 | ## HERE IS WHERE IT ACTUALL STARTS | |
1547 | ## | |
1548 | ############################################################################ | |
1549 | ||
1550 | ||
1551 | #setting the nonew line stuff | |
1552 | case `echo -n` in | |
1553 | -n) ac_n= ; ac_c='\c' ;; | |
1554 | *) ac_n='-n' ; ac_c= ;; | |
1555 | esac | |
1556 | ||
1557 | case $show_welcome in | |
1558 | 1) ;; | |
1559 | *) welcome_screen ;; | |
1560 | esac | |
1561 | ||
1562 | ## | |
1563 | ## Initialize parameters to defaults | |
1564 | ## | |
1565 | ServerRoot=$ServerRoot_default | |
1566 | sr=' ' | |
1567 | until [[ -d $sr ]] | |
1568 | do | |
1569 | echo $ac_n "Enter Server Root directory: [$ServerRoot] $ac_c" | |
1570 | read in | |
1571 | case $in in | |
1572 | '') ;; | |
1573 | *) ServerRoot=$in | |
1574 | ;; | |
1575 | esac | |
1576 | test -d $ServerRoot || echo "$ServerRoot: No such directory" | |
1577 | sr=$ServerRoot | |
1578 | done | |
1579 | test $in && change_default ServerRoot_default $ServerRoot | |
1580 | ||
1581 | Apache_src=$Apache_src_default | |
1582 | as=' ' | |
1583 | until [[ -d $as ]] | |
1584 | do | |
1585 | ||
1586 | echo $ac_n "Enter Apache src directory: [$Apache_src] $ac_c" | |
1587 | read in | |
1588 | case $in in | |
1589 | '') ;; | |
1590 | *) Apache_src=$in | |
1591 | ;; | |
1592 | esac | |
1593 | test -d $Apache_src || echo "$Apache_src: No such directory" | |
1594 | as=$Apache_src | |
1595 | done | |
1596 | echo | |
1597 | test $in && change_default Apache_src_default $Apache_src | |
1598 | ||
1599 | ||
1600 | make_conf=$Apache_src/$make_conf_default | |
1601 | run_conf=$ServerRoot/conf/$run_conf_default | |
1602 | binary=$ServerRoot/$binary_default | |
1603 | startscr=$ServerRoot/$startscr_default | |
1604 | stopscr=$ServerRoot/$stopscr_default | |
1605 | DocRoot=$ServerRoot/$DocRoot_default | |
1606 | ||
1607 | firsttime=0 | |
1608 | ||
1609 | ## | |
1610 | ## Determine which version of Apache this is | |
1611 | ## default to 1.3 since that is what everyone should be running! | |
1612 | ## | |
1613 | apache_version=1.3 | |
1614 | if [ ! -d $Apache_src/modules/standard ] | |
1615 | then | |
1616 | ## prompt user to confirm Apache 1.2 | |
1617 | echo $ac_n "Is this Apache 1.2.X?: [N] $ac_c" | |
1618 | read n | |
1619 | case $n in | |
1620 | y|Y) apache_version=1.2;; | |
1621 | esac | |
1622 | fi | |
1623 | ||
1624 | echo "Apache Version: $apache_version" >> $Log | |
1625 | ||
1626 | echo `date` >> $Log | |
1627 | while true | |
1628 | do | |
1629 | main | |
1630 | done | |
1631 | ||
1632 | ||
1633 | ||
1634 | ||
1635 | ||
1636 | ||
1637 | ||
1638 | ||
1639 | ||
1640 |