Tiny Core Extensions > TCE Q&A Forum

Use /etc/host for ad-blocking?

<< < (3/3)

Misalf:

--- Quote from: coreplayer2 on December 24, 2015, 02:11:50 AM ---Update and add etc/hosts to your backup

--- End quote ---
Looking at  tc-config  and  sethostname  it seems one could just remove sethostname from bootsync.sh if there is no need to change the host name (which could still be done via host= bootcode) as long as a valid /etc/hosts file is included in the backup.
Otherwise  sethostname  recreates /etc/hosts with default values after the backup was restored.

Misalf:
If the hostname is set via bootcode, the backed-up hosts file should probably have the same value in the localhost line.

emninger:

--- Quote from: coreplayer2 on December 24, 2015, 02:11:50 AM ---Somewhere in this forum is a thread on updating the host file from from the good folks at putorius.net
Maybe it's the same script..?  this one works fine.  Update and add etc/hosts to your backup
I've been experimenting with this, but it adds a considerably large file to my backup so tend not to use it.   
it's hard to tell the difference as I hardly every get ad's anyhow


--- Code: ---~ $ ./HostFileUpdate.sh
Connecting to winhelp2002.mvps.org (216.155.126.40:80)
hosts.txt            100% |************************************************|   498k  0:00:00 ETA
~ $

--- End code ---


--- Code: ---#!/bin/sh
## Update hosts file
## http://www.putorius.net/2012/01/block-unwanted-advertisements-on.html

## backup old hsts file
# cp /etc/hosts ~/.hosts_bak


if [ -f ~/.hosts_bak ]; then
cd /tmp
wget http://winhelp2002.mvps.org/hosts.txt
sudo rm /etc/hosts
sudo mv hosts.txt /etc/hosts
sudo cat ~/.hosts_bak >> /etc/hosts
else
echo "No hosts backup found"
fi
exit

--- End code ---


Good luck

--- End quote ---

Thanks! As far as i see, the script i found (in the kubuntuforums btw) is even wider using not only mvps but also other sources of host lists and merging them.

In the way, Misalf taught me, i.e. using cat ~/<hostlistfilename> >> /etc/hosts in bootsync, i do not even need a backup (my home is set persistent via bootcode): I do not have to touch the default procedure of setting the host name, works with busybox wget - no need of GNU wget -  and it works flawlessly ... (i'll attach the new script).

Misalf:
I've changed a lot of things to make the script more reliable, especially related to my slow internet connection. Having wget.tcz loaded works better than busybox wget as GNU wget can continue a download even if output is STDOUT. Both will do fine though if it's faster than 56kbit. ;)

Navigation

[0] Message Index

[*] Previous page

Go to full version