blob: 3f5804f1a5db5f9b287004332ccd1ef30ac1de48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/usr/bin/perl
# Read all the configuration templates in the configuration
# template directory and produce an ordered list of the priority
# of configuration actions
use strict;
use warnings;
use File::Find;
my %pri;
sub get_priority {
open( my $f, '<', $_ )
or return;
my $priority;
while (<$f>) {
chomp;
next unless m/^priority:\s(\d+)/;
$priority = $1;
last;
}
close $f;
return $priority;
}
sub wanted {
return unless ( $_ eq 'node.def' );
my $p = get_priority($File::Find::name);
return unless $p;
my $dir = $File::Find::dir;
$dir =~ s/^.*\/templates\///;
push @{ $pri{$p} }, $dir;
return 1;
}
my $cfgdir = '/opt/vyatta/share/vyatta-cfg/templates';
die "$cfgdir does not exist!" unless -d $cfgdir;
find( \&wanted, $cfgdir );
foreach my $key ( sort { $a <=> $b } keys %pri ) {
my @a = @{ $pri{$key} };
foreach my $val (@a) {
print $key, " ", $val, "\n";
}
}
|