Standardize License information
[openafs.git] / src / afsinstall / lib / InstallGuides / GENERIC / clientconfig
1 # Copyright 2000, International Business Machines Corporation and others.
2 # All Rights Reserved.
3
4 # This software has been released under the terms of the IBM Public
5 # License.  For details, see the LICENSE file in the top-level source
6 # directory or online at http://www.openafs.org/dl/license10.html
7
8 # An InstallGuide for configuration of an AFS client
9 #
10
11 sub clientconfig {
12   my($cachefile, $cellfile, $dbfile, $replaced);
13   my($afsroot, $cachedir, $cachesize, $cellname);
14   my($config, $different, $line)
15   &ErrorsAreFatal(1);
16   &CreateDir("/usr/vice/etc");
17   $cachefile = "/usr/vice/etc/cacheinfo";
18   $cellfile = "/usr/vice/etc/ThisCell";
19   $dbfile = "/usr/vice/etc/CellServDB";
20
21   # Create a new cacheinfo file if it does not already exist
22   if (! -r $cachefile) {
23     $afsroot = $Configuration{"AFSROOT"};
24     $cachedir = $Configuration{"CACHEDIR"};
25     $cachesize = $Configuration{"CACHESIZE"};
26     &ErrorMsg("AFSROOT not defined") if ($afsroot eq "");
27     &ErrorMsg("CACHEDIR not defined") if ($cachedir eq "");
28     &ErrorMsg("CACHESIZE not defined") if ($cachesize eq "");
29     $config = "$afsroot:$cachedir:$cachesize";
30     
31     &CreateDir($cachedir);
32     
33     &CreateDir($afsroot);
34     # the next 2 blocks of code will be used later when config
35     # parameters can be passed through the GUI to override the
36     # defaults
37     if (-r $cachefile) {
38       open(CONFIG, "$cachefile");
39       $replaced = "$cachefile.old";
40       chomp($line = <CONFIG>);
41       $different = ($line ne $config);
42       close CONFIG;
43     }
44     if (($replaced && $different) || !$replaced) {
45       &VPrint("Creating new $cachefile");
46       unlink($replaced) if ($replaced);
47       rename($cachefile, $replaced) if ($replaced);
48       open(CONFIGNEW, ">$cachefile") || &ErrorMsg("Can't open config file", 
49                                                   $cachefile);
50       print CONFIGNEW "$config\n";
51       close CONFIGNEW;
52     } else {
53       &VPrint("$cachefile already created");
54     } 
55   }
56   $replaced = $different = 0;
57
58   # create a new ThisCell file
59   $cellname = $Configuration{"CELLNAME"};
60   &ErrorMsg("CELLNAME not defined") if ($cellname eq "");
61
62   if (-r $cellfile) {
63     open(CELL, "$cellfile");
64     $replaced = "$cellfile.old";
65     chomp($line = <CELL>);
66     $different = ($line ne $cellname);
67     close CELL;
68   }
69   if (($replaced && $different) || !$replaced) {
70     &VPvint("Creating new $cellfile");
71     unlink($replaced) if ($replaced);
72     rename($cellfile, $replaced) if ($replaced);
73     open(CELLNEW, ">$cellfile") || &ErrorMsg("Can't open cell file", 
74                                                  $cellfile);
75     print CELLNEW "$cellname\n";
76     close CELLNEW;
77   } else {
78     &VPrint("$cellfile already created");
79   } 
80
81   # create a new CellServDB file
82   $cellservdb = $Configuration{CELLSERVDB};
83   &ErrorMsg("CELLSERVDB not defined") if ($cellservdb eq "");
84   &Copy($cellservdb, $dbfile);
85 }
86
87
88   
89
90