summaryrefslogtreecommitdiffstats
path: root/modules.d/conf-tgz
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/conf-tgz')
-rwxr-xr-xmodules.d/conf-tgz/hooks/s3-copy-openslx-config.sh43
-rwxr-xr-xmodules.d/conf-tgz/module-setup.sh24
-rw-r--r--modules.d/conf-tgz/services/s3-fetch-config-tgz.service13
-rw-r--r--modules.d/conf-tgz/services/s3-fetch-config.service13
-rw-r--r--modules.d/conf-tgz/services/s3-unpack-config-tgz.service12
5 files changed, 57 insertions, 48 deletions
diff --git a/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh b/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh
new file mode 100755
index 00000000..bedceb85
--- /dev/null
+++ b/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+source "/etc/openslx"
+
+# Merge search domain from server and from dhcp
+(
+ search="$SLX_NET_SEARCH"
+ source /run/openslx/network.conf
+ search="$SLX_NET_SEARCH $search" # DHCP > config vars
+ declare -a uniq
+ declare -A dups # Don't use keys for output later as order is undefined
+ for i in $search; do
+ [ -n "${dups["$i"]}" ] && continue
+ dups["$i"]=1
+ uniq+=( "$i" )
+ done
+ sed -i 's/^SLX_NET_SEARCH=/# &/' "/etc/openslx" "/run/openslx/network.conf"
+ echo "SLX_NET_SEARCH='${uniq[*]}'" >> "/run/openslx/network.conf"
+ if grep -q '^search' "/etc/resolv.conf"; then
+ sed -i "s/^search.*$/search ${uniq[*]}/" "/etc/resolv.conf"
+ else
+ echo "search ${uniq[*]}" "/etc/resolv.conf"
+ fi
+)
+
+
+mkdir --parents "${NEWROOT}/opt/openslx"
+{
+ cat "/etc/openslx"
+ echo "## Generated by '$0' in stage3"
+ cat "/run/openslx/network.conf"
+} > "${NEWROOT}/opt/openslx/config"
+ln -nfs "${NEWROOT}/opt/openslx/config" "/etc/openslx"
+
+# Set root/demo password for stage4, if set
+if [ -n "${SLX_ROOT_PASS}" ]; then
+ sed -i "s#^root:[^:]*:#root:$SLX_ROOT_PASS:#" "$NEWROOT/etc/shadow"
+fi
+if [ -n "${SLX_DEMO_PASS}" ] && grep -q '^demo:' "$NEWROOT/etc/shadow"; then
+ sed -i "s#^demo:[^:]*:#demo:$SLX_DEMO_PASS:#" "$NEWROOT/etc/shadow"
+fi
diff --git a/modules.d/conf-tgz/module-setup.sh b/modules.d/conf-tgz/module-setup.sh
index 936d4356..cf2ba088 100755
--- a/modules.d/conf-tgz/module-setup.sh
+++ b/modules.d/conf-tgz/module-setup.sh
@@ -9,14 +9,18 @@ depends() {
install() {
inst_multiple tar mktemp gzip
- for _name in "s3-fetch-config" "s3-fetch-config-tgz" "s3-unpack-config-tgz"; do
- inst "$moddir/hooks/${_name}.sh" \
- "/usr/local/bin/${_name}.sh"
- inst_simple "${moddir}/services/${_name}.service" \
- "${systemdsystemunitdir}/${_name}.service"
- mkdir --parents \
- "${initdir}/${systemdsystemunitdir}/initrd.target.wants"
- ln_r "${systemdsystemunitdir}/${_name}.service" \
- "${systemdsystemunitdir}/initrd.target.wants/${_name}.service"
- done
+ slx_service "s3-fetch-config" "Download text-based config" \
+ --wafter "s3-setup-bootif-network.service" \
+ --wafter "s3-get-system-uuid.service"
+ slx_service "s3-copy-openslx-config" "Copy final /opt/openslx/config to /sysroot" \
+ --wafter "initrd-root-fs.target" \
+ --wafter "s3-fetch-config.service"
+
+ slx_service "s3-fetch-config-tgz" "Download config.tgz" \
+ --after "s3-fetch-config.service" \
+ --requires "s3-fetch-config.service"
+ slx_service "s3-unpack-config-tgz" "Unpack config.tgz to stage 4" \
+ --after "initrd-root-fs.target" \
+ --after "s3-fetch-config-tgz.service" \
+ --requires "s3-fetch-config-tgz.service"
}
diff --git a/modules.d/conf-tgz/services/s3-fetch-config-tgz.service b/modules.d/conf-tgz/services/s3-fetch-config-tgz.service
deleted file mode 100644
index 60d2b774..00000000
--- a/modules.d/conf-tgz/services/s3-fetch-config-tgz.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Download config.tgz
-Requires=s3-setup-bootif-network.service
-After=s3-setup-bootif-network.service
-Wants=s3-fetch-config.service
-After=s3-fetch-config.service
-DefaultDependencies=no
-IgnoreOnIsolate=true
-
-[Service]
-Type=oneshot
-RemainAfterExit=true
-ExecStart=/usr/local/bin/s3-fetch-config-tgz.sh
diff --git a/modules.d/conf-tgz/services/s3-fetch-config.service b/modules.d/conf-tgz/services/s3-fetch-config.service
deleted file mode 100644
index 9d602899..00000000
--- a/modules.d/conf-tgz/services/s3-fetch-config.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Download config
-Requires=s3-setup-bootif-network.service
-After=s3-setup-bootif-network.service
-Wants=s3-get-system-uuid.service
-After=s3-get-system-uuid.service
-DefaultDependencies=no
-IgnoreOnIsolate=true
-
-[Service]
-Type=oneshot
-RemainAfterExit=true
-ExecStart=/usr/local/bin/s3-fetch-config.sh
diff --git a/modules.d/conf-tgz/services/s3-unpack-config-tgz.service b/modules.d/conf-tgz/services/s3-unpack-config-tgz.service
deleted file mode 100644
index d3b9a3e0..00000000
--- a/modules.d/conf-tgz/services/s3-unpack-config-tgz.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Unpack config.tgz to stage 4
-After=initrd-root-fs.target
-Requires=s3-fetch-config-tgz.service
-After=s3-fetch-config-tgz.service
-DefaultDependencies=no
-IgnoreOnIsolate=true
-
-[Service]
-Type=oneshot
-RemainAfterExit=true
-ExecStart=/usr/local/bin/s3-unpack-config-tgz.sh