Editing /etc/hosts-file

Antworten
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Editing /etc/hosts-file

Beitrag von bobzbobz »

Hello

I am trying to create a new product-package that blocks certain websites from being displayed.
I have read that the "easiest/best" way to achieve this, is to edit the /etc/hosts-file like such:
I need to create a package that can add these lines (perhaps from a .txt-file?) and remove them again, without removing other lines in the file.
What would be the correct approach to this task? Using "loadTextFile" to read the .txt-file into separate strings and then write them somehow?
Zuletzt geändert von bobzbobz am 23 Jan 2020, 11:43, insgesamt 1-mal geändert.
Benutzeravatar
wolfbardo
uib-Team
Beiträge: 1354
Registriert: 01 Jul 2008, 12:10

Re: Editing /etc/hosts-file

Beitrag von wolfbardo »



OPSICONF 2024
https://opsi.org/en/opsiconf/

opsi-Basisworkshops:

22. - 25. 04. 2024


opsi support - uib gmbh
For productive opsi installations we recommend maintainance + support contracts which are the base of opsi development.

http://www.uib.de
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: Editing /etc/hosts-file

Beitrag von bobzbobz »

Thank you for the quick response :)

I have now created the package (might not be the prettiest code) and uploaded the scripts to the OPSI-wiki.
wiki/doku.php?id=userspace:block_websit ... hosts-file
Antworten