]> git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/update-ids-ruleset
956c3a1f5d406f436fb6955643b66c608aae30c0
[ipfire-2.x.git] / src / scripts / update-ids-ruleset
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
22 use strict;
23
24 require '/var/ipfire/general-functions.pl';
25 require "${General::swroot}/ids-functions.pl";
26 require "${General::swroot}/lang.pl";
27
28 # Check if the red device is active.
29 unless (-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.
34 &IDS::_store_error_message("$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}");
35
36 # Exit.
37 exit 0;
38 }
39
40 # Check if enought free disk space is availabe.
41 if(&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
49 # Lock the IDS page.
50 &IDS::lock_ids_page();
51
52 # Call the download function and gather the new ruleset.
53 if(&IDS::downloadruleset()) {
54 # Store error message for displaying in the WUI.
55 &IDS::_store_error_message("$Lang::tr{'could not download latest updates'}");
56
57 # Unlock the IDS page.
58 &IDS::unlock_ids_page();
59
60 # Exit.
61 exit 0;
62 }
63
64 # Set correct ownership for the downloaded tarball.
65 &IDS::set_ownership("$IDS::rulestarball");
66
67 # Call oinkmaster to alter the ruleset.
68 &IDS::oinkmaster();
69
70 # Set correct ownership for the rulesdir and files.
71 &IDS::set_ownership("$IDS::rulespath");
72
73 # Unlock the IDS page.
74 &IDS::unlock_ids_page();
75
76 # Check if the IDS is running.
77 if(&IDS::ids_is_running()) {
78 # Call suricatactrl to perform a reload.
79 &IDS::call_suricatactrl("reload");
80 }
81
82 1;