$ wc -l * | sort -n | tail
274 exim4
286 apache2
290 dnsmasq
298 nfs-common
350 clamav-freshclam
364 udev
386 checkroot.sh
420 clamav-daemon
465 clamav-milter
9893 total
If you look into these, you'll find tons of near-duplicate code between scripts, and frequently every script reinvents the wheel in one way or another.Simplicity really does buy me something.
$ wc -l /usr/src/sbin/init/init.c
1450 /usr/src/sbin/init/init.c
$ wc -l /etc/rc
537 /etc/rc
$ wc -l /etc/rc.d/*
21 /etc/rc.d/amd
11 /etc/rc.d/apmd
21 /etc/rc.d/avahi_daemon
21 /etc/rc.d/avahi_dnsconfd
11 /etc/rc.d/bgpd
15 /etc/rc.d/bootparamd
9 /etc/rc.d/cron
14 /etc/rc.d/cvsyncd
16 /etc/rc.d/dbus_daemon
15 /etc/rc.d/dhcpd
11 /etc/rc.d/dhcrelay
12 /etc/rc.d/dvmrpd
11 /etc/rc.d/ftpd
11 /etc/rc.d/ftpproxy
9 /etc/rc.d/hostapd
9 /etc/rc.d/hotplugd
11 /etc/rc.d/httpd
13 /etc/rc.d/identd
9 /etc/rc.d/ifstated
17 /etc/rc.d/iked
9 /etc/rc.d/inetd
17 /etc/rc.d/isakmpd
17 /etc/rc.d/iscsid
11 /etc/rc.d/ldapd
15 /etc/rc.d/ldattach
11 /etc/rc.d/ldomd
11 /etc/rc.d/ldpd
11 /etc/rc.d/lockd
9 /etc/rc.d/lpd
16 /etc/rc.d/mopd
17 /etc/rc.d/mountd
9 /etc/rc.d/mrouted
18 /etc/rc.d/nfsd
11 /etc/rc.d/npppd
38 /etc/rc.d/nsd
12 /etc/rc.d/ntpd
11 /etc/rc.d/ospf6d
11 /etc/rc.d/ospfd
24 /etc/rc.d/pflogd
11 /etc/rc.d/popa3d
11 /etc/rc.d/portmap
16 /etc/rc.d/rarpd
9 /etc/rc.d/rbootd
289 /etc/rc.d/rc.subr
11 /etc/rc.d/relayd
11 /etc/rc.d/ripd
9 /etc/rc.d/route6d
11 /etc/rc.d/rsyncd
11 /etc/rc.d/rtadvd
11 /etc/rc.d/rtsold
9 /etc/rc.d/rwhod
11 /etc/rc.d/sasyncd
13 /etc/rc.d/sendmail
9 /etc/rc.d/sensorsd
11 /etc/rc.d/slowcgi
13 /etc/rc.d/smtpd
11 /etc/rc.d/sndiod
12 /etc/rc.d/snmpd
26 /etc/rc.d/spamd
25 /etc/rc.d/spamlogd
13 /etc/rc.d/sshd
11 /etc/rc.d/statd
15 /etc/rc.d/syslogd
12 /etc/rc.d/tftpd
11 /etc/rc.d/tftpproxy
9 /etc/rc.d/tor
32 /etc/rc.d/unbound
9 /etc/rc.d/watchdogd
11 /etc/rc.d/wsmoused
9 /etc/rc.d/xdm
16 /etc/rc.d/ypbind
11 /etc/rc.d/ypldap
28 /etc/rc.d/yppasswdd
13 /etc/rc.d/ypserv
1285 totalOtherwise should we also count the C compiler, libc, all the CLI utilities and the kernel?
But here you go. Still smaller than systemd. Sysvinit needs a shell too...
$ wc -l /usr/src/bin/ksh/*.[ch]
127 /usr/src/bin/ksh/alloc.c
1412 /usr/src/bin/ksh/c_ksh.c
935 /usr/src/bin/ksh/c_sh.c
560 /usr/src/bin/ksh/c_test.c
53 /usr/src/bin/ksh/c_test.h
201 /usr/src/bin/ksh/c_ulimit.c
60 /usr/src/bin/ksh/config.h
829 /usr/src/bin/ksh/edit.c
86 /usr/src/bin/ksh/edit.h
2163 /usr/src/bin/ksh/emacs.c
1333 /usr/src/bin/ksh/eval.c
1433 /usr/src/bin/ksh/exec.c
107 /usr/src/bin/ksh/expand.h
593 /usr/src/bin/ksh/expr.c
984 /usr/src/bin/ksh/history.c
438 /usr/src/bin/ksh/io.c
1653 /usr/src/bin/ksh/jobs.c
13 /usr/src/bin/ksh/ksh_limval.h
1643 /usr/src/bin/ksh/lex.c
132 /usr/src/bin/ksh/lex.h
196 /usr/src/bin/ksh/mail.c
786 /usr/src/bin/ksh/main.c
1149 /usr/src/bin/ksh/misc.c
91 /usr/src/bin/ksh/mknod.c
285 /usr/src/bin/ksh/path.c
267 /usr/src/bin/ksh/proto.h
420 /usr/src/bin/ksh/sh.h
1161 /usr/src/bin/ksh/shf.c
82 /usr/src/bin/ksh/shf.h
897 /usr/src/bin/ksh/syn.c
231 /usr/src/bin/ksh/table.c
183 /usr/src/bin/ksh/table.h
420 /usr/src/bin/ksh/trap.c
708 /usr/src/bin/ksh/tree.c
141 /usr/src/bin/ksh/tree.h
57 /usr/src/bin/ksh/tty.c
37 /usr/src/bin/ksh/tty.h
1210 /usr/src/bin/ksh/var.c
10 /usr/src/bin/ksh/version.c
2128 /usr/src/bin/ksh/vi.c
25214 total 142 mysql
142 sysfs
157 kexec
172 udev
172 xdm
182 apache2
195 bootmisc
232 named
297 dmcrypt
736 net.lo
This is on an OpenRC Gentoo system. There's very little duplicated code in the init scripts.You might well complain that many these init scripts are substantially longer than the equivalent systemd unit files. Your complaint would be valid. Thing is, many of these init scripts do so much more than the equivalent systemd unit files. Ferinstance, the postgres and mysql unit files that I've seen permit no user configuration (like, such as, altering daemon listen port, config file location, and the like). [0] They also don't do any sort of housekeeping such as verification of the validity of the service's configuration file, checking and repairing mode and ownership of the same, and verifying the existence of the service's data directory.
I understand that OpenRC wasn't being considered for Debian Jessie, but it does a lot of things right, and is (IMO) head-and-shoulders above SysV init. (But then, isn't even bringing up SysV init kind of beating on a dead horse? We all agree that it really needs improvement.)
If you're interested, Gentoo's apache2 init script is here: http://pastebin.ca/2845519 . For reference, the apache2 systemd service file is here: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/www-... .
For a look at a simpler init script, check out the script for dnsmasq: http://pastebin.ca/2845520 . Looks pretty simple, no? At least as simple as the systemd service files we've been seeing, yes? The config file for dnsmasq is a single line: DNSMASQ_OPTS="--user=dnsmasq --group=dnsmasq" .
OpenRC provides complexity when you need it, and gets out of your way when you don't.
[0] I don't have systemd installed, so I might be missing the user configuration facilities. If they exist, and the configuration files have any appreciable complexity, then their line count must be counted against the unit file's line length.
~ # for file in `equery files openrc`; do [ -f $file ] && echo $file; done | xargs wc | tail -1 23729 196573 7432232 total
Oh, and that's with lzma compressed man pages.
Less verbose does _not_ mean simpler! In many cases it means quite the opposite.
UNIX to me is about simplicity. We don't need crap like binary logs and heavy RPC mechanisms to be polluting beautifully simple and minimal systems.
As several others have noted, the code duplication issue is solved in FreeBSD's init(8) with rc.subr.
I also suspect you're running RH. Under Debian script lengths are typically quite short:
n: 104 sum: 13553 min: 8 max: 1246 mean: 130.317308 median: 99 sd: 138.595750
That outlier, by the way, is xprint, part of CUPS. Never had to touch it myself.
Quite a few of those lines are comments, and the basic structure is a set of start / stop / restart blocks.