From 01d4c9c6e8c5e7b20ff1bd7372417b086af8f301 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 23 Nov 2010 15:58:19 -0800 Subject: Use unlink rather than system() to remove files in keepalive script Faster to use perl to remove file than going out to shell. --- scripts/keepalived/vyatta-keepalived.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts/keepalived') diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index 981bd5a8..ebb8307c 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -118,7 +118,7 @@ sub keepalived_get_values { if ( $config->exists("disable") ) { vrrp_log("$vrrp_instance disabled - skipping"); my $state_file = get_state_file( $intf, $group ); - system("rm -f $state_file"); + unlink($state_file); next; } my @vips = $config->returnValues("virtual-address"); @@ -337,7 +337,7 @@ sub remove_from_changes { # we shouldn't get to this point, but try to handle it if we do # vrrp_log("unexpected remove_from_changes()"); - system("rm -f $changes_file"); + unlink($changes_file); return 0; } my @new_lines = (); @@ -353,7 +353,7 @@ sub remove_from_changes { if ( $num_changes > 0 ) { vrrp_save_changes(@new_lines); } else { - system("rm -f $changes_file"); + unlink($changes_file); } return $num_changes; } @@ -493,7 +493,7 @@ if ( $action eq "update" ) { } if ( $vrrp_instances == 0 ) { stop_daemon(); - system("rm -f $conf_file"); + unlink($conf_file); } if ( scalar(@errs) ) { print join( "\n", @errs ); @@ -510,7 +510,7 @@ if ( $action eq "delete" ) { } vrrp_log("vrrp delete $vrrp_intf $vrrp_group"); my $state_file = get_state_file( $vrrp_intf, $vrrp_group ); - system("rm -f $state_file"); + unlink($state_file); exit 0; } -- cgit v1.2.3