3 # A command line interface to execute the installation of OpenAFS.
5 # openafs-tools, Version 1.2.2
7 # Copyright 2001, International Business Machines Corporation and others.
10 # This software has been released under the terms of the IBM Public
11 # License. For details, see the LICENSE file in the top-level source
12 # directory or online at http://www.openafs.org/dl/license10.html
15 afscodeDir=/usr/afs/tools/install/
25 if [ $1 = "help" ]; then
27 echo -e "OpenAFS Installation for Linux: Help Mode\n"
28 echo -e "The command install_afs takes the following optional arguments. If any\nneeded information is not provided on the command line, it will be\nprompted for the user to input.\n"
29 echo -e "\t-machineName (or -m) name: where name specifies\n\t the name of the machine the command is being run on"
30 echo -e "\t-cellName (or -c) cell: where cell specifies the\n\t name of the home cell of this machine"
31 echo -e "\t-shortCell (or -s) scell: where scell is the shortcut\n\t name desired for the home cell. Ignored if this\n\t is not the first server"
32 echo -e "\t-hardDrive (or -h) hd: where hd is the device name on\n\t which to mount the first AFS partition. Ignored if this\n\t is not a server"
33 echo -e "\t-serverType (or -st) type: where type can be \"first\",\n\t \"additional\", or \"not\", specifying whether this is\n\t to be the first server in a cell, an additional server\n\t for the cell, or not a server at all"
34 echo -e "\t-clientType (or -ct) type: where type can be \"client\"\n\t or \"not\", specifying whether this machine is to be an\n\t AFS client or not"
35 echo -e "\t-adminPassword (or -p) password: the administrative\n\t password of the cell. Ignored if this is not a server"
36 echo -e "\t-existingServer (or -e) name: the name of an\n\t existing server already in the cell. Ignored if\n\t this is not an additional server"
37 echo -e "\t-scriptDirectory (or -d) name: the name of the\n\t directory containing these OpenAFS installation\n\t scripts"
38 echo -e "\t-noConf (or -n): Do not ask for confirmation before\n\t performing the installation."
39 echo -e "\thelp: Display this help dialogue"
45 # Check the state file to ensure AFS is not installed already
46 if [ -r $afscodeDir/.afs_state ]; then
47 read state < $afscodeDir/.afs_state
48 if [ $state = "Install" ]; then
49 echo -e "You have already run the OpenAFS installation program. You must uninstall OpenAFS before you install it again."
54 while [ $# -gt 0 ]; do
60 if [ $flag != "-noConf" -a $flag != "-n" ]; then
69 # if the value is empty
71 echo -e No value given to $flag flag. Use \"install_afs help\" for syntax.
74 # if the value is a flag
75 if [ -z ${val##-*} ]; then
76 echo -e No value given to $flag flag. Use \"install_afs help\" for syntax.
80 if [ $flag = "-machineName" -o $flag = "-m" ]; then
83 if [ $flag = "-cellName" -o $flag = "-c" ]; then
86 if [ $flag = "-shortCell" -o $flag = "-s" ]; then
89 if [ $flag = "-hardDrive" -o $flag = "-h" ]; then
92 if [ $flag = "-scriptDirectory" -o $flag = "-d" ]; then
95 if [ $flag = "-serverType" -o $flag = "-st" ]; then
97 if [ $val = "first" ]; then
98 serverType=$firstServer
99 else if [ $val = "additional" ]; then
100 serverType=$addServer
101 else if [ $val = "not" ]; then
102 serverType=$notServer
104 echo -e Invalid value for -serverType flag. Use \"install_afs help\" for syntax.
109 if [ $flag = "-clientType" -o $flag = "-ct" ]; then
111 if [ $val = "client" ]; then
113 else if [ $val = "not" ]; then
114 clientType=$notClient
116 echo -e Invalid value for $flag flag. Use \"install_afs help\" for syntax.
121 if [ $flag = "-adminPassword" -o $flag = "-p" ]; then
124 if [ $flag = "-existingServer" -o $flag = "-e" ]; then
127 if [ $flag = "-noConf" -o $flag = "-n" ]; then
130 echo Invalid flag $flag. Use \"install_afs help\" for syntax.
132 fi fi fi fi fi fi fi fi fi fi
135 # Collect variables not given:
138 while [ -z $server ]; do
139 echo -ne "Provide the server type for this machine (\"first\", \"additional\", or \"not\"),\n or hit enter to accept the default (\"first\"): "
142 if [ -z $server ]; then
146 if [ $server = "first" ]; then
147 serverType=$firstServer
148 else if [ $server = "additional" ]; then
149 serverType=$addServer
150 else if [ $server = "not" ]; then
151 serverType=$notServer
153 echo -e Invalid value for server type. Please choose \"first\", \"additional\", or \"not\".
159 while [ -z $client ]; do
160 echo -ne "Provide the client type for this machine (\"client\" or \"not\"), or hit enter to\n accept the default (\"client\"): "
163 if [ -z $client ]; then
167 if [ $client = "client" ]; then
169 else if [ $client = "not" ]; then
170 clientType=$notClient
172 echo -e Invalid value for client type. Please choose \"client\" or \"not\".
178 if [ $serverType -eq $notServer ]; then
179 if [ $clientType -eq $notClient ]; then
180 echo -e "This machine must be either a server or a client."
185 while [ -z $cellName ]; do
186 echo -ne "Provide the name of the cell (in the form of cellname.domainname):\n "
190 while [ -z $machineName ]; do
191 read default < /etc/HOSTNAME
192 echo -ne "Provide the name of this machine, or hit enter to accept the\n default ($default): "
195 if [ -z $machineName ]; then
201 if [ $serverType -ne $notServer ]; then
203 while [ -z $hardDrive ]; do
204 echo -ne "Provide the name of the device on which to mount the AFS partition,\n i.e. hda5: "
210 if [ $serverType -eq $firstServer ]; then
212 while [ -z $shortCell ]; do
213 default=${cellName%%.*}
214 echo -ne "Provide a shortcut name for your cell, or press Enter to accept the\n default ($default): "
217 if [ -z $shortCell ]; then
225 if [ $serverType -eq $addServer ]; then
227 while [ -z $existingServer ]; do
228 echo -ne "Provide the name of the first server in this cell:\n "
234 while [ -z $scriptDir ]; do
236 echo -ne "Provide the directory of this installation script, or press Enter to accept\n the default ($default): "
239 if [ -z $scriptDir ]; then
245 if [ $serverType -ne $notServer ]; then
246 while [ -z $adminPassword ]; do
247 echo -ne "Provide the administrative password of this cell: "
251 echo -ne "Please confirm the password: "
256 if [ -z $adminPassword ]; then
257 echo -e "You must give a password"
259 if [ -z $adminPassword2 ]; then
260 echo -e "You must confirm the password"
263 if [ $adminPassword != $adminPassword2 ]; then
264 echo -e "Passwords do not match"
270 # Make sure the needed files exist:
271 if [ $serverType -eq $addServer ]; then
272 while [ ! -e $scriptDir/afs/ -o ! -e $scriptDir/afs/ThisCell -o ! -e $scriptDir/afs/CellServDB -o ! -e $scriptDir/afs/KeyFile -o ! -e $scriptDir/afs/UserList ]; do
273 echo -e "Needed files in $scriptDir/afs do not exist."
274 echo -e "Copy the following files from $existingServer to the specified locations:"
275 echo -e "- $existingServer:/usr/afs/etc/ThisCell to $machineName:$scriptDir/afs/ThisCell"
276 echo -e "- $existingServer:/usr/afs/etc/CellServDB to $machineName:$scriptDir/afs/CellServDB"
277 echo -e "- $existingServer:/usr/afs/etc/KeyFile to $machineName:$scriptDir/afs/KeyFile"
278 echo -e "- $existingServer:/usr/afs/etc/UserList to $machineName:$scriptDir/afs/UserList"
279 echo -e "- $existingServer:/usr/vice/etc/CellServDB to $machineName:$scriptDir/vice/CellServDB"
280 echo -e "Press Enter when ready"
284 if [ $serverType -ne $firstServer ]; then
285 while [ ! -e $scriptDir/vice/ -o ! -e $scriptDir/vice/CellServDB ]; do
286 echo "Needed file in $scriptDir/vice does not exist."
287 echo -e "Copy the following file from an existing server to the specified location:"
288 echo -e "- CellServDB from $cellName to $machineName:$scriptDir/vice/CellServDB"
289 echo -e "Press Enter when ready"
294 echo -e "You're about to install OpenAFS with the following configuration:"
295 echo -e "Machine name: $machineName"
296 echo -e "Cell name: $cellName"
297 if [ $serverType -eq $firstServer ]; then
298 echo -e "Shortcut cell name: $shortCell"
300 if [ $serverType -ne $notServer ]; then
301 echo -e "Hard drive: $hardDrive"
302 echo -ne "adminPassword: "
304 while [ $i -lt ${#adminPassword} ]; do
310 echo -e "Server: $server"
311 echo -e "Client: $client"
312 if [ $serverType -eq $addServer ]; then
313 echo -e "Existing server: $existingServer"
315 echo -e "Script directory: $scriptDir"
317 if [ -z $noConf ]; then
318 echo -ne "Would you like to continue with the installation? "
319 while [ -z $goAhead ]; do
323 if [ -z $goAhead ]; then
326 if [ $goAhead = "n" ]; then
327 echo -e "Aborting installation"
330 if [ $goAhead != "y" ]; then
337 #Start the installation
339 # the directory on which the hard drive partition will be mounted:
343 # the password for the afs account:
344 afsPassword=$adminPassword
346 # Make sure the needed files exist:
347 if [ $serverType -eq $addServer ]; then
348 if [ ! -e $scriptDir/afs/ ]; then
349 echo "Needed directory $scriptDir/afs does not exist. Aborting."
352 if [ ! -e $scriptDir/afs/ThisCell ]; then
353 echo "Needed file $scriptDir/afs/ThisCell does not exist. Aborting."
356 if [ ! -e $scriptDir/afs/CellServDB ]; then
357 echo "Needed file $scriptDir/afs/CellServDB does not exist. Aborting."
360 if [ ! -e $scriptDir/afs/KeyFile ]; then
361 echo "Needed file $scriptDir/afs/KeyFile does not exist. Aborting."
364 if [ ! -e $scriptDir/afs/UserList ]; then
365 echo "Needed file $scriptDir/afs/UserList does not exist. Aborting."
369 if [ $serverType -ne $firstServer ]; then
370 if [ ! -e $scriptDir/vice/ ]; then
371 echo "Needed directory $scriptDir/vice does not exist. Aborting."
374 if [ ! -e $scriptDir/vice/CellServDB ]; then
375 echo "Needed file $scriptDir/vice/CellServDB does not exist. Aborting."
379 # Write to the state file
380 echo "Install" > $scriptDir/.afs_state
381 echo "begin" >> $scriptDir/.afs_state
385 if [ $clientType -eq $isClient ]; then
386 echo Configuring /etc/pam.d/login
387 perl $scriptDir/write_pam.pl enable
389 echo ln -s pam_afs.so.1 pam_afs.so
390 ln -s pam_afs.so.1 pam_afs.so
393 # Remove files installed by OpenAFS rpms that are intrusive
394 echo "Removing troublesome files"
395 rm -f /usr/vice/etc/ThisCell
396 rm -f /usr/vice/etc/CellServDB
398 if [ $serverType -ne $notServer ]; then
400 echo Configuring /etc/fstab
401 perl $scriptDir/write_fstab.pl $hardDrive $partition
405 echo Starting the BOS server
406 mkdir -p /usr/afs/etc
407 if [ $serverType -eq $addServer ]; then
408 # Move the needed file to /usr/afs/etc
409 echo Copying /usr/afs/etc/ files for additional server
410 cp -f $scriptDir/afs/ThisCell /usr/afs/etc/
411 cp -f $scriptDir/afs/CellServDB /usr/afs/etc/
412 cp -f $scriptDir/afs/KeyFile /usr/afs/etc/
413 cp -f $scriptDir/afs/UserList /usr/afs/etc/
416 if [ $serverType -eq $firstServer ]; then
418 echo /usr/afs/bin/bosserver -noauth
419 /usr/afs/bin/bosserver -noauth
420 echo bos setcellname $machineName $cellName -noauth
421 bos setcellname $machineName $cellName -noauth
422 echo bos listhosts $machineName -noauth
423 bos listhosts $machineName -noauth
424 echo bos addkey $machineName -key $afsPassword -kvno 0 -cell $cellName -noauth
425 bos addkey $machineName -key $afsPassword -kvno 0 -cell $cellName -noauth
427 echo bos shutdown $machineName -noauth
428 bos shutdown $machineName -noauth
429 bosserver_process=$(ps -Ao pid,cmd | grep boss)
430 echo kill ${bosserver_process%% /*}
431 kill ${bosserver_process%% /*}
433 /usr/afs/bin/kaserver -noauth &
435 echo Configuring kaserver
436 kas create afs -initial_password $afsPassword -cell $cellName -noauth
437 kas examine -name afs -cell $cellName -noauth
438 kas create admin -initial_password $adminPassword -cell $cellName -noauth
439 kas setfields admin -flags admin -cell $cellName -noauth
440 kas examine -name admin -cell $cellName -noauth
442 kaserver_process=$(ps -Ao pid,cmd | grep kaserver)
443 echo kill ${kaserver_process%% /*}
444 kill ${kaserver_process%% /*}
446 echo Bootstrapping ptserver
447 echo -e "admin 128/20 1 -204 -204\nsystem:administrators 130/20 -204 -204 -204\n admin 1\n" | pt_util -p /usr/afs/db/prdb.DB0 -w
451 /usr/afs/bin/bosserver
453 if [ $serverType -ne $firstServer ]; then
454 # Define the upclients
455 echo bos create $machineName upclientetc simple "/usr/afs/bin/upclient $existingServer /usr/afs/etc" -cell $cellName -localauth
456 bos create $machineName upclientetc simple "/usr/afs/bin/upclient $existingServer /usr/afs/etc" -cell $cellName -localauth
457 echo bos create $machineName upclientbin simple "/usr/afs/bin/upclient $existingServer -clear /usr/afs/bin" -cell $cellName -localauth
458 bos create $machineName upclientbin simple "/usr/afs/bin/upclient $existingServer -clear /usr/afs/bin" -cell $cellName -localauth
463 if [ $serverType -eq $firstServer ]; then
465 echo Starting the Database Server Processes
467 echo bos create -server $machineName -instance kaserver -type simple -cmd /usr/afs/bin/kaserver -cell $cellName -localauth
468 bos create -server $machineName -instance kaserver -type simple -cmd /usr/afs/bin/kaserver -cell $cellName -localauth
469 echo bos create -server $machineName -instance buserver -type simple -cmd /usr/afs/bin/buserver -cell $cellName -localauth
470 bos create -server $machineName -instance buserver -type simple -cmd /usr/afs/bin/buserver -cell $cellName -localauth
471 echo bos create -server $machineName -instance ptserver -type simple -cmd /usr/afs/bin/ptserver -cell $cellName -localauth
472 bos create -server $machineName -instance ptserver -type simple -cmd /usr/afs/bin/ptserver -cell $cellName -localauth
473 echo bos create -server $machineName -instance vlserver -type simple -cmd /usr/afs/bin/vlserver -cell $cellName -localauth
474 bos create -server $machineName -instance vlserver -type simple -cmd /usr/afs/bin/vlserver -cell $cellName -localauth
476 echo bos adduser $machineName admin -cell $cellName -localauth
477 bos adduser $machineName admin -cell $cellName -localauth
478 echo bos restart $machineName -all -cell $cellName -localauth
479 bos restart $machineName -all -cell $cellName -localauth
483 if [ $serverType -ne $notServer ]; then
484 echo Starting the File Server, Volume Server, and Salvager
486 echo bos create $machineName fs fs /usr/afs/bin/fileserver /usr/afs/bin/volserver /usr/afs/bin/salvager -cell $cellName -localauth
487 bos create $machineName fs fs /usr/afs/bin/fileserver /usr/afs/bin/volserver /usr/afs/bin/salvager -cell $cellName -localauth
488 # Verify success of fs:
489 echo bos status $machineName fs -long -localauth
490 bos status $machineName fs -long -localauth
492 if [ $serverType -eq $firstServer ]; then
493 # Wait for Ubik to elect a quorum
494 echo Waiting for a quorum election . . .
495 perl $scriptDir/check_udebug.pl $machineName
496 echo vos create $machineName $partition root.afs -cell $cellName -localauth
497 vos create $machineName $partition root.afs -cell $cellName -localauth
500 vos syncvldb $machineName -cell $cellName -verbose -localauth
501 vos syncserv $machineName -cell $cellName -verbose -localauth
505 if [ $serverType -eq $firstServer ]; then
506 echo Starting the Server Portion of the Update Server
508 echo bos create $machineName upserver simple "/usr/afs/bin/upserver -crypt /usr/afs/etc -clear /usr/afs/bin" -cell $cellName -localauth
509 bos create $machineName upserver simple "/usr/afs/bin/upserver -crypt /usr/afs/etc -clear /usr/afs/bin" -cell $cellName -localauth
514 # Installing Client Functionality
516 echo Defining Cell Membership for Client Processes
518 if [ $serverType -eq $notServer ]; then
519 echo $cellName > /usr/vice/etc/ThisCell
522 echo Creating the Client CellServDB File
525 if [ $serverType -ne $firstServer ]; then
526 # Move the CellServDB file to /usr/vice/etc
527 cp -f $scriptDir/vice/CellServDB /usr/vice/etc
530 # copy correct afs setup file to etc/sysconfig
531 if [ $serverType -eq $notServer ]; then
532 cp -f $scriptDir/afsinit_client /etc/sysconfig/afs
534 cp -f $scriptDir/afsinit_both /etc/sysconfig/afs
537 # Overview: Completing the Installation of the First AFS Machine
539 echo Verifying the AFS Initialization Script
541 if [ $serverType -ne $notServer ]; then
542 echo bos shutdown $machineName -localauth
543 bos shutdown $machineName -localauth
544 bosserver_process=$(ps -Ao pid,cmd | grep boss)
545 echo kill ${bosserver_process%% /*}
546 kill ${bosserver_process%% /*}
550 echo Continuing with Verifying ths AFS Initialization Script
552 echo /etc/rc.d/init.d/afs start
553 /etc/rc.d/init.d/afs start
554 if [ $serverType -ne $notServer ]; then
556 echo klog admin -password
557 klog admin -password $adminPassword
558 # verify klog worked correctly:
561 # verify each process is running normally:
562 echo bos status $machineName
563 bos status $machineName
569 echo Activating the AFS Initialization Script
571 echo /sbin/chkconfig --add afs
572 /sbin/chkconfig --add afs
575 ln -s /etc/rc.d/init.d/afs afs.rc
576 ln -s /etc/sysconfig/afs afs.conf
578 if [ $serverType -eq $firstServer ]; then
579 echo Configuring the Top Levels of the AFS Filespace
581 # Wait for Ubik to elect a quorum
582 echo Waiting for a quorum election . . .
583 perl $scriptDir/check_udebug.pl $machineName
585 echo fs setacl /afs system:anyuser rl
586 fs setacl /afs -acl system:anyuser rl
587 echo vos create $machineName $partition root.cell
588 vos create $machineName $partition root.cell
589 echo fs mkmount /afs/$cellName root.cell
590 fs mkmount /afs/$cellName root.cell
591 echo fs setacl /afs/$cellName system:anyuser rl
592 fs setacl /afs/$cellName -acl system:anyuser rl
594 ln -s $cellName $shortCell
595 echo fs mkmount /afs/.$cellName root.cell -rw
596 fs mkmount /afs/.$cellName root.cell -rw
599 echo Stopping the client to replicate
602 /usr/vice/etc/afsd -shutdown
604 echo vos addsite $machineName $partition root.afs -localauth
605 vos addsite $machineName $partition root.afs -localauth
606 echo vos addsite $machineName $partition root.cell -localauth
607 vos addsite $machineName $partition root.cell -localauth
608 echo vos release root.afs -localauth
609 vos release root.afs -localauth
610 echo vos release root.cell -localauth
611 vos release root.cell -localauth
613 /etc/rc.d/init.d/afs stop
614 # start the client again
615 echo Starting client again
616 /etc/rc.d/init.d/afs start
620 echo klog admin -password
621 klog admin -password $adminPassword
623 # Wait for Ubik to elect a quorum
624 echo Waiting for a quorum election . . .
625 perl $scriptDir/check_udebug.pl $machineName
629 echo fs examine /afs/$cellName
630 fs examine /afs/$cellName
637 if [ $clientType -ne $isClient ]; then
639 echo Removing Client Functionality
641 # Install correct config file
642 cp -f $scriptDir/afsinit_server /etc/sysconfig/afs
645 ln -fs /usr/afs/etc/ThisCell ThisCell
646 ln -fs /usr/afs/etc/CellServDB CellServDB
648 /etc/rc.d/init.d/afs stop
649 /etc/rc.d/init.d/afs start
655 # Write the done file
656 echo "Here is a summary of what was done:<br><ul>" > $scriptDir/done.txt
657 if [ $serverType -eq $firstServer ]; then
658 echo "<li>Configured $machineName as the first server to the cell $cellName</li>" >> $scriptDir/done.txt
659 echo "<li>Created the server processes (vlserver, buserver, kaserver, and ptserver)</li>" >> $scriptDir/done.txt
660 echo "<li>Created /vicepa as a server partition</li>" >> $scriptDir/done.txt
661 echo "<li>Created an admin account</li>" >> $scriptDir/done.txt
662 echo "<li>Mounted a read-write version of root.cell at /afs/.$cellName</li>" >> $scriptDir/done.txt
664 if [ $serverType -eq $addServer ]; then
665 echo "<li>Configured $machineName as an additional server to the cell $cellName</li>" >> $scriptDir/done.txt
666 echo "<li>Created the update processes, using $existingServer as the first server</li>" >> $scriptDir/done.txt
667 echo "<li>Created /vicepa as a server partition</li>" >> $scriptDir/done.txt
669 if [ $clientType -eq $isClient ]; then
670 echo "<li>Configured $machineName as a client to the cell $cellName</li>" >> $scriptDir/done.txt
672 echo "</ul><br>" >> $scriptDir/done.txt
673 if [ $serverType -eq $firstServer ]; then
674 echo "<br>Here are some suggestions about how to get started using your cell:<br><ul>" >> $scriptDir/done.txt
675 echo "<li>Read the <a href=\"http://oss.software.ibm.com/developerworks/opensource/afs/docs.html\">OpenAFS documentation</a></li>" >> $scriptDir/done.txt
676 echo "<li>Create users for your cell</li>" >> $scriptDir/done.txt
677 echo "<li>Create volumes</li>" >> $scriptDir/done.txt
678 echo "<li>Configure other machines to be additional servers for this cell</li>" >> $scriptDir/done.txt
679 echo "<li>Make another partition (i.e. /vicepb) on which to store volumes</li>" >> $scriptDir/done.txt
680 echo "<li>Mount other cells in root.afs</li>" >> $scriptDir/done.txt
681 echo "</ul>" >> $scriptDir/done.txt
683 # Write the state file
684 echo "Install" > $scriptDir/.afs_state
685 echo "complete" >> $scriptDir/.afs_state