7.16. Creating a DenyHosts Startup File

You installed DenyHosts from the source tarball, so you need to know how to set up an init script to start it automatically at boot, and for starting and stopping it manually.

daemon-control-dist is the model startup file; you'll need to edit it for your particular Linux distribution. Only the first section needs to be edited:

	#########################################
	# Edit these to suit your configuration #
	#########################################
	
	DENYHOSTS_BIN = "/usr/bin/denyhosts.py"
	DENYHOSTS_LOCK = "/var/lock/subsys/denyhosts"
	DENYHOSTS_CFG = "/etc/denyhosts.cfg"

Make sure the filepaths and filenames are correct for your system. Then give the file a name you can type reasonably, like /etc/init.d/denyhosts.

Configuring DenyHosts to start at boot is done in the usual manner, using chkconfig on Red Hat and Fedora, and update-rc.d on Debian:

	# chkconfig denyhosts --add
	# chkconfig denyhosts on

	# update-rc.d start 85 2 3 4 5 . stop 30 0 1 6 .

Manually stopping and starting DenyHosts is done in the usual manner:

	# /etc/init.d/denyhosts {start|stop|restart|status|debug}

Fedora users also have this option:

	# /etc/init.d/denyhosts condrestart

This restarts DenyHosts only if it already running; otherwise, it fails silently.

When you create a new init script on Fedora, you must first add it to the control of chkconfig with the chkconfig--add command. Then, you can use the chkconfig foo on/off command to start or stop it at boot.