Re: script bash pour unbound

2018-08-21 Par sujet Bernard Schoenacker



- Mail original -
> De: "Daniel Caillibaud" 
> À: debian-user-french@lists.debian.org
> Envoyé: Mardi 21 Août 2018 19:21:06
> Objet: Re: script bash pour unbound
> 
> Le 18/08/18 à 21:48, Bernard Schoenacker
>  a
> écrit :
> 
> > bonjour,
> > 
> > j'ai pris ce script bash et je n'arrive pas à le déverminer:
> > 
> > https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
> > 
> > voici le début qui pose problème :
> > 
> > ARRAY=
> > $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> > )
> 
> sur la page mentionnée y'a pas de $
> 
> > for i in "${ARRAY[@]}"
> 
> et du coup je comprend pas la ligne précédente, pourquoi un for sur
> un
> tableau d'un seul élément ?
> 
> Pas testé, mais amha, virer do/done et remplacer le wget par
> 
> > do
> >   wget -c  -O  w  "$i"
> 
> wget -c -O w
> https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> 
> 
> > 
> >   grep -v "
> >   #\|\|\|\|\|\|href\|title=\|=\|<" w
> > > adsList.txt rm -f w
> >   dos2unix adsList.txt
> 
> 
> ça peut se faire sans fichier intermediaire avec
> 
> wget -c -O - $url|grep -v "expression" > fichier
> 
> donc ici tu peux te contenter de ces 3 lignes, en remplaçant la 3e
> par /etc/init, service ou systemctl suivant ta conf
> (et mettre le path complet de adsList.txt pour pouvoir lancer le
> script de
> n'importe où) :
> 
> url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> wget -q -O - $url|sed -e '/^$/d; /#/d' > adsList.txt
> # reste à relancer unbound qui lit ce adsList.txt
> 
> 
> mais je crois qu'unbound ignore les lignes vides et celles qui
> commencent
> par #, ton script devrai#!/bin/bash
#
# set chmod +x
# exec sh

echo  Someonewhocares  Go ===

wget -vnc -O - 'https://someonewhocares.org/hosts/zero/' |unhtml | grep 
'^0\.0\.0\.0' | awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Someonewhocares  done ==

echo  Githubusercontent notracking  Go 
===
wget -vnc -O - 
'https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt'|
 grep '^0\.0\.0\.0' | awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 
>>w

echo convert file to utf8
echo  Githubusercontent notracking  done 
===

echo  winhelp2002 Go ===

  wget -vnc -O - 'http://winhelp2002.mvps.org/hosts.txt' |awk '/0.0.0.0/ {print 
$2}'| iconv -f iso8859-15 -t utf8 >>w
 
echo convert file to utf8
echo  winhelp2002 done ===


echo  Githubusercontent StevenBlack Go 
===

wget -vnc -O - 
'https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts'
 |awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Githubusercontent StevenBlack done 
===

echo  Adaway  Go ===
wget -vnc -O -  'https://adaway.org/hosts.txt' | awk '/127.0.0.1/ {print $2}'| 
iconv -f iso8859-15 -t utf8 >>w
echo convert file to utf8
echo  Adaway  done ===


echo  Pgl Yoyo  Go ===
wget -vnc  -O- --header\="Accept-Encoding: gzip" 
'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext'
 | gunzip | awk '/127.0.0.1/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Pgl Yoyo  done ===


echo  Hosts File  Go ===
wget -qnc  -O - 'https://hosts-file.net/ad_servers.txt' | awk '/127.0.0.1/ 
{print $2}' | iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Hosts File done ===


echo   dsfc  Go ===

wget -qnc -O - 
'https://www.dsfc.net/infrastructure/dns-infrastructure/unbound-redirecteur-cache-blacklist-dns/'|unhtml|
 tr -d '\'| tr -d '"' | awk '/local-zone/ {print $2}'| iconv -f iso8859-15 
-t utf8 >>w


Re: script bash pour unbound

2018-08-21 Par sujet Daniel Caillibaud
Le 18/08/18 à 21:48, Bernard Schoenacker  a
écrit :

> bonjour,
> 
> j'ai pris ce script bash et je n'arrive pas à le déverminer:
> 
> https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
> 
> voici le début qui pose problème :
> 
> ARRAY=
> $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> )

sur la page mentionnée y'a pas de $

> for i in "${ARRAY[@]}"

et du coup je comprend pas la ligne précédente, pourquoi un for sur un
tableau d'un seul élément ?

Pas testé, mais amha, virer do/done et remplacer le wget par

> do
>   wget -c  -O  w  "$i"

wget -c -O w
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts


> 
>   grep -v " #\|\|\|\|\|\|href\|title=\|=\|<" w
> > adsList.txt rm -f w
>   dos2unix adsList.txt


ça peut se faire sans fichier intermediaire avec

wget -c -O - $url|grep -v "expression" > fichier

donc ici tu peux te contenter de ces 3 lignes, en remplaçant la 3e
par /etc/init, service ou systemctl suivant ta conf
(et mettre le path complet de adsList.txt pour pouvoir lancer le script de
n'importe où) :

url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
wget -q -O - $url|sed -e '/^$/d; /#/d' > adsList.txt
# reste à relancer unbound qui lit ce adsList.txt


mais je crois qu'unbound ignore les lignes vides et celles qui commencent
par #, ton script devrait pouvoir se résumer à

url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
wget -q -O /path/to/adsList.tmp $url \
  && [ -s /path/to/adsList.tmp ] \
  && mv /path/to/adsList.tmp /path/to/adsList.txt \
  && systemctl reload unbound \
  && echo "Liste actualisée et rechargée" \
  || echo "Un truc a foiré">&2

(l'enchaînement avec && est là au cas où le wget plante, pour ne pas risquer
d'écraser l'ancien txt avec un truc vide, le test -s passe si le fichier
n'est pas vide)


Une remarque au passage, je ne laisserais pas qqun d'externe définir
l'ip de localhost, ça me parait plus prudent d'ajouter un sed pour virer
les premières lignes, ou ne garder que celles qui commencent par 0.0.0.0,
en ajoutant si besoin un autre fichier txt pour unbound pour ces lignes
(mais je crois qu'unbound résoud déjà localhost avec sa conf par défaut).

wget -q -O - $url|sed -ne '/^0\.0\.0\.0/ p' > /path/to/adsList.tmp


Celui qui fournit la liste pourra toujours rediriger localhost vers 0.0.0.0
mais au moins ça n'ira pas ailleurs et je vais m'en apercevoir rapidement.

> 
> 
> merci pour le coup de puce
> 
> slt
> bernard
> 


-- 
Daniel

Travailler dur n'a jamais tué personne, mais pourquoi prendre le 
risque ?
Edgar Bergen



Re: script bash pour unbound

2018-08-19 Par sujet Petrus MH8
Bonjour,

J'utilise actuellement un script un peu différent avec Unbound, pour une
finalité anti-pubs équivalente avec une autre source, je pense cependant
qu'il est possible de remanier la commande afin d'utiliser ta source si
tu préfères...
En espérant que ca fonctionne toujours sur la version Unbound distribuée
sur une Stretch, car actuellement sur une Raspbian 8 Jessie.

réf:
https://mh8.mooo.com/www/leminos/wiki/unbound-serveur-dns-a-la-maison-requetes-aux-dns-racines



Le 18/08/2018 à 21:48, Bernard Schoenacker a écrit :
> bonjour,
>
> j'ai pris ce script bash et je n'arrive pas à le déverminer:
>
> https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
>
> voici le début qui pose problème :
>
> ARRAY= 
> $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
>  )
>
> for i in "${ARRAY[@]}"
> do
>   wget -c  -O  w  "$i"
>
>   grep -v " #\|\|\|\|\|\|href\|title=\|=\|<" w > 
> adsList.txt
>   rm -f w
>   dos2unix adsList.txt
>
>
> merci pour le coup de puce
>
> slt
> bernard
>






signature.asc
Description: OpenPGP digital signature


script bash pour unbound

2018-08-18 Par sujet Bernard Schoenacker
bonjour,

j'ai pris ce script bash et je n'arrive pas à le déverminer:

https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound

voici le début qui pose problème :

ARRAY= 
$(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
 )

for i in "${ARRAY[@]}"
do
  wget -c  -O  w  "$i"

  grep -v " #\|\|\|\|\|\|href\|title=\|=\|<" w > 
adsList.txt
  rm -f w
  dos2unix adsList.txt


merci pour le coup de puce

slt
bernard