summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjandob2016-03-29 19:06:22 +0200
committerjandob2016-03-29 19:06:22 +0200
commit7a14d8932f1f4bba79ba4e7b8d5fe4129788e4ac (patch)
tree0de5de71c12e08e3783bc885fb7c30c4b0346c2b
parentadd logging to file functionality (diff)
parentFix. (diff)
downloadsystemd-init-7a14d8932f1f4bba79ba4e7b8d5fe4129788e4ac.tar.gz
systemd-init-7a14d8932f1f4bba79ba4e7b8d5fe4129788e4ac.tar.xz
systemd-init-7a14d8932f1f4bba79ba4e7b8d5fe4129788e4ac.zip
Merge branch 'master' of git.openslx.org:openslx-ng/systemd-init
-rwxr-xr-xbuilder/build-initramfs.sh2
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/prepare-root-partition.sh9
-rwxr-xr-xbuilder/dnbd3-rootfs/module-setup.sh6
-rw-r--r--builder/dnbd3-rootfs/services/dnbd3-generator.sh30
-rwxr-xr-xdev-tools/exampleDracutModule/apply-package.sh38
-rwxr-xr-xdev-tools/exampleDracutModule/module-setup.sh4
-rw-r--r--dev-tools/exampleDracutModule/source/usr/lib/systemd/system/example.service10
-rw-r--r--dev-tools/exampleDracutModule/source/usr/lib/systemd/system/multi-user.target.wants/example.service10
8 files changed, 67 insertions, 42 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index 0ceef33f..46e322c0 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -60,7 +60,7 @@ core.import change_root
# region properties
# shellcheck disable=SC2034
build_initramfs__doc_test_setup__='exceptions.activate'
-dracut_resource_url='https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-043.tar.gz'
+dracut_resource_url='https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-044.tar.gz'
file_path='/boot/initramfs.img'
dracut_parameter=(--force --no-hostonly)
verbose='no'
diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
index 95d13e51..3e93253f 100755
--- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -85,15 +85,13 @@ else
writable_device="$(losetup --find)"
losetup "$writable_device" "$ramdisk_location"
fi
-
-
# endregion
# region connect dnbd3
IFS_backup="$IFS"
IFS=","
return_code=1
for host in ${SLX_DNBD3_SERVERS}; do
- logging.info "Trying host \"host\"."
+ logging.info "Trying host \"$host\"."
if systemd-preserve-process-marker dnbd3-client --host "$host" --image \
"${SLX_DNBD3_IMAGE}" --device "$SLX_DNBD3_DEVICE" \
--rid "$SLX_DNBD3_RID"
@@ -105,8 +103,9 @@ done
IFS="$IFS_backup"
if [[ $return_code != 0 ]]; then
- logging.warn "Failed to connect '${SLX_DNBD3_IMAGE}' from" \
- "one of '$SLX_DNBD3_SERVERS' to '$SLX_DNBD3_DEVICE'."
+ logging.warn "Failed to connect \"${SLX_DNBD3_IMAGE}\" (revision" \
+ "\"$SLX_DNBD3_RID\") from one of \"$SLX_DNBD3_SERVERS\" to" \
+ "\"$SLX_DNBD3_DEVICE\"."
exit 1
fi
# endregion
diff --git a/builder/dnbd3-rootfs/module-setup.sh b/builder/dnbd3-rootfs/module-setup.sh
index 3599d797..1ef81a11 100755
--- a/builder/dnbd3-rootfs/module-setup.sh
+++ b/builder/dnbd3-rootfs/module-setup.sh
@@ -194,8 +194,10 @@ install() {
# endregion
# region hooks
inst_hook cmdline 00 "$moddir/hooks/enable-sysrq.sh"
- inst_hook cmdline 10 \
- "$moddir/hooks/prepare-kernel-command-line-parameter.sh"
+ # NOTE: Can be used to support old style ip append syntax and have an
+ # exclusive interface name.
+ #inst_hook cmdline 10 \
+ # "$moddir/hooks/prepare-kernel-command-line-parameter.sh"
inst_hook cmdline 90 "$moddir/hooks/set-dracut-environment-variables.sh"
inst_hook pre-udev 00 "$moddir/hooks/load-custom-kernel-modules.sh"
# Get the openslx config from the servers configured in the kernel command
diff --git a/builder/dnbd3-rootfs/services/dnbd3-generator.sh b/builder/dnbd3-rootfs/services/dnbd3-generator.sh
deleted file mode 100644
index bb9e7ad5..00000000
--- a/builder/dnbd3-rootfs/services/dnbd3-generator.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-GENERATOR_DIR="$2"
-[ -z "$GENERATOR_DIR" ] && exit 1
-[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
-#GENERATOR_DIR="/run/systemd/generator/"
-{
- echo "[Unit]"
- echo "Description=root fs on dnbd3 (distributed network block device)"
- echo "After=dracut-initqueue.service network.target"
- echo "Before=dracut-mount.service"
- echo "DefaultDependencies=no"
- echo "IgnoreOnIsolate=true"
- echo "#Conflicts=shutdown.target"
- echo "#ConditionKernelCommandLine=!"
- echo "#ConditionPathExists=/etc/multipath.conf"
- echo ""
- echo "[Service]"
- echo "Type=oneshot"
- echo "RemainAfterExit=true"
- echo "KillMode=none"
- echo "ExecStartPre=/sbin/fetch-config"
- echo "ExecStart=/sbin/dnbd3root"
- echo "#ExecReload=/sbin/multipathd reconfigure"
- echo "#ExecStop=echo 'stopping dnbd3'"
-} > "$GENERATOR_DIR"/dnbd3root.service
-[ -d "$GENERATOR_DIR"/sysinit.target.wants ] || mkdir -p "$GENERATOR_DIR"/sysinit.target.wants
-ln -s ../dnbd3root.service "$GENERATOR_DIR"/sysinit.target.wants/dnbd3root.service
-[ -d "$GENERATOR_DIR"/remote-fs.target.wants ] || mkdir -p "$GENERATOR_DIR"/remote-fs.target.wants
-ln -s ../dnbd3root.service "$GENERATOR_DIR"/remote-fs.target.wants/dnbd3root.service
-exit 0
diff --git a/dev-tools/exampleDracutModule/apply-package.sh b/dev-tools/exampleDracutModule/apply-package.sh
index 218740ef..07d3c0a5 100755
--- a/dev-tools/exampleDracutModule/apply-package.sh
+++ b/dev-tools/exampleDracutModule/apply-package.sh
@@ -1,8 +1,38 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
-source /etc/openslx
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
-echo --------------------------------------------------------------------------
-echo TEST
-echo --------------------------------------------------------------------------
+exceptions.try
+{
+ logging.set_commands_level debug
+ logging.set_level debug
+ # NOTE: "getarg" raises an exception so deactivate exceptions for now.
+ exceptions.deactivate
+ slx_server="$(getarg slxsrv=)"
+ slx_server_base="$(getarg slxbase=)"
+ exceptions.activate
+
+ logging.info 'Getting package.'
+ IFS_backup="$IFS"
+ IFS=','
+ for host in ${slx_server}; do
+ logging.info "Trying host \"$host\"."
+ if wget --timeout 5 \
+ "http://${host}/${slx_server_base}config.tar.gz" \
+ --output-document - | tar --extract --verbose --gzip --directory \
+ "$NEWROOT"
+ then
+ break
+ fi
+ done
+ IFS="$IFS_backup"
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
diff --git a/dev-tools/exampleDracutModule/module-setup.sh b/dev-tools/exampleDracutModule/module-setup.sh
index bfe216e7..8a7d0e07 100755
--- a/dev-tools/exampleDracutModule/module-setup.sh
+++ b/dev-tools/exampleDracutModule/module-setup.sh
@@ -14,6 +14,9 @@ check() {
`check`
'
+
+ # Here we could build our package file.
+
# Tell dracut that this module should only be included if it is required
# explicitly.
return 255
@@ -38,4 +41,5 @@ install() {
`install`
'
inst_hook pre-pivot 00 "$moddir/apply-package.sh"
+ inst_multiple tar wget
}
diff --git a/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/example.service b/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/example.service
new file mode 100644
index 00000000..83310c1d
--- /dev/null
+++ b/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/example.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Simple example service
+After=dracut-pre-mount.service network.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+KillMode=none
+ExecStart=/usr/bin/bash -c '/usr/bin/echo test >/tmp/test-output.txt'
diff --git a/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/multi-user.target.wants/example.service b/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/multi-user.target.wants/example.service
new file mode 100644
index 00000000..83310c1d
--- /dev/null
+++ b/dev-tools/exampleDracutModule/source/usr/lib/systemd/system/multi-user.target.wants/example.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Simple example service
+After=dracut-pre-mount.service network.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+KillMode=none
+ExecStart=/usr/bin/bash -c '/usr/bin/echo test >/tmp/test-output.txt'