From 5f9125b0443c2bc7db1298f51da9b237dd7c574a Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Sun, 25 Aug 2024 14:25:19 +0000 Subject: [PATCH] loxilb UI: save loxilb configuration save IP/LB/FW configuration from loxilb UI so when loxilb restart or bpfire reboot, the configuration can be restored. Signed-off-by: Vincent Li --- html/cgi-bin/loxilb.cgi | 13 ++++++++++++- html/cgi-bin/loxilbconfig.cgi | 12 ++++++++++++ html/cgi-bin/loxilbfw.cgi | 13 ++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/html/cgi-bin/loxilb.cgi b/html/cgi-bin/loxilb.cgi index 01723ab30..e50ac5b1f 100644 --- a/html/cgi-bin/loxilb.cgi +++ b/html/cgi-bin/loxilb.cgi @@ -457,13 +457,24 @@ sub manageIP { } +sub SaveIP { + my @save_options; + my $command = 'loxicmd'; + my $dir="/var/ipfire/loxilb/"; + push(@save_options, "save", "--ip", "-c", $dir); + &General::system_output($command, @save_options); + #my @output = &General::system_output($command, @save_options); + #$errormessage = join('', @output); +} + sub CreateIP { my (%settings) = @_; manageIP("create", %settings); + &SaveIP; } sub DeleteIP { my (%settings) = @_; manageIP("delete", %settings); + &SaveIP; } - diff --git a/html/cgi-bin/loxilbconfig.cgi b/html/cgi-bin/loxilbconfig.cgi index eafd3b80d..4fd466379 100644 --- a/html/cgi-bin/loxilbconfig.cgi +++ b/html/cgi-bin/loxilbconfig.cgi @@ -650,6 +650,16 @@ sub SortDataFile close (FILE); } +sub SaveLB { + my @save_options; + my $command = 'loxicmd'; + my $dir="/var/ipfire/loxilb/"; + push(@save_options, "save", "--lb", "-c", $dir); + &General::system_output($command, @save_options); + #my @output = &General::system_output($command, @save_options); + #$errormessage = join('', @output); +} + # # Build the configuration file # @@ -686,6 +696,7 @@ sub CreateLB { push(@loxicmd_options, "--monitor"); } &General::system($command, @loxicmd_options); + &SaveLB; } sub DeleteLB { @@ -696,4 +707,5 @@ sub DeleteLB { push(@loxicmd_options, "delete", "lb"); push(@loxicmd_options, "$name"); &General::system($command, @loxicmd_options); + &SaveLB; } diff --git a/html/cgi-bin/loxilbfw.cgi b/html/cgi-bin/loxilbfw.cgi index 04dd56464..b595a71d7 100644 --- a/html/cgi-bin/loxilbfw.cgi +++ b/html/cgi-bin/loxilbfw.cgi @@ -630,13 +630,24 @@ sub manageFW { } } +sub SaveFW { + my @save_options; + my $command = 'loxicmd'; + my $dir="/var/ipfire/loxilb/"; + push(@save_options, "save", "--firewall", "-c", $dir); + &General::system_output($command, @save_options); + #my @output = &General::system_output($command, @save_options); + #$errormessage = join('', @output); +} + sub CreateFW { my (%settings) = @_; manageFW("create", %settings); + &SaveFW; } sub DeleteFW { my (%settings) = @_; manageFW("delete", %settings); + &SaveFW; } -