7 ms·
Simple scripts? Have you looked at the shit in /etc/init.d in a modern linux distribution? $ wc -l * | sort -n | tail 274 exim4 286 apache2 290 dns
by mmagin 12y ago
Simple scripts? Have you looked at the shit in /etc/init.d in a modern linux distribution?
$ 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.
- mmagin 12y agoAnd on my Debian testing system with systemd, the longest service definition is 46 lines! (/lib/systemd/system/getty@.service)
- jsmthrowaway 12y agoThe comment makes more sense if you substitute "familiar" for "simple," a tactic I use a lot while reading arguments like these.
- deleted 12y ago[deleted]
- deleted 12y ago[deleted]
- deleted 12y ago[deleted]
- ultramancool 12y agoUsing sysvinit doesn't require a domain specific configuration language to be known and understood. So I think simpler is quite valid. 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.
- jude- 12y agoIf duplicate code bothers you this much, then what stops you from abstracting the common routines into something like BSD's /etc/rc.subr, and then sourcing them in the service-specific init script?
- simoncion 12y ago/etc/init.d $ for I in * ; do printf "%s %s \n" $(cat $I | grep -v -e '#' | wc -l) $I; done | sort -n | grep -v net.e | tail 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 http://pastebin.ca/2845519 . For reference, the apache2 systemd service file is here: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/www-servers/apache/files/apache2.2.service?revision=1.1&view=markup 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 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.
- cbsmith 12y agoYeah, I've got OpenRC on one of my Funtoo systems too... Let's try some different shell magic... ~ # 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.
- clarry 12y agoYes, modern linux and sysvinit are pigs compared to some alternatives (though systemd is worse). The choice isn't a binary choice between sysvinit and systemd. How about this? init + rc + all the scripts combined are smaller than your handful of daemon-specific scripts. And I understand exactly how all of this works (the kernel parts included). I can easily change any part of it, I can easily debug any part of it, I can easily extend any of it if I need special features. With systems that comprise hundreds of thousands of lines of code, just beginning to understand how all of it works together takes much more time... 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 total
- 12y ago
- dredmorbius 12y agoYou see crap. I see time-polished scripts. 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.