summaryrefslogtreecommitdiff
path: root/scripts/priority.pl
blob: 39f6220be316cbcbe0882c25be2df7397c8d35bc (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
#!/usr/bin/perl

my %pri;

# Look at all node.def files in the configuration template tree
my @files = `find /opt/vyatta/share/vyatta-cfg -name 'node.def'`;
foreach my $f (@files) {
    my $result = `grep 'priority:' $f`;
    if (defined $result && length($result) != 0) {
	my @r = split " ", $result;
	if (defined $r[1]) {
	    # Strip off trailing "/node.def\n" from file pathname
	    my $line = substr($f, 0, -10);

	    # Strip off leading "/opt/vyatta/share/vyatta-cfg/templates/"
	    $line = substr($line, 39);

	    # See if there is a comment in entry
	    my ($entry, $comment) = split /#/, $result;
	    if (defined $comment) {
		$comment =~ s/\n//;
		$line = $line . " #" . $comment;
	    }
		
	    # stuff resulting line into hash
	    push @{$pri{$r[1]}}, $line;
	}
    }
}


#now sort

foreach my $key ( sort { $a <=> $b } keys %pri ) {
    my @a = @{$pri{$key}};
    foreach my $val (@a) {
	print $key," ",$val,"\n";
    }
}