summaryrefslogtreecommitdiff
path: root/sbin/e2guardian-update-shallalists
blob: 756e83c49bed789f67850a39db4a34d11135b6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash

# Copyright (C) 2016 by Mike Gabriel <mike.gabriel@it-zukunft-schule.de>

# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

set -e

unset http_proxy
unset https_proxy
unset ftp_proxy

SHALLA_BLACKLIST_URL="http://www.shallalist.de/Downloads/shallalist.tar.gz"

mkdir -p /var/lib/e2guardian/
curl "$SHALLA_BLACKLIST_URL" 1> /var/lib/e2guardian/blacklists.tar.gz 2>/dev/null

if [ -e /var/lib/e2guardian/.blacklists.new ]; then
        rm -Rf /var/lib/e2guardian/.blacklists.new
fi

mkdir -p /var/lib/e2guardian/.blacklists.new

cd /var/lib/e2guardian/.blacklists.new
tar xzf /var/lib/e2guardian/blacklists.tar.gz

mv BL/* .
rmdir BL/

cd - 1>/dev/null

if [ -e /var/lib/e2guardian/blacklists.old ]; then
  rm -Rf /var/lib/e2guardian/blacklists.old
fi

if [ -d /var/lib/e2guardian/blacklists ]; then
        mv /var/lib/e2guardian/blacklists /var/lib/e2guardian/blacklists.old
fi

if [ ! -e /var/lib/e2guardian/blacklists ]; then
        mv /var/lib/e2guardian/.blacklists.new /var/lib/e2guardian/blacklists

        LANG=C date 1> /var/lib/e2guardian/last-updated.txt

        chown root:root -Rf /var/lib/e2guardian/blacklists
        chmod -Rf a+r /var/lib/e2guardian/blacklists
        cd /var/lib/e2guardian/blacklists
        find * -type d | while read dir; do
                chmod a+x "${dir}"
        done
        cd - 1> /dev/null

        invoke-rc.d e2guardian restart 1>/dev/null 2>/dev/null
fi

if [ -e /var/lib/e2guardian/blacklists.tar.gz ]; then
        rm -f /var/lib/e2guardian/blacklists.tar.gz
fi