aboutsummaryrefslogtreecommitdiff
path: root/arch-daemons
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-07-28 01:32:35 +0200
committerTom Gundersen <teg@jklm.no>2012-07-28 02:35:48 +0200
commitb0b1d8fb0f933b37e5878541e18034614eed47fb (patch)
treec114a209c2c5dcdd9fa716f6d79fb14874a406d1 /arch-daemons
parent22c3b22688f451fb24f9075712fce732e9057a10 (diff)
downloadinitscripts-b0b1d8fb0f933b37e5878541e18034614eed47fb.tar.xz
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 <teg@jklm.no>
Diffstat (limited to 'arch-daemons')
-rwxr-xr-xarch-daemons57
1 files changed, 57 insertions, 0 deletions
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: