mirror of
https://github.com/nchevsky/systemrescue-zfs.git
synced 2025-12-06 07:12:01 +01:00
execute sysrescue-configuration.lua only once
Before this patch sysrescue-configuration.lua was executed twice each boot: (1) during initramfs stage (2) in the regular system as sysrescue-configuration.service While in theory both runs should create the same output, this isn't guaranteed and differences could appear for example because of network issues. Finding and debugging these is difficult because the output of sysrescue-configuration.lua created during initramfs isn't available anymore when the final system is running. This patch lets sysrescue-configuration.lua just run once during initramfs. The output JSON file is then written to the new tmpfs mounted dir /run/archiso/config/. This dir is also made the new default location for sysrescue-effective-config.json. A symlink from /etc/sysrescue/sysrescue-effective-config.json to the new location is created for compatibility with previous releases.
This commit is contained in:
parent
f1b7636d5d
commit
e87660beeb
|
|
@ -19,7 +19,7 @@ errcnt = 0
|
|||
# Read the effective configuration file
|
||||
# ==============================================================================
|
||||
print(f"====> Read the effective configuration file ...")
|
||||
effectivecfg = "/etc/sysrescue/sysrescue-effective-config.json"
|
||||
effectivecfg = "/run/archiso/config/sysrescue-effective-config.json"
|
||||
if os.path.exists(effectivecfg) == False:
|
||||
print (f"Failed to find effective configuration file in {effectivecfg}")
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
[Unit]
|
||||
Description=Determine SystemRescue effective configuration
|
||||
After=network.target network-online.target
|
||||
Before=sysrescue-initialize.service
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/sysrescue-configuration.lua
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -27,6 +27,10 @@ sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' /etc/systemd/logind.conf
|
|||
# PulseAudio takes care of volume restore
|
||||
ln -sf /dev/null /etc/udev/rules.d/90-alsa-restore.rules
|
||||
|
||||
# config symlink
|
||||
mkdir /etc/sysrescue/
|
||||
ln -sf /run/archiso/config/sysrescue-effective-config.json /etc/sysrescue/sysrescue-effective-config.json
|
||||
|
||||
# Services
|
||||
systemctl enable NetworkManager.service
|
||||
systemctl enable iptables.service
|
||||
|
|
@ -34,7 +38,6 @@ systemctl enable ip6tables.service
|
|||
systemctl enable pacman-init.service
|
||||
systemctl enable choose-mirror.service
|
||||
systemctl enable sshd.service
|
||||
systemctl enable sysrescue-configuration.service
|
||||
systemctl enable sysrescue-initialize.service
|
||||
systemctl enable sysrescue-autorun.service
|
||||
systemctl enable qemu-guest-agent.service
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
-- At the end it writes the effective configuration to a JSON file which is meant
|
||||
-- to be ready by any initialisation script which needs to know the configuration.
|
||||
-- Shell scripts can read values from the JSON file using a command such as:
|
||||
-- jq --raw-output '.global.copytoram' /etc/sysrescue/sysrescue-effective-config.json
|
||||
-- jq --raw-output '.global.copytoram' /run/archiso/config/sysrescue-effective-config.json
|
||||
-- This script requires the following lua packages to run on Arch Linux:
|
||||
-- sudo pacman -Sy lua lua-yaml lua-dkjson lua-http
|
||||
|
||||
|
|
@ -253,10 +253,9 @@ print (jsoncfgtxt)
|
|||
-- Write the effective configuration to a JSON file
|
||||
-- ==============================================================================
|
||||
print ("====> Writing the effective configuration to a JSON file ...")
|
||||
output_location = "/etc/sysrescue"
|
||||
output_location = "/run/archiso/config"
|
||||
output_filename = "sysrescue-effective-config.json"
|
||||
output_fullpath = output_location.."/"..output_filename
|
||||
lfs.mkdir(output_location)
|
||||
jsoncfgfile = io.open(output_fullpath, "w")
|
||||
if jsoncfgfile == nil then
|
||||
io.stderr:write(string.format("ERROR: Failed to create effective configuration file in %s\n", output_fullpath))
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ 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,32 @@ archiso_mount_handler() {
|
||||
@@ -197,6 +197,35 @@ archiso_mount_handler() {
|
||||
fi
|
||||
fi
|
||||
|
||||
+ msg ":: Creating config dir ..."
|
||||
+ mkdir -p /run/archiso/config/
|
||||
+
|
||||
+ msg ":: Execute the configuration processing script ..."
|
||||
+ jsonconfig="/etc/sysrescue/sysrescue-effective-config.json"
|
||||
+ 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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue