From b0b1d8fb0f933b37e5878541e18034614eed47fb Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 28 Jul 2012 01:32:35 +0200 Subject: merge initscripts-systemd This makes sure that systemd supports some initscripts API's. With this patch, systemd will: * Parse and use DAEMONS and MODULES from rc.conf * Run rc.local and rc.local.shutdown on boot and shutdown respectively Signed-off-by: Tom Gundersen --- arch-daemons | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 arch-daemons (limited to 'arch-daemons') diff --git a/arch-daemons b/arch-daemons new file mode 100755 index 0000000..34f4597 --- /dev/null +++ b/arch-daemons @@ -0,0 +1,57 @@ +#!/bin/bash +# +# /usr/lib/systemd/system-generators/arch-daemons +# + +. /etc/rc.conf + +[[ $1 ]] || exit 1 + +# when called at boot, this is /run/systemd/generator.late +dest=$3 + +# list of services that have to be started before the next one +deps=() + +# Make service file +create_unit() { + local deps= daemon=${1%.service} + + (( $# > 1 )) && printf -v deps 'After=%s\n' "${*:2}" + + printf \ +'[Unit] +SourcePath=/etc/rc.conf +Documentation=https://raw.github.com/falconindy/initscripts-systemd/master/README +Description=Legacy unit for %s +%s +[Service] +ExecStart=/etc/rc.d/%s start +ExecStop=/etc/rc.d/%s stop +RemainAfterExit=yes +Type=forking +' "$daemon" "$deps" "$daemon" "$daemon" > "$dest/$1" + +} + +for daemon in /etc/rc.d/*; do + create_unit "${daemon##*/}".service +done + +[[ -d $dest/multi-user.target.wants ]] || /bin/mkdir -p "$dest/multi-user.target.wants" + +for daemon in "${DAEMONS[@]}"; do + service="$daemon.service" + case ${daemon:0:1} in + '!') continue ;; + '@') create_unit "${service:1}" "${deps[@]}" + ln -s "../${service:1}" "$dest/multi-user.target.wants" + ;; + *) create_unit "$service" "${deps[@]}" + deps+=("$service") + ln -s "../$service" "$dest/multi-user.target.wants" + ;; + esac +done + +# vim: et sw=2: -- cgit v1.2.3