Bladeren bron

Merge branch 'devel'

Edvinas Valatka 9 jaren geleden
bovenliggende
commit
be484e22e4
5 gewijzigde bestanden met toevoegingen van 32 en 5 verwijderingen
  1. 2 3
      e-badips
  2. 1 2
      e-pullasn
  3. 11 0
      e-pullhosts
  4. 8 0
      e-pullhosts.service
  5. 10 0
      e-pullhosts.timer

+ 2 - 3
e-badips

@@ -4,11 +4,10 @@ set -euo pipefail
 CONFD=/etc/e-router
 source $CONFD/config
 
-
 tmp=$(mktemp)
+trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
+
 curl -f -s -m 60 -o $tmp "https://www.badips.com/get/list/${banservice}/${banlevel}?age=${rangecheck}"
 while read -r ip ; do
     ipset -! add ${banset} ${ip} timeout $bantime
 done < $tmp
-
-trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM

+ 1 - 2
e-pullasn

@@ -5,6 +5,7 @@ CONFD=/etc/e-router
 source $CONFD/config
 
 tmp=$(mktemp)
+trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
 
 while read -r asn ; do
     [[ "$asn" =~ ^AS[0-9]{1,}$ ]] || continue
@@ -14,5 +15,3 @@ done < $CONFD/WHITE.asn
 grep -Eo "([0-9.]+){4}/[0-9]+" $tmp | while read -r net ; do
     ipset -! add  $whiteset $net timeout $routettl
 done
-
-trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM

+ 11 - 0
e-pullhosts

@@ -0,0 +1,11 @@
+#!/bin/bash
+((EUID == 0 )) || { echo "Need root"; exit 1; }
+set -euo pipefail
+
+tmp=$(mktemp)
+trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
+
+curl -sSfo ${tmp}  http://someonewhocares.org/hosts/zero/hosts
+sed -i  '0,/#<\/localhost>/d' ${tmp}
+grep -E '^[0#]+' ${tmp} > /etc/hosts.ban
+systemctl reload dnsmasq.service

+ 8 - 0
e-pullhosts.service

@@ -0,0 +1,8 @@
+[Unit]
+Description=Update hosts.ban file from http://someonewhocares.org/hosts/zero/hosts
+Requires=dnsmasq.service
+After=dnsmasq.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/e-pullhosts

+ 10 - 0
e-pullhosts.timer

@@ -0,0 +1,10 @@
+[Unit]
+Description=e-pullhosts timer
+
+[Timer]
+OnUnitActiveSec=80000
+OnBootSec=300
+
+[Install]
+WantedBy=timers.target
+