mirror of
https://github.com/prurigro/buildhosts.git
synced 2024-11-21 13:52:31 -05:00
2.8 KiB
2.8 KiB
buildhosts
Build and maintain /etc/hosts
while including lists imported from local and remote hosts list sources.
Instructions
Note: All instructions should be performed as the root user or using the sudo
command.
Enable Remote Sources
- The first time you run the
build
command,/etc/hosts
will be moved to/etc/hosts.core
, and the file/etc/hosts.sources
will be created using the default sources list. The/etc/hosts
file will then be generated by combining/etc/hosts.core
and the resulting contents of the downloaded sources in/etc/hosts.sources
. - You can now open
/etc/hosts.sources
and remove or comment out (by adding#
in front) any sources you don't wish to use, as well as add new ones. Sources can remote (ie:http://adaway.org/hosts.txt
) as well as local (ie:file:///etc/hosts.d/mylist.txt
). - If you want to make any changes to the contents of what used to be
/etc/hosts
, you should now make them to/etc/hosts.core
, and you'll need to rerun thebuild
command to have them applied. - Once you're done customizing your configuration, run the
build
command again and the/etc/hosts
file will be regenerated using the current list of sources and your up-to-date/etc/hosts.core
file.
Disable Remote Sources
- To disable the configured hosts lists, run the
revert
command and/etc/hosts.core
will be moved back to/etc/hosts
.
- The
/etc/hosts.sources
file will continue to exist until it's manually deleted, and it will be used again the next time remote sources are enabled.
Notes on /etc/hosts.sources
- On each line of
/etc/hosts.sources
, after#
is commented/skipped. - The
$HOSTS_SYSTEM
variable can be set to an alternative location to configure a different file to be used for/etc/hosts
. - Similarly, the
$HOSTS_CORE
and$HOSTS_SOURCES
variables (which default to$HOSTS_SYSTEM.core
and$HOSTS_SYSTEM.sources
and will automatically change when$HOSTS_SYSTEM
is changed), can be set to alternative locations to configure the use of different files.
Commands
buildhosts build
: generate/etc/hosts
using/etc/hosts.core
and the configured sourcesbuildhosts revert
: remove lists imported from hosts list sources and restore/etc/hosts
buildhosts help
: display the help
Note: Colour output can be disabled by setting the variable NOCOL=1
.
Extra
- The
p2p-to-hosts
script included in this repo can be used to convert blocklists in p2p format to hosts format (usable with this package).
Credits
Written by Kevin MacMartin:
License
Released under the MIT license.