summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2008-04-02 18:05:55 -0700
committerStig Thormodsrud <stig@vyatta.com>2008-04-02 18:05:55 -0700
commitab870f61eec0e48c06ee1a5008e8aa0d77a0638e (patch)
tree8b2761b6952a355c940dbd121daf2efc5b274322 /scripts
parentac2527611ae57dd54edb2d08e26a2b54aeca9dc4 (diff)
downloadvyatta-cfg-ab870f61eec0e48c06ee1a5008e8aa0d77a0638e.tar.gz
vyatta-cfg-ab870f61eec0e48c06ee1a5008e8aa0d77a0638e.zip
Add duplicate check to watchlink exclude file.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-watchlink-exclude.pl16
1 files changed, 15 insertions, 1 deletions
diff --git a/scripts/vyatta-watchlink-exclude.pl b/scripts/vyatta-watchlink-exclude.pl
index 048946c..eb9d280 100755
--- a/scripts/vyatta-watchlink-exclude.pl
+++ b/scripts/vyatta-watchlink-exclude.pl
@@ -112,6 +112,18 @@ sub remove_exclude_line {
return @new_lines;
}
+sub is_exclude_dup {
+ my ($new_line, @lines) = @_;
+
+ my $frag = substr($new_line, 0, index($new_line, ' #'));
+ foreach my $line (@lines) {
+ if (substr($line, 0, index($line, ' #')) eq $frag) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
#
# main
@@ -148,7 +160,9 @@ if (defined $opt_id) {
}
if ($opt_action eq "add") {
- push @lines, $new_line;
+ if (! is_exclude_dup($new_line, @lines)) {
+ push @lines, $new_line;
+ }
} elsif (defined $opt_intf) {
@lines = remove_exclude_line($new_line, @lines);
} else {