#!/usr/bin/perl use strict; use warnings; my %cm_servers; open(FS, '-|', 'fs', 'listcells', '-numeric') or die; while () { if (/^Cell dynroot on hosts\.$/) { } elsif (/^Cell (\S+) on hosts (.+)\.$/) { $cm_servers{$1} = [split(' ', $2)]; } else { die; } } close(FS) or die; my %csdb_servers; my $cell; open(CSDB, '<', '/var/db/openafs/etc/CellServDB') or die; while () { if (/^>([^#\s]+)/) { $cell = $1; } elsif (/^([^#\s]+)/) { push(@{$csdb_servers{$cell}}, $1); } else { die; } } close(CSDB); while (my ($cell, $servers) = each(%csdb_servers)) { if (!exists($cm_servers{$cell}) or join(' ', sort(@{$cm_servers{$cell}})) ne join(' ', sort(@$servers))) { system('fs', 'newcell', '-name', $cell, '-servers', @$servers); } }