aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-07-27 23:32:35 (GMT)
committerTom Gundersen <teg@jklm.no>2012-07-28 00:35:48 (GMT)
commitb0b1d8fb0f933b37e5878541e18034614eed47fb (patch)
treec114a209c2c5dcdd9fa716f6d79fb14874a406d1
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>
-rw-r--r--Makefile10
-rw-r--r--PKGBUILD1
-rwxr-xr-xarch-daemons57
-rwxr-xr-xarch-modules-load15
-rw-r--r--arch-modules-load.service10
-rw-r--r--rc-local-shutdown.service10
-rw-r--r--rc-local.service10
7 files changed, 113 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index cebda3e..74808e5 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,10 @@ DIRS := \
/etc/logrotate.d \
/etc/profile.d \
/usr/lib/tmpfiles.d \
+ /usr/lib/systemd/system-generators \
+ /usr/lib/systemd/system/multi-user.target.wants \
+ /usr/lib/systemd/system/shutdown.target.wants \
+ /usr/lib/systemd/system/sysinit.target.wants \
/usr/sbin \
/usr/share/bash-completion/completions \
/usr/share/zsh/site-functions \
@@ -29,9 +33,15 @@ install: installdirs doc
install -m644 -t $(DESTDIR)/usr/share/man/man5 rc.conf.5
install -m644 -t $(DESTDIR)/usr/share/man/man7 archlinux.7
install -m644 -t $(DESTDIR)/usr/share/man/man8 rc.d.8
+ install -m755 -t $(DESTDIR)/usr/lib/systemd/system-generators arch-daemons
+ install -m755 -t $(DESTDIR)/usr/lib/systemd arch-modules-load
+ install -m644 -t $(DESTDIR)/usr/lib/systemd/system arch-modules-load.service rc-local.service rc-local-shutdown.service
install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/initscripts.conf
install -m644 -T bash-completion $(DESTDIR)/usr/share/bash-completion/completions/rc.d
install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d
+ ln -s ../rc-local.service ${DESTDIR}/usr/lib/systemd/system/multi-user.target.wants/
+ ln -s ../rc-local-shutdown.service ${DESTDIR}/usr/lib/systemd/system/shutdown.target.wants/
+ ln -s ../arch-modules-load.service ${DESTDIR}/usr/lib/systemd/system/sysinit.target.wants/
%.5: %.5.txt
a2x -d manpage -f manpage $<
diff --git a/PKGBUILD b/PKGBUILD
index e2e4f3d..7f0e845 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -8,6 +8,7 @@ license=('GPL')
groups=('base')
conflicts=('initscripts')
provides=('initscripts=9999')
+replaces=('initscripts-systemd')
backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown)
makedepends=('asciidoc')
depends=('glibc' 'bash' 'coreutils' 'systemd-tools' 'iproute2'
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:
diff --git a/arch-modules-load b/arch-modules-load
new file mode 100755
index 0000000..e522c2b
--- /dev/null
+++ b/arch-modules-load
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# /usr/lib/systemd/arch-modules-load
+#
+
+. /etc/rc.conf
+
+# generate list of modules to be loaded by systemd-module-load in /run/modules-load.d/
+if [[ $MODULES ]]; then
+ mkdir /run/modules-load.d
+ echo "# Autogenerated by /usr/lib/systemd/arch-modules-load" > /run/modules-load.d/rc.conf
+ printf '%s\n' "${MODULES[@]}" >> /run/modules-load.d/rc.conf
+fi
+
+# vim: set noet ts=2 sw=2:
diff --git a/arch-modules-load.service b/arch-modules-load.service
new file mode 100644
index 0000000..f400d48
--- /dev/null
+++ b/arch-modules-load.service
@@ -0,0 +1,10 @@
+[Unit]
+SourcePath=/etc/rc.conf
+Documentation=https://raw.github.com/falconindy/initscripts-systemd/master/README
+Description=Load modules defined in rc.conf
+DefaultDependencies=no
+Before=systemd-modules-load.service
+
+[Service]
+ExecStart=/usr/lib/systemd/arch-modules-load
+Type=oneshot
diff --git a/rc-local-shutdown.service b/rc-local-shutdown.service
new file mode 100644
index 0000000..b8fb291
--- /dev/null
+++ b/rc-local-shutdown.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=/etc/rc.local.shutdown Compatibility
+After=rc-local.service
+ConditionPathIsExecutable=/etc/rc.local.shutdown
+
+[Service]
+Type=oneshot
+ExecStart=/etc/rc.local.shutdown
+StandardInput=tty
+RemainAfterExit=yes
diff --git a/rc-local.service b/rc-local.service
new file mode 100644
index 0000000..6c4c412
--- /dev/null
+++ b/rc-local.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=/etc/rc.local Compatibility
+ConditionPathIsExecutable=/etc/rc.local
+
+[Service]
+Type=oneshot
+ExecStart=/etc/rc.local
+TimeoutSec=0
+StandardInput=tty
+RemainAfterExit=yes