Renew /etc/hosts with a bashscript for /etc/cron.daily #3063
vanthiedsteffan-jpg
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
#!/bin/bash
set -e
cp /home/User/.Xauthority /root
XAUTHORITY=/root/.Xauthority
export XAUTHORITY
DISPLAY=
cat /home/User/.mydisplayexport DISPLAY
YOU MUST DO in /home/User/.bashrc an -> echo $DISPLAY >~/.mydisplay
logger -i -t hosts-file-updater -- Programm -Start
cd /home/User/Downloads
date >> /var/log/hosts-file-updater-datum.log
rm -f hosts
wget -q -O hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
webdatum=
grep "# Date:" hosts | sed "s/# Date: //" | cut -d " " -f1,2,3,4hostsdatum=
grep "# Date:" /etc/hosts | sed "s/# Date: //" | cut -d " " -f1,2,3,4if [ -z "$hostsdatum" ]
then
hostsdatum = "Datum ist null !"
fi
if [ "$webdatum" != "$hostsdatum" ]
then
zenity --question --title="Eine neue hosts-Datei von raw.githubusercontent.com/StevenBlack/hosts/ liegt vor !" --text="Datum der neuen hosts : $webdatum\nDatum in hosts-Datei ist : $hostsdatum\n\n\n/etc/hosts jetzt erneuern ?" --width=500
if [ "$?" == "0" ]
then
"#" hosts-head your private network
cp /etc/hosts-head /etc/hosts
cat hosts >> /etc/hosts
fi
fi
logger -i -t hosts-file-updater -- Programm beendet
exit 0
Beta Was this translation helpful? Give feedback.
All reactions