systemrescue-zfs/patches/archiso-v43-07-yaml-config.patch
Gerd v. Egidy 533a4cab7e add cow_label and cow_directory options to the global scope of the yaml config file
Allows to set to set the persistent backing store options via the yaml config too and
not only through boot commandline options.
2022-08-05 22:05:02 +02:00

66 lines
2.8 KiB
Diff

diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso
index 853652e..53215eb 100644
--- a/archiso/initcpio/hooks/archiso
+++ b/archiso/initcpio/hooks/archiso
@@ -197,6 +197,60 @@
fi
fi
+ msg ":: Creating config dir ..."
+ mkdir -p /run/archiso/config/
+
+ msg ":: Execute the configuration processing script ..."
+ jsonconfig="/run/archiso/config/sysrescue-effective-config.json"
+ if ! /usr/bin/sysrescue-configuration.lua > /tmp/sysrescue-configuration.log 2>&1
+ then
+ echo "ERROR: The configuration processing script has failed"
+ cat /tmp/sysrescue-configuration.log
+ sleep 20
+ fi
+
+ msg ":: Define early boot options based on the configuration ..."
+ for curentry in "copytoram" "checksum" "loadsrm"
+ do
+ if value=$(jq --raw-output ".global.${curentry} | tostring | ascii_downcase" ${jsonconfig} 2>/dev/null)
+ then
+ if [[ "${value}" == 'y' ]] || [[ "${value}" == 'yes' ]] || [[ "${value}" == 't' ]] || \
+ [[ "${value}" == 'true' ]] || [[ "${value}" == 'on' ]] || [[ "${value}" == '1' ]] || \
+ [[ "${value}" == '1.0' ]] ; then
+ echo "Entry '.global.${curentry}' enabled in config: value='${value}'"
+ eval "${curentry}='y'"
+ elif [[ "${value}" == 'n' ]] || [[ "${value}" == 'no' ]] || [[ "${value}" == 'f' ]] || \
+ [[ "${value}" == 'false' ]] || [[ "${value}" == 'off' ]] || [[ "${value}" == '0' ]] || \
+ [[ "${value}" == '0.0' ]] || [[ "${value}" == 'null' ]] ; then
+ echo "Entry '.global.${curentry}' disabled in config: value='${value}'"
+ else
+ echo "ERROR: Found invalid value for '.global.${curentry}': value='${value}'"
+ sleep 8
+ fi
+ fi
+ done
+
+ # read string values set by YAML config, only handle non-empty strings
+ for curentry in "cow_label" "cow_directory"
+ do
+ if value=$(jq --raw-output ".global.${curentry} // empty | tostring" ${jsonconfig} 2>/dev/null)
+ then
+ if [[ -n "${value}" ]] ; then
+ eval "${curentry}='${value}'"
+ fi
+ fi
+ done
+
+ # redo handling of cow_label, it could have changed due to yaml config
+ if [[ -n "${cow_label}" ]]; then
+ cow_device="/dev/disk/by-label/${cow_label}"
+ [[ -z "${cow_persistent}" ]] && cow_persistent="P"
+ elif [[ -n "${cow_device}" ]]; then
+ [[ -z "${cow_persistent}" ]] && cow_persistent="P"
+ else
+ cow_persistent="N"
+ fi
+
if [[ "${checksum}" == "y" ]]; then
if [[ -f "/run/archiso/bootmnt/${archisobasedir}/${arch}/airootfs.sha512" ]]; then
msg -n ":: Self-test requested, please wait..."