update-ids-ruleset: Silent script if no providers settings file exists.

Message ID 20220513171044.39793-1-stefan.schantl@ipfire.org
State Accepted
Commit 89c7320bcfd8bfd19cb9f98965477520ef14ff78
Headers
Series update-ids-ruleset: Silent script if no providers settings file exists. |

Commit Message

Stefan Schantl May 13, 2022, 5:10 p.m. UTC
  Only try to read-in the providers settings file, in case it exists.
Otherwise the script produces an error message, about the missing file,
each time it gets executed.

Because of the fcron job this would be twice a day in most cases.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/scripts/update-ids-ruleset | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Michael Tremer May 13, 2022, 8:12 p.m. UTC | #1
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>

> On 13 May 2022, at 18:10, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Only try to read-in the providers settings file, in case it exists.
> Otherwise the script produces an error message, about the missing file,
> each time it gets executed.
> 
> Because of the fcron job this would be twice a day in most cases.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> src/scripts/update-ids-ruleset | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/scripts/update-ids-ruleset b/src/scripts/update-ids-ruleset
> index e9a082e62..553c1a1e1 100644
> --- a/src/scripts/update-ids-ruleset
> +++ b/src/scripts/update-ids-ruleset
> @@ -95,8 +95,8 @@ if ($return) {
> # The script has requested a lock, so set locket to "1".
> $locked = "1";
> 
> -# Grab the configured providers.
> -&General::readhasharray("$IDS::providers_settings_file", \%providers);
> +# Grab the configured providers, if the providers settings file exists.
> +&General::readhasharray("$IDS::providers_settings_file", \%providers) if (-f "$IDS::providers_settings_file");
> 
> # Loop through the array of available providers.
> foreach my $id (keys %providers) {
> -- 
> 2.30.2
>
  

Patch

diff --git a/src/scripts/update-ids-ruleset b/src/scripts/update-ids-ruleset
index e9a082e62..553c1a1e1 100644
--- a/src/scripts/update-ids-ruleset
+++ b/src/scripts/update-ids-ruleset
@@ -95,8 +95,8 @@  if ($return) {
 # The script has requested a lock, so set locket to "1".
 $locked = "1";
 
-# Grab the configured providers.
-&General::readhasharray("$IDS::providers_settings_file", \%providers);
+# Grab the configured providers, if the providers settings file exists.
+&General::readhasharray("$IDS::providers_settings_file", \%providers) if (-f "$IDS::providers_settings_file");
 
 # Loop through the array of available providers.
 foreach my $id (keys %providers) {