Harald Hoyer fe68ba
From c4f8329cc2b158c8d91ad9d9b7776b3970d3735a Mon Sep 17 00:00:00 2001
Harald Hoyer fe68ba
From: Tony Asleson <tasleson@redhat.com>
Harald Hoyer fe68ba
Date: Mon, 2 Apr 2018 09:32:12 -0500
Harald Hoyer fe68ba
Subject: [PATCH] Initial Stratis support
Harald Hoyer fe68ba
Harald Hoyer fe68ba
Ref. https://github.com/stratis-storage
Harald Hoyer fe68ba
Harald Hoyer fe68ba
Signed-off-by: Tony Asleson <tasleson@redhat.com>
Harald Hoyer fe68ba
---
Harald Hoyer fe68ba
 modules.d/90stratis/module-setup.sh       | 34 +++++++++++++++++++++++++++++++
Harald Hoyer fe68ba
 modules.d/90stratis/stratisd-init.service | 15 ++++++++++++++
Harald Hoyer fe68ba
 modules.d/90stratis/stratisd-start.sh     |  3 +++
Harald Hoyer fe68ba
 modules.d/90stratis/stratisd-stop.sh      |  6 ++++++
Harald Hoyer fe68ba
 4 files changed, 58 insertions(+)
Harald Hoyer fe68ba
Harald Hoyer fe68ba
diff --git a/modules.d/90stratis/module-setup.sh b/modules.d/90stratis/module-setup.sh
Harald Hoyer fe68ba
new file mode 100755
Harald Hoyer fe68ba
index 00000000..2787b63b
Harald Hoyer fe68ba
--- /dev/null
Harald Hoyer fe68ba
+++ b/modules.d/90stratis/module-setup.sh
Harald Hoyer fe68ba
@@ -0,0 +1,34 @@
Harald Hoyer fe68ba
+#!/bin/bash
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+# called by dracut
Harald Hoyer fe68ba
+check() {
Harald Hoyer fe68ba
+    require_binaries stratisd-init thin_check thin_repair || return 1
Harald Hoyer fe68ba
+    return 255
Harald Hoyer fe68ba
+}
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+# called by dracut
Harald Hoyer fe68ba
+depends() {
Harald Hoyer fe68ba
+    echo dm
Harald Hoyer fe68ba
+    return 0
Harald Hoyer fe68ba
+}
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+# called by dracut
Harald Hoyer fe68ba
+installkernel() {
Harald Hoyer fe68ba
+    instmods xfs
Harald Hoyer fe68ba
+}
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+# called by dracut
Harald Hoyer fe68ba
+install() {
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+    inst_multiple stratisd-init thin_check thin_repair
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+    if dracut_module_included "systemd"; then
Harald Hoyer fe68ba
+        inst_simple "${moddir}/stratisd-init.service" "${systemdsystemunitdir}/stratisd-init.service"
Harald Hoyer fe68ba
+        mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants"
Harald Hoyer fe68ba
+        ln -rfs "${initdir}${systemdsystemunitdir}/stratisd-init.service" "${initdir}${systemdsystemunitdir}/sysinit.target.wants/stratisd-init.service"
Harald Hoyer fe68ba
+    else
Harald Hoyer fe68ba
+        inst_hook cmdline 25 "$moddir/stratisd-start.sh"
Harald Hoyer fe68ba
+        inst_hook cleanup 25 "$moddir/stratisd-stop.sh"
Harald Hoyer fe68ba
+    fi
Harald Hoyer fe68ba
+}
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
diff --git a/modules.d/90stratis/stratisd-init.service b/modules.d/90stratis/stratisd-init.service
Harald Hoyer fe68ba
new file mode 100644
Harald Hoyer fe68ba
index 00000000..318e8c27
Harald Hoyer fe68ba
--- /dev/null
Harald Hoyer fe68ba
+++ b/modules.d/90stratis/stratisd-init.service
Harald Hoyer fe68ba
@@ -0,0 +1,15 @@
Harald Hoyer fe68ba
+[Unit]
Harald Hoyer fe68ba
+Description=A daemon that manages a pool of block devices to create flexible file systems
Harald Hoyer fe68ba
+Documentation=man:stratisd(8)
Harald Hoyer fe68ba
+Before=local-fs-pre.target
Harald Hoyer fe68ba
+DefaultDependencies=no
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+[Service]
Harald Hoyer fe68ba
+Type=simple
Harald Hoyer fe68ba
+ExecStart=/sbin/stratisd-init --debug
Harald Hoyer fe68ba
+KillSignal=SIGINT
Harald Hoyer fe68ba
+StandardOutput=syslog
Harald Hoyer fe68ba
+StandardError=syslog
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+[Install]
Harald Hoyer fe68ba
+WantedBy=sysinit.target
Harald Hoyer fe68ba
diff --git a/modules.d/90stratis/stratisd-start.sh b/modules.d/90stratis/stratisd-start.sh
Harald Hoyer fe68ba
new file mode 100755
Harald Hoyer fe68ba
index 00000000..afcd81fd
Harald Hoyer fe68ba
--- /dev/null
Harald Hoyer fe68ba
+++ b/modules.d/90stratis/stratisd-start.sh
Harald Hoyer fe68ba
@@ -0,0 +1,3 @@
Harald Hoyer fe68ba
+#!/bin/sh
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+stratisd-init --debug > /dev/kmsg 2>&1 &
Harald Hoyer fe68ba
\ No newline at end of file
Harald Hoyer fe68ba
diff --git a/modules.d/90stratis/stratisd-stop.sh b/modules.d/90stratis/stratisd-stop.sh
Harald Hoyer fe68ba
new file mode 100755
Harald Hoyer fe68ba
index 00000000..f394a843
Harald Hoyer fe68ba
--- /dev/null
Harald Hoyer fe68ba
+++ b/modules.d/90stratis/stratisd-stop.sh
Harald Hoyer fe68ba
@@ -0,0 +1,6 @@
Harald Hoyer fe68ba
+#!/bin/sh
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+[ -f /lib/dracut-lib.sh ] && . /lib/dracut-lib.sh
Harald Hoyer fe68ba
+
Harald Hoyer fe68ba
+pid=$(pidof stratisd-init)
Harald Hoyer fe68ba
+[ -n "$pid" ] && kill ${pid}
Harald Hoyer fe68ba