2020-10-05 00:10:52 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-11-10 10:50:05 +01:00
|
|
|
# V0.2.1
|
2020-10-05 00:10:52 +02:00
|
|
|
# Script para descargar una lista personalizada con direcciones para bloquearlas
|
|
|
|
# a través del fichero hosts
|
|
|
|
|
|
|
|
# Para automatizar este proceso se recomienda crear una tarea (crontab) y ajustarla a las necesidades del usuario (diario, semanal
|
|
|
|
# mensual, etc)
|
|
|
|
|
|
|
|
# Realizar copia de seguridad del fichero hosts en caso de no existir
|
|
|
|
if [ ! -f /etc/hosts.bak ]; then
|
2021-10-11 15:33:04 +02:00
|
|
|
printf "\033[32;1mCreando copia de seguridad del fichero hosts...\033[0m\n";
|
|
|
|
doas cp /etc/hosts /etc/hosts.bak && sleep 1s; printf "\033[33;1mCopia finalizada\033[0m\n"
|
2020-10-05 00:10:52 +02:00
|
|
|
else
|
2021-10-11 15:33:04 +02:00
|
|
|
printf "\033[35;5mYa existe copia de seguridad del fichero hosts\033[0m\n"
|
2020-10-05 00:10:52 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Descargar actualizaciones mas reciente del repositorio y copiarlo al fichero hosts
|
|
|
|
if [ ! -w /etc/hosts ]; then
|
|
|
|
doas chmod o+w /etc/hosts && sleep 1s;
|
2021-10-11 15:33:04 +02:00
|
|
|
printf "\033[32;1mDescargando y copiando lista actualizada para fichero hosts...\033[0m\n" &&
|
2020-10-05 00:10:52 +02:00
|
|
|
wget -O /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts && sleep 1s;
|
|
|
|
else
|
2021-10-11 15:33:04 +02:00
|
|
|
printf "\033[32;1mDescargando y copiando lista actualizada para fichero hosts...\033[0m\n" &&
|
2020-10-05 00:10:52 +02:00
|
|
|
wget -O /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts && sleep 1s;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Agregar lista personalizada de páginas al fichero hosts
|
2021-10-11 15:33:04 +02:00
|
|
|
#printf "\033[32;1mAgregando parche de la lista personalizada al fichero hosts...\033[0m\n";
|
2021-08-05 21:17:13 +02:00
|
|
|
#cat /home/skynet/Datos/Git/archivos_diversos/parche >> /etc/hosts; sleep 2;
|
2021-10-11 15:33:04 +02:00
|
|
|
#printf "\033[33;1mParche aplicado\033[0m\n";
|
2020-10-05 00:10:52 +02:00
|
|
|
|
2021-08-05 21:17:13 +02:00
|
|
|
~/.local/bin/dunst_sound &
|
2020-10-05 00:10:52 +02:00
|
|
|
|
|
|
|
# Notificacion de actualizacion del fichero
|
2021-10-11 15:33:04 +02:00
|
|
|
printf "\033[36;1mFichero hosts actualizado.\nTarea finalizada.\033[0m\n";
|
2020-10-05 00:10:52 +02:00
|
|
|
#notify-send -t 5000 -i /home/skynet/.icons/status/hosts_update.png "Tarea finalizada" 'Fichero hosts actualizado'
|
2020-11-10 10:50:05 +01:00
|
|
|
#printf 'IMG:/home/skynet/Datos/Git_Hub/Void_Linux/otros/icons/status/hosts_update.png\tTarea finalizada\tFichero hosts actualizado\n' > $XNOTIFY_FIFO
|
|
|
|
herbe "Lista de fichero hosts actualizado"
|