diff options
Diffstat (limited to 'xpp/utils/xpp_sync')
-rwxr-xr-x | xpp/utils/xpp_sync | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/xpp/utils/xpp_sync b/xpp/utils/xpp_sync index 018d268..e1258d9 100755 --- a/xpp/utils/xpp_sync +++ b/xpp/utils/xpp_sync @@ -5,7 +5,9 @@ # This program is free software; you can redistribute and/or # modify it under the same terms as Perl itself. # -#use strict; +# $Id$ +# +use strict; BEGIN { my $dir = $0; $dir =~ s:/[^/]+$::; unshift(@INC, "$dir", "$dir/zconf"); } use Zaptel::Xpp; @@ -19,6 +21,7 @@ if(@ARGV == 1) { $autoselect = 1 if $sync =~ /^auto$/i; } + sub get_sorted_xpds() { my @good_xpds; @@ -31,7 +34,7 @@ sub get_sorted_xpds() { next; } next unless $isreg; # Skip unregistered XPDs - push(@good_xpds, $xpd); + push(@good_xpds, $xpd); } } @@ -70,21 +73,45 @@ sub do_set($) { die "Failed to set sync to '$sync'" unless Zaptel::Xpp::sync($sync); } +sub unique_xbus(@) { + my %seen; + + grep { !$seen{$_->xbus}++; } @_; +} + my $curr_sync = Zaptel::Xpp::sync; -my %xbus_seen; -my @sorted_xpds = grep { !$xbus_seen{$_->xbus}++; } get_sorted_xpds; +my @sync_xpds = unique_xbus(get_sorted_xpds()); + +sub check_fxo_host_sync() { + my @host_synced_xpds = grep { $_->xbus->num() ne $curr_sync } @sync_xpds; + my @host_synced_fxos = grep($_->type eq 'FXO', @host_synced_xpds); + if(@host_synced_fxos) { + my @bad_xbus = map { $_->xbus } unique_xbus(@host_synced_fxos); + our $lines = join("\n\t", map { $_->name } @bad_xbus); + print STDERR <<"END"; +========================================= +WARNING: FXO with HOST SYNC cause bad PCM + Affected Astribanks are: +----------------------------------------- + $lines +========================================= +END + } +} + if($sync) { if($autoselect) { - do_select(@sorted_xpds); + do_select(@sync_xpds); } else { $sync = uc($sync); do_set($sync); } + $curr_sync = Zaptel::Xpp::sync; #print "New sync: ", Zaptel::Xpp::sync, "\n"; } else { print "Current sync: ", $curr_sync, "\n"; print "Best Available Syncers:\n"; - foreach my $xpd (@sorted_xpds) { + foreach my $xpd (@sync_xpds) { my $xbus = $xpd->xbus; my @xpds = $xbus->xpds; my @types = map { $_->type } @xpds; @@ -101,12 +128,13 @@ if($sync) { $next = $n + 1; } # Fill spaces to end - $n = 4; + my $n = 4; for(my $i = $next; $i < $n; $i++) { printf "%-3s ", ""; } printf "] (%s)\n", $xbus->connector; } + check_fxo_host_sync; } __END__ |