3 # Remove cell files from this machine. Use with caution!
10 use OpenAFS
::ConfigUtils
;
17 afs-rmcell - Delete AFS cell files from this machine.
21 B<afs-rmcell> [B<--batch>] [B<--partition-id>=letter] [B<--help>] [B<--debug>]
25 This script destroys the AFS database and volume files on this machine.
33 my $partition_id = 'a';
34 my $path = $OpenAFS::Dirpath
::openafsdirpath
;
35 my $ostype = $path->{'ostype'};
37 #-----------------------------------------------------------------------------------
44 "partition-id=s" => \
$partition_id,
45 "ostype=s" => \
$ostype,
48 $OpenAFS::ConfigUtils
::debug
= $debug;
56 die "error: This script should run as root.\n";
59 # To be on the safe side, we do no accept the full partition name, just the letter id.
60 # You'll have to manually delete volume files for unconventional partition names.
61 unless ($partition_id=~/^(([a-z])|([a-h][a-z])|([i][a-v]))$/) {
62 die "error: Invalid partition id specified.\n".
63 "info: Please specify a valid partition abbreviation, for example --partition-id='a' for /vicepa\n";
67 my $rl = new Term
::ReadLine
('afs-rmcell');
68 print "\n*** WARNING !! WARNING !! WARNING !! *** \n\n";
69 print "You are about to permanently DESTROY the OpenAFS\n";
70 print "configuration, databases, and volumes on this machine!\n";
71 my $answer = $rl->readline("Do you really want to destroy the AFS cell? (destroy/no) [no] ");
72 unless ($answer eq "destroy" ) {
73 print "info: must answer 'destroy' to continue.\n" if $answer!~/^n/i;
74 print "info: Aborted.\n";
79 my $os = OpenAFS
::OS
::create
('ostype'=>$ostype, 'debug'=>$debug);
81 # make sure the client init script has the correct paths.
82 $os->configure_client();
84 run
($os->command('client-stop'));
85 run
($os->command('fileserver-stop'));
86 run
($os->command('client-forcestop'));
88 $os->remove("$path->{'afsdbdir'}/prdb.DB0");
89 $os->remove("$path->{'afsdbdir'}/prdb.DBSYS1");
90 $os->remove("$path->{'afsdbdir'}/vldb.DB0");
91 $os->remove("$path->{'afsdbdir'}/vldb.DBSYS1");
92 $os->remove("$path->{'afsdbdir'}/kaserver.DB0");
93 $os->remove("$path->{'afsdbdir'}/kaserver.DBSYS1");
94 $os->remove("$path->{'afsbosconfigdir'}/BosConfig");
95 $os->remove("$path->{'afslogsdir'}/*");
96 $os->remove("$path->{'afslocaldir'}/*");
97 $os->remove("$path->{'afsconfdir'}/UserList");
98 $os->remove("$path->{'afsconfdir'}/ThisCell");
99 $os->remove("$path->{'afsconfdir'}/CellServDB");
100 $os->remove("$path->{'afsconfdir'}/KeyFile");
101 $os->remove("$path->{'afsconfdir'}/krb.conf");
102 $os->remove("$path->{'afsddir'}/ThisCell");
103 $os->remove("$path->{'afsddir'}/CellServDB");
104 $os->remove("/vicep$partition_id/AFSIDat ");
105 $os->remove("/vicep$partition_id/V*.vol");
106 $os->remove("/vicep$partition_id/Lock");