소스 검색

Add hosts.ban feature

Edvinas Valatka 9 년 전
부모
커밋
1d62f2f25b
3개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      e-pullhosts
  2. 8 0
      e-pullhosts.service
  3. 10 0
      e-pullhosts.timer

+ 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
+