How would I make this program start up automatically?

https://github.com/KrasnayaSecurity/DomainBlocker

Preferably using an installation shell script, or some easily automate-able feature, what would be the best way to make this program start up automatically on Linux?

I help run a private proxy server, and it would be useful to use this program instead of just relying on our private DNS server. BIND allows blocking of all subdomains though (DNS wildcard), but not hosts.

4 Replies

Until recently, the approach would be to write an init script and install it as part of application installation. Of course not all distros are LSB compliant so custom futzing may be necessary.

Now with some distributions moving to systemd, this may not be the right way to do things for those distros (supposedly systemd will interpret an LSB init script, but in practice… seems tricky). You may be better off writing a service file for those.

I don't have first-hand experience so can't provide guidance on the easiest way to approach things. My impression is this will be an ugly task no matter which path you take and all you can do is minimize the pain. But then I'm a pessimist.

I create a script like /etc/init.d/myscript.sh then run:

update-rc.d myscript.sh defaults

Thank you for your help.

Will it run as root? The program I am making blocks malicious domains in the hosts file. Is there a way to make it not run as root, in case I make a program that does not need to be root?

I typed this into Google "ubuntu 14.04 updaterc.d" and the second link seems to do what you want in the latter case:

http://mobiarch.wordpress.com/2014/05/1 … ntu-14-04/">http://mobiarch.wordpress.com/2014/05/16/creating-an-init-script-in-ubuntu-14-04/

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct