]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blame - src/scripts/convert-to-location
libloc: Update to 0.9.3
[people/mfischer/ipfire-2.x.git] / src / scripts / convert-to-location
CommitLineData
f1d982cc
SS
1#!/bin/bash
2
3###############################################################################
4# #
5# IPFire.org - A linux based firewall #
6# Copyright (C) 2020 IPFire Development Team <info@ipfire.org> #
7# #
8# This program is free software: you can redistribute it and/or modify #
9# it under the terms of the GNU General Public License as published by #
10# the Free Software Foundation, either version 3 of the License, or #
11# (at your option) any later version. #
12# #
13# This program is distributed in the hope that it will be useful, #
14# but WITHOUT ANY WARRANTY; without even the implied warranty of #
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16# GNU General Public License for more details. #
17# #
18# You should have received a copy of the GNU General Public License #
19# along with this program. If not, see <http://www.gnu.org/licenses/>. #
20# #
21###############################################################################
22
23CONF_DIR="/var/ipfire"
24FW_CONF_DIR="$CONF_DIR/firewall"
25HOSTS_CONF_DIR="$CONF_DIR/fwhosts"
26
27# Check if the old blocking configuration file exists.
28if [ -f "$FW_CONF_DIR/geoipblock" ]; then
29 # Convert variable, if blocking is enabled or not.
30 sed -i 's/GEOIPBLOCK/LOCATIONBLOCK/g' "$FW_CONF_DIR/geoipblock"
31
32 # Rename file to the new name.
33 mv "$FW_CONF_DIR/geoipblock" "$FW_CONF_DIR/locationblock"
34
35 # Loop through the firewall config directory.
36 for file in "$FW_CONF_DIR/config" "$FW_CONF_DIR/input" "$FW_CONF_DIR/outgoing"; do
37 # Convert pattern which indicates location based rules to the new
38 # ones.
39 sed -i 's/cust_geoip/cust_location/g' "$FW_CONF_DIR/$file"
40 done
41
42 # Rename indicator for location based groups to the new one.
43 sed -i 's/GeoIP Group/Location Group/g' "$HOSTS_CONF_DIR/customgeoipgrp"
44
45 # Rename file to the new name.
46 mv "$HOSTS_CONF_DIR/customgeoipgrp" "$HOSTS_CONF_DIR/customlocationgrp"
47fi
48
49# Finished.
50exit 0