This is a reference for setting up various daemons (services) under djb's excellent daemontools package, which provides tools for the supervision, monitoring, and control of system processes, as well as an assortment of other useful utilities. Some of these scripts make use of software included in djb's ucspi-tcp package.
The rationale for using daemontools and ucspi-tcp is available on djb's site. Suffice it to say that any competent systems engineer will immediately recognize the benefits of these packages.
I recommend the use of /var/spool/supervise
to contain supervise
directories. I've seen
/etc/supervise
used as well.
Shameless plug: I am available to set up any of this software on either a full-time employment or consulting/contracting basis. Feel free to inquire.
run
) for various services:#!/bin/sh exec 2>&1 exec /usr/sbin/syslogd -nklogd
#!/bin/sh exec 2>&1 exec /usr/sbin/klogd -nsshd (OpenSSH)
#!/bin/sh exec 2>&1 exec /usr/local/sbin/sshd -D -ecrond
#!/bin/sh exec 2>&1 exec /usr/sbin/crond -l10 -fhttpd (Apache)
#!/bin/sh exec 2>&1 exec /usr/local/apache/bin/httpd -Fdnscache
#!/bin/sh exec 2>&1 exec <seed exec /usr/local/bin/envdir ./env sh -c ' exec /usr/local/bin/envuidgid dnscache \ /usr/local/bin/softlimit -o250 -d "$DATALIMIT" \ /usr/local/bin/dnscache 'tinydns
#!/bin/sh exec 2>&1 exec /usr/local/bin/envuidgid tinydns \ /usr/local/bin/envdir ./env \ /usr/local/bin/softlimit -d300000 \ /usr/local/bin/tinydnspure-ftpd
#!/bin/sh exec 2>&1 exec /usr/local/sbin/pure-ftpd -C 2 -E -d -4 -H -k 95 -u 100 -f nonemysqld
#!/bin/sh exec 2>&1 exec /usr/local/mysql/libexec/mysqld -u mysqlpostmaster (PostgreSQL)
#!/bin/sh exec 2>&1 PREFIX=/usr/local/pgsql exec /usr/local/bin/setuidgid postgres \ $PREFIX/bin/postmaster -i -D $PREFIX/dataspamd (SpamAssassin)
#!/bin/sh exec 2>&1 exec /usr/local/bin/spamdntpd
#!/bin/sh exec 2>&1 exec /usr/local/bin/ntpd -nimapd (Courier)
#!/bin/sh exec 2>&1 PREFIX=/usr/local/courier exec /usr/local/bin/envdir ./env \ /usr/local/bin/tcpserver -v -R -H 0 143 \ $PREFIX/sbin/imaplogin $PREFIX/libexec/authlib/authshadow \ $PREFIX/bin/imapd Maildirimapd-ssl (Courier)
#!/bin/sh exec 2>&1 PREFIX=/usr/local/courier exec /usr/local/bin/envdir ./env \ /usr/local/bin/tcpserver -v -R -H 0 993 \ $PREFIX/bin/couriertls -server \ -tcpd $PREFIX/sbin/imaplogin \ $PREFIX/libexec/authlib/authshadow \ $PREFIX/bin/imapd Maildirwebproxy (micro_proxy)
#!/bin/sh exec 2>&1 exec /usr/local/bin/setuidgid webproxy \ /usr/local/bin/tcpserver -v -H -R 0 44444 \ /usr/local/bin/micro_proxyspam-stats
#!/bin/sh exec 2>&1 exec /usr/local/bin/setuidgid spam-stats \ /usr/local/bin/tcpserver -v -H -R 0 7300 \ /usr/local/sbin/spamstats-stage1.plin.telnetd
#!/bin/sh exec 2>&1 exec /usr/local/bin/tcpserver -v -R -H \ -x telnetd/tcp.telnet.cdb 0 23 \ /usr/sbin/in.telnetdinetd
#!/bin/sh exec 2>&1 exec /usr/local/bin/fghack /usr/sbin/inetddhcpd
#!/bin/sh exec 2>&1 exec /usr/sbin/dhcpd -f eth1pptpd (PoPToP)
#!/bin/sh exec 2>&1 exec /usr/local/bin/pptpd -c /etc/pptpd.conf -f -l 10.1.1.1
supervise
directories:#!/bin/bash if [ "$2" == "" ]; then echo -e "\nUsage: $0 dir loguser\n"; exit 100 fi mkdir -p $1/log/main chown $2 $1/log/main echo -e "#!/bin/sh\nexec 2>&1" > $1/run echo -e "#!/bin/sh\nexec setuidgid $2 multilog t ./main" > $1/log/run chmod 0755 $1/run $1/log/runmakedir-auto
#!/bin/bash if [ "$3" == "" ]; then echo -e "\nUsage: $0 dir loguser runcmd\n"; exit 100 fi mkdir -p $1/log/main chown $2 $1/log/main echo -e "#!/bin/sh\nexec 2>&1\nexec $3" > $1/run echo -e "#!/bin/sh\nexec setuidgid $2 multilog t ./main" > $1/log/run chmod 0755 $1/run $1/log/run ln -s /var/spool/supervise/$1 /service