G. Pape
runit
How to replace init

runit - collection of run scripts


This is a collection of run scripts for popular services to have them monitored by the daemontools or runit package. If you have additional run scripts or one of these run scripts works for you on an operating system not stated here, please let me know.

Thanks go to the following people for contributing run scripts: Alessandro Bono, Robin S. Socha, Claus Alboege, Paul Jarc, clemens fischer, Jesse Cablek, Lukas Beeler, Thomas Baden, Ralf Hildebrandt, Antonio Dias.


apache
apache2
bind9
boa
cfengine
courier-imap
cups
dhclient
dhcpcd
dhcpd
expireproctitle
fam
gdm
getty
identd
inn
klogd
logging Linux kernel messages
logging console messages
mysql
ntpd
pop3-ssl
postgresql
ppp
proftpd
pure-ftpd
radiusd
rsyncd
samba (smbd, nmbd)
squid
sshd
sshd under tcpserver
statd, mountd
stunnel
taiclockd
tomcat
wvdial
xdm

An apache run script

(SunOS, Apache 1.*, patched to run under supervise)
 #!/bin/sh
 exec 2>&1
 exec env -i \
 /pack/apache/1.3.27-1/sbin/httpd -F 2>&1
(Debian woody)
 #!/bin/sh
 exec 1>&2
 exec apache-ssl -F

An apache2 run script

(SunOS)
 #!/bin/sh
 exec 2>&1
 exec env -i /command/pgrphack \
 /pack/apache/2.0.43-1/sbin/httpd -DFOREGROUND 2>&1
(HP-UX/GNU, Linux)
 #!/bin/sh
 TZ=MET-1METDST
 export TZ
 exec /usr/local/apache2/bin/httpd -DNO_DETACH

A bind9 run script

(Linux)
 #!/bin/sh
 MEM="`head -1 ./env/MEM`"
 CHROOT="`head -1 ./env/CHROOT`"
 exec softlimit -m "${MEM}" \
   named -u bind -t "${CHROOT}" -g 2>&1
(HP-UX/GNU, Linux)
 #!/bin/sh
 exec /usr/sbin/named -f -t /var/spool/named/ -u named

A boa run script

(SunOS)
 #!/bin/sh
 exec 2>&1
 ulimit -n 1024
 exec /pack/boa/current/boa -c /pack/boa/current -d 2>&1

A cfengine run script

(SunOS)
 #!/bin/sh
 /pack/cfengine/sbin/cfagent --file /pack/cfengine/etc/cfagent.conf \
   -L -v -q exec sleep 3600

A courier-imap run script

(SunOS)
 #!/bin/sh
 exec 2>&1
 PREFIX="/usr/lib/courier-imap"
 exec envdir ./env \
   tcpserver -v -R 0 143 \
   $PREFIX/sbin/imaplogin \
   $PREFIX/libexec/authlib/authshadow \
   $PREFIX/libexec/authlib/authvchkpw \
   $PREFIX/bin/imapd Maildir
See also this page.

A cups run script

(Debian woody, a.bono)
 #!/bin/sh
 exec 2>&1
 exec /usr/sbin/cupsd -f

A dhclient run script

(Debian woody)
 #!/bin/sh
 exec dhclient -e -d -cf ./config -lf ./leases -pf ./pid eth1

A dhcpcd run script

(Linux, DHCP Client Daemon v.scriptconfig-0.1)
 #!/bin/sh
 dhcpcd -a -d -D -H eth0

A dhcpd run script

(Debian woody)
 #!/bin/sh
 exec 2>&1
 exec dhcpd-2.2.x -f -d -cf ./config eth0
This service needs a log service to be set up.

(Solaris 8, uses additional dsvclockd service, would get fired off automatically, but then it's not supervised)

 #!/bin/sh
 exec 2>&1
 exec /command/envdir ./env /usr/lib/inet/dsvclockd -f
 #!/bin/sh
 if /command/svok /service/dsvclockd; then
   /usr/bin/sleep 2 # wait to make sure dsvclockd is initialized
   exec 2>&1
   exec /command/envdir ./env /usr/lib/inet/in.dhcpd -b manual -d # -v
 fi
 echo dsvclockd is not running - aborting
 exec /usr/bin/sleep 5
The in.dhcpd service needs a log service to be set up.

expireproctitle run script examples

(Linux)
 #!/bin/sh
 echo -n .
 exec sleep 300

A fam run script

(Slackware Linux 9.0)
 #!/bin/sh
 exec 2>&1
 exec /usr/bin/fam -L -f -v
This service needs a log service to be set up.

A gdm run script

(Debian woody)
 #!/bin/sh
 exec gdm -nodaemon

A mingetty run script

(Debian)
 #!/bin/sh
 exec mingetty tty5
The runit package does not care about utmp records for getties. You should choose a getty that handles its own utmp and wtmp records. Debian's mingetty does create his own utmp record.

An agetty run script

(Slackware Linux 9.0)
 #!/bin/sh
 exec /sbin/agetty 38400 tty1 linux

An oidentd run script

(Linux, oidentd version 2.0.6)
 #!/bin/sh
 exec 2>&1
 exec oidentd -i -S -t 10 -u daemon -g daemon
This service needs a log service to be set up.

An innd run script

(Linux)
 #!/bin/sh
 MEM="`head -1 ./env/MEM`"
 exec softlimit -m "${MEM}" \
   setuidgid news \
   /usr/sw/bin/news/inndstart -f -r

A klogd run script

(Debian woody)
 #!/bin/sh
 exec /sbin/klogd -n

A run script for logging Linux kernel messages with multilog

(Linux)
 #!/bin/sh -e
 exec < /proc/kmsg \
 setuidgid loguser \
 multilog t n64 ./main

A mysql run script

(SunOS)
 #!/bin/sh
 exec setuidgid mysql /pack/mysql/current/libexec/mysqld \
         --basedir=/pack/mysql/current \
         --datadir=/pack/mysql/data/ \
         --socket=/tmp/mysql.sock \
         --pid-file=/pack/mysql/data/mysql.pid 2>&1
(Linux, mysqld Ver 3.23.54-max for pc-linux on i686)
 #!/bin/sh
 cd /usr/local/mysql
 ./bin/safe_mysqld
 cd

A ntpd run script

(Linux)
 #!/bin/sh
 MEM="`head -1 ./env/MEM`"
 exec softlimit -m ${MEM} \
   ntpd -n -p /var/run/ntpd.pid

A pop3-ssl run script

(BSD)
 #!/bin/sh
 exec /usr/local/bin/tcpserver -R -v -c 50 0 995 /usr/local/sbin/stunnel
 -f  -p /etc/ssl/stunnel.pem \
 -l /var/qmail/bin/qmail-popup -- /var/qmail/bin/qmail-popup
 "`cat /var/qmail/control/me`" vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1
This service needs a log service to be set up.

A postgresql run script

(SunOS)
 #!/bin/sh
 exec setuidgid postgres /pack/postgresql/current/bin/postmaster \
   -D /pack/postgresql/data 2>&1

A ppp run script

(FreeBSD)
 #!/bin/sh
 exec 2>&1
 echo "ppp -ddial dsl "
 exec /usr/sbin/ppp -unit0 -foreground dsl

A proftpd run script

(Linux, ProFTPD Version 1.2.8rc1, configure it to use 'ErrorLog "/dev/stdout"')
 #!/bin/sh
 exec 2>&1
 exec proftpd -n -d 1
This service needs a log service to be set up.

A pure-ftpd run script

(Debian woody, a.bono)
 #!/bin/sh
 exec 2>&1
 exec /usr/sbin/pure-ftpd -a 50 -E -l pam -u 100

A radiusd run script

(Slackware Linux 9.0, cistron radius 1.6.1)
 #!/bin/sh
 exec 2>&1
 exec radiusd -f -y -z -lstdout
This service needs a log service to be set up.

A rsyncd run script

(SunOS)
 #!/bin/sh
 exec 2>&1
 exec softlimit -d 100000000 /usr/local/bin/tcpserver \
   -x /pack/rsync/rsync.service/tcp.rsync.cdb -v -c 100 -U -H -l 0 -R \
   1.2.3.4 873 nice -2 /pack/rsync/bin/rsync --daemon --no-detach \
   --config /pack/rsync/etc/rsyncd.conf
This service needs a log service to be set up.

A smbd run script

(Linux, smbd Version 2.2.7a)
 #!/bin/sh
 PATH="/usr/local/samba/bin"
 exec 2>&1
 exec smbd -i -d3
This service needs a log service to be set up.

A nmbd run script

(Linux, nmbd Version 2.2.7a)
 #!/bin/sh
 PATH="/usr/local/samba/bin"
 exec 2>&1
 exec nmbd -i -d1
This service needs a log service to be set up.

A squid run script

(Debian woody)
 #!/bin/sh
 exec squid -f ./config -sN

A sshd run script

(Debian woody, sshd version OpenSSH_2.9p2)
 #!/bin/sh
 exec 2>&1
 exec sshd -D -e
This service needs a log service to be set up.

A sshd (under tcpserver) run script

(Linux, sshd version OpenSSH_3.4p1)
 #!/bin/sh -e
 exec 2>&1
 exec \
 tcpserver -1vpdl0 -Xxtcp.cdb 0 ssh \
 sshd -ief config
This service needs a log service to be set up.

A statd run script

(Debian woody)
 #!/bin/sh
 exec 2>&1
 NEED_LOCKD=yes
 if test -f /proc/ksyms; then
   # We need to be conservative and run lockd,
   # unless we can prove that it isn't required.
   grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
 fi
 if [ "$NEED_LOCKD" = yes ]; then
   /sbin/rpc.lockd
 fi
 exec rpc.statd -F -d
This service needs a log service to be set up.

A mountd run script

(Debian woody)
 #!/bin/sh
 svwaitup /service/statd
 RPCNFSDCOUNT=8  # Number of servers to be started up by default
 RPCMOUNTDOPTS=-F
 exportfs -r
 rpc.nfsd -- $RPCNFSDCOUNT
 rpcinfo -u localhost nfs 3 >/dev/null 2>&1 ||
   RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
 exec rpc.mountd $RPCMOUNTDOPTS

A stunnel run script

(BSD)
 #!/bin/sh
 exec /usr/local/sbin/stunnel -f -d 1234 -r 25 -v3 -a /etc/ssl/mailcerts 2>&1

A taiclockd run script

 #!/bin/sh
 exec 2>&1
 exec setuidgid taiclock /usr/local/clockspeed/bin/taiclockd

A tomcat run script

(SunOS)
 #!/bin/sh
 exec 2>&1
 exec \
 setuidgid apache \
 /pack/tomcat/current/bin/catalina.sh run

A wvdial run script

(Slackware Linux 9.0, the service should have a down file, use svc -o /service/wvdial to bring up a ppp connection)
 #!/bin/sh
 exec 2>&1
 exec wvdial ISP
This service needs a log service to be set up.

A xdm run script

(Linux)
 #!/bin/sh
 svwaitup -s 2 /service/vc-*
 exec xdm -nodaemon

Gerrit Pape <pape@smarden.org>
$Id$