maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   Blocking ads on N9 (Custom hosts file HOW-TO) (https://talk.maemo.org/showthread.php?t=82180)

thedead1440 2012-11-29 12:25

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Quote:

Originally Posted by vi_ (Post 1299644)
Easy mode


As root, on device;

Code:

wget -O ~/hosts http://www.mvps.org/winhelp2002/hosts.txt && echo "127.0.0.1" $(cat /etc/hostname) "localhost" > /etc/hosts && tr -d '\015' < ~/hosts >> /etc/hosts
***big fat warning. I do not actually have an N9 so I do not know if this will actuall work...it should, it works on an n900.
***this will wipe your hosts file, so if you have put anything custom in there, you will have to re-ad it.

vi_,

The download and transfer of file to /etc/hosts works but the $(cat /etc/hostname) didn't put RM696 into the hosts file...

See:
Code:

127.0.0.1  localhost
I don't know about other n9's but my hostname file is empty:
Code:

:~# ls -al /etc/hostname
-rw-r--r--    1 root    root            0 Nov 29 20:11 /etc/hostname


I had deleted the same hosts file that I already had prior to your post so its a fresh test...


Edit: Why not replace (cat /etc/hostname) with (uname -n)?

Edit 2: Replacing with (uname -n) in your command didn't do the change too; will check and report...

vi_ 2012-11-29 12:32

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
fixed:

Code:

wget -O ~/hosts http://www.mvps.org/winhelp2002/hosts.txt && echo "127.0.0.1 RM696 localhost" > /etc/hosts && tr -d '\015' < ~/hosts >> /etc/hosts
I was trying to write a generic script that would work on any device, however I have now changed it to specifically put the 'RM696' in hosts. So the above is N9 only.


I cannot imagine why:
Code:

echo "127.0.0.1" $(uname -n) "localhost"
Does not work for you, it works for me. I did not use because I did not know about it! uname -n >> /vi_/brain/unix_vocabulary.

thedead1440 2012-11-29 12:43

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Are you sure it works correctly with uname -n?

Doing:
Code:

~# wget -O ~/hosts http://www.mvps.org/winhelp2002/hosts.txt && echo "127.0.0.1" $(uname -n) "localhost" > /etc/hosts && tr -d '\015' < ~/hosts >> /etc/hosts
Creates the entry of "127.0.0.1 RM696 localhost" into the first line of file instead...


Edit: Would you know how to instead in the above commands replace the contents of line 23 with the echo command instead?

Edit 2: Ah just realized my stupidness...The uname echo can remain as first line; it won't make any difference...

Hacker 2013-02-18 08:00

This works like a charm to speed up the browser! Are there any new host files to update with?

thedead1440 2013-02-18 08:07

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Quote:

Originally Posted by Hacker (Post 1323570)
This works like a charm to speed up the browser! Are there any new host files to update with?

Updated Jan 18 2013; same as vi_'s one-liner above:

Code:

wget -O ~/hosts http://winhelp2002.mvps.org/hosts.txt && echo "127.0.0.1" $(uname -n) "localhost" > /etc/hosts && tr -d '\015' < ~/hosts >> /etc/hosts

E: If you just recently ran the one-liner then you are surely updated as the updates are just pushed to the same URL ;)

marmistrz 2013-02-18 14:28

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
I guess that on N950 you need to replace RM696 with RM680, right?

thedead1440 2013-02-18 14:33

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Quote:

Originally Posted by marmistrz (Post 1323626)
I guess that on N950 you need to replace RM696 with RM680, right?

The one-liner reads your hostname and does the change accordingly so you don't need to do anything other than the one-liner...

marmistrz 2013-02-18 14:37

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Quote:

Originally Posted by thedead1440 (Post 1323628)
The one-liner reads your hostname and does the change accordingly so you don't need to do anything other than the one-liner...

thx,

the one liner should be put into the op. Or maybe a deb on apps for meego! :)

thedead1440 2013-02-18 14:51

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
Quote:

Originally Posted by marmistrz (Post 1323630)
the one liner should be put into the op.

Done... ;)

Mark Twain 2013-05-15 15:08

Re: Blocking ads on N9 (Custom hosts file HOW-TO)
 
I have a strange issue with that.

I downloaded the ad-blocking hosts file from the link given and changed 127.0.0.1 localhost to 127.0.0.1 RM696 localhost manually with kate (I'm on Kubuntu). Then I transferred the new hosts file to my Downloads directory and replaced the original /etc/hosts (I made a copy before).

Everything works fine except the fact that I am not able to access any website when I am in my wireless home network:eek:

What is really strange about this issue that I got it working back again when I changed my hosts file back to the standard one. When I tried out the ad-blocking hosts file again it didn't work again for me. But now my old hosts file does not work too! Any tips?

Edit: Well, obviously this could not be caused by the hosts file. there was some encryption error, I changed b&g to b and then to auto108mbps and now it is working again. Very strange. yesterday I downloaded some maps through my wifi...:confused:


All times are GMT. The time now is 13:54.

vBulletin® Version 3.8.8