Merge branch 'lua-config-once' into 'main'

execute sysrescue-configuration.lua only once

See merge request systemrescue/systemrescue-sources!193
This commit is contained in:
Francois Dupoux 2022-05-09 11:26:49 +00:00
commit cfcfd6dd7a
5 changed files with 12 additions and 20 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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
@ -300,10 +300,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))

View file

@ -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"