]> git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/convert-to-location
mympd: remove create config start
[ipfire-2.x.git] / src / scripts / convert-to-location
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 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 CONF_DIR="/var/ipfire"
23 FW_CONF_DIR="$CONF_DIR/firewall"
24 HOSTS_CONF_DIR="$CONF_DIR/fwhosts"
25
26 # Check if the old blocking configuration file exists.
27 if [ -f "$FW_CONF_DIR/geoipblock" ]; then
28 # Convert variable, if blocking is enabled or not.
29 sed -i 's/GEOIPBLOCK/LOCATIONBLOCK/g' "$FW_CONF_DIR/geoipblock"
30
31 # Rename file to the new name.
32 mv "$FW_CONF_DIR/geoipblock" "$FW_CONF_DIR/locationblock"
33
34 # Loop through the firewall config directory.
35 for file in "$FW_CONF_DIR/config" "$FW_CONF_DIR/input" "$FW_CONF_DIR/outgoing"; do
36 # Convert pattern which indicates location based rules to the new
37 # ones.
38 sed -i 's/cust_geoip/cust_location/g' "$file"
39 done
40
41 # Rename indicator for location based groups to the new one.
42 sed -i 's/GeoIP Group/Location Group/g' "$HOSTS_CONF_DIR/customgeoipgrp"
43
44 # Rename file to the new name.
45 mv "$HOSTS_CONF_DIR/customgeoipgrp" "$HOSTS_CONF_DIR/customlocationgrp"
46
47 # Regenerate firewall chains.
48 /etc/init.d/firewall restart
49
50 # Restart IPsec for dropped iptables rules
51 if grep -q "ENABLED=on" /var/ipfire/vpn/settings; then
52 /etc/init.d/ipsec restart
53 fi
54 fi
55
56 # Finished.
57 exit 0