source: trunk/debathena/config/afs-config/debian/update-cellservdb @ 23739

Revision 23739, 775 bytes checked in by broder, 15 years ago (diff)
In afs-config: * Add script to `fs newcell` any cells that are out of date according to the newly installed CellServDB. (Trac: #186)
  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5my %cm_servers;
6open(FS, '-|', 'fs', 'listcells', '-numeric') or die;
7while (<FS>) {
8    if (/^Cell dynroot on hosts\.$/) {
9    } elsif (/^Cell (\S+) on hosts (.+)\.$/) {
10        $cm_servers{$1} = [split(' ', $2)];
11    } else {
12        die;
13    }
14}
15close(FS) or die;
16
17my %csdb_servers;
18my $cell;
19open(CSDB, '<', '/etc/openafs/CellServDB') or die;
20while (<CSDB>) {
21    if (/^>([^#\s]+)/) {
22        $cell = $1;
23    } elsif (/^([^#\s]+)/) {
24        push(@{$csdb_servers{$cell}}, $1);
25    } else {
26        die;
27    }
28}
29close(CSDB);
30
31while (my ($cell, $servers) = each(%csdb_servers)) {
32    if (!exists($cm_servers{$cell}) or
33        join(' ', sort(@{$cm_servers{$cell}})) ne join(' ', sort(@$servers))) {
34        system('fs', 'newcell', '-name', $cell, '-servers', @$servers);
35    }
36}
Note: See TracBrowser for help on using the repository browser.