I wanted to have a web application through which I can access my sockets through a computer or iPad. The following components make this possible:
First, develop and trouble shoot the daemon binary.
Start the daemon, then find it's process id (pid):
$ ps -ax | grep <daemon>
Find all open files:
# lsof -p <pid>
On Debian systems, copy the skeleton file and modify to your needs. This is quite simple and straight forward.
# cp /etc/init.d/skeleton ~/scripts/<daemon> # vim <daemon>
Copy the binary file:
# cp ~/binaries/<daemon> /usr/sbin
Copy the script:
# cp ~/scripts/<daemon> /etc/init.d
Add the daemon to the different run-levels:
# update-rc.d <daemon> defaults
Remove the daemon from the different run-levels:
# update-rc.d -f <daemon> remove
See Daemon and LSBInitScripts for more details.
Run
crontab -e
and enter the following lines:
*/5 * * * * wget http://localhost/path/to/web/code/state-machine.php * 14 * * * wget http://localhost/path/to/web/code/randomize.php
The first line will run the state machine every 5 minutes. The second line will randomize your on / off pattern every day at 14:00.