]> git.ipfire.org Git - ipfire-2.x.git/blame - src/scripts/update-ids-ruleset
update-ids-ruleset: Release ids_page_lock when the downloader fails.
[ipfire-2.x.git] / src / scripts / update-ids-ruleset
CommitLineData
82979dec
SS
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2018 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22use strict;
23
24require '/var/ipfire/general-functions.pl';
25require "${General::swroot}/ids-functions.pl";
26require "${General::swroot}/lang.pl";
27
28# Check if the red device is active.
29unless (-e "${General::swroot}/red/active") {
30 # Store notice in the syslog.
31 &IDS::_log_to_syslog("The system is offline.");
32
33 # Store error message for displaying in the WUI.
d6f725e1 34 &IDS::_store_error_message("$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}");
82979dec
SS
35
36 # Exit.
37 exit 0;
38}
39
40# Check if enought free disk space is availabe.
41if(&IDS::checkdiskspace()) {
42 # Store the error message for displaying in the WUI.
43 &IDS::_store_error_message("$Lang::tr{'not enough disk space'}");
44
45 # Exit.
46 exit 0;
47}
48
5206a335
SS
49# Lock the IDS page.
50&IDS::lock_ids_page();
51
82979dec
SS
52# Call the download function and gather the new ruleset.
53if(&IDS::downloadruleset()) {
54 # Store error message for displaying in the WUI.
55 &IDS::_store_error_message("$Lang::tr{'could not download latest updates'}");
56
84227f7a
SS
57 # Unlock the IDS page.
58 &IDS::unlock_ids_page();
59
82979dec
SS
60 # Exit.
61 exit 0;
62}
63
50b35e0f
SS
64# Set correct ownership for the downloaded tarball.
65&IDS::set_ownership("$IDS::rulestarball");
66
82979dec
SS
67# Call oinkmaster to alter the ruleset.
68&IDS::oinkmaster();
69
ca8c9210
SS
70# Set correct ownership for the rulesdir and files.
71&IDS::set_ownership("$IDS::rulespath");
72
5206a335
SS
73# Unlock the IDS page.
74&IDS::unlock_ids_page();
75
82979dec
SS
76# Check if the IDS is running.
77if(&IDS::ids_is_running()) {
78 # Call suricatactrl to perform a reload.
79 &IDS::call_suricatactrl("reload");
80}
81
821;