Closed eksperimental closed 3 years ago
Hi @eksperimental,
You can make your changes to the hosts file persistent by adding them to /etc/hosts.original
instead of /etc/hosts
.
Background info:
/etc/hosts.original
as the backup of the original /etc/hosts
and it'll be used as the base when its updating the hosts file.adsorber disable
the hosts file will be restored to its original form by moving /etc/hosts.original
to /etc/hosts
leaving it like adsorber has never been there.But I've to admit, the documentation does not give any information how to add persistent values. Will add it later today.
Hi @eksperimental,
You can make your changes to the hosts file persistent by adding them to
/etc/hosts.original
instead of/etc/hosts
.Background info:
* Adsorber creates `/etc/hosts.original` as the backup of the original `/etc/hosts` and it'll be used as the base when its updating the hosts file. * Also when you remove adsorber from the system or when you disable it with `adsorber disable` the hosts file will be restored to its original form by moving `/etc/hosts.original` to `/etc/hosts` leaving it like adsorber has never been there.
thank you for your answer. Yes, I know that. but it just happened to me that I edited the files and when I upgraded my system, I realized the changes were lost. From a usability point of view if the software can mark the edited section and only modify that, It is less overhead for the user. Also, what happens when there is another software that also edit /etc/hosts ?
When another application is writing to /etc/hosts
the changes are gone.
I never thought about that.
Is there any application that does write to /etc/hosts
? To my knowledge Docker does that but only inside a container.
another software like adsorber, or maybe command line instructions, or custom bash functions such as https://gist.github.com/irazasyed/a7b0a079e7727a4315b9
It should not be expected that someone will open up the file and read the initial comment saying it should not be edited. Well, those are my two cents
Ok I see, you are right. I'll see what I can do.
Thanks for reporting.
Awesome and thank you. perl seems like the right tool for the job. Let me know if I can help with anything. But any tool that can use a regex and replace will do
I would like to stick to sed
. It's already being used, and perl would be another dependency. Expect a new version somewhere around the weekend.
Thank you @stablestud
Besides the comment, I think AdSorber should not discard changes in /etc/hosts. What it should, I think, is make the block of hosts delimited with a start and end comment. Leave a comment saying this block will be overwritten in the next update, but only delete these chunk and preserve the rest of the file as is