mirror of
https://github.com/linuxboot/heads.git
synced 2025-01-30 08:03:55 +00:00
Use global /tmp/config that combines multiple config files
As part of the config gui we want to be able to have the system define new config options without them being lost if the user makes their own changes in CBFS. To allow that this change creates a function initiated in init that combines all /etc/config* files into /tmp/config. All existing scripts have been changed to source /tmp/config instead of /etc/config. The config-gui.sh script now uses /etc/config.user to hold user configuration options but the combine_configs function will allow that to expand as others want to split configuration out further. As it stands here are the current config files: /etc/config -- Compiled-in configuration options /etc/config.user -- User preferences that override /etc/config /tmp/config -- Running config referenced by the BIOS, combination of existing configs
This commit is contained in:
parent
49a131fa4b
commit
3eb62eed1a
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
file_selector() {
|
file_selector() {
|
||||||
FILE=""
|
FILE=""
|
||||||
@ -49,15 +49,6 @@ file_selector() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
replace_config() {
|
|
||||||
CONFIG_OPTION=$1
|
|
||||||
NEW_SETTING=$2
|
|
||||||
|
|
||||||
awk "gsub(\"^export ${CONFIG_OPTION}=.*\",\"export ${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /etc/config > /tmp/config
|
|
||||||
awk "gsub(\"^${CONFIG_OPTION}=.*\",\"${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /etc/config >> /tmp/config
|
|
||||||
grep -v "^export ${CONFIG_OPTION}=" /etc/config | grep -v "^${CONFIG_OPTION}=" >> /tmp/config
|
|
||||||
mv /tmp/config /etc/config
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
unset menu_choice
|
unset menu_choice
|
||||||
@ -76,7 +67,7 @@ while true; do
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"b" )
|
"b" )
|
||||||
CURRENT_OPTION=`grep 'CONFIG_BOOT_DEV=' /etc/config | cut -f2 -d '=' | tr -d '"'`
|
CURRENT_OPTION=`grep 'CONFIG_BOOT_DEV=' /tmp/config | cut -f2 -d '=' | tr -d '"'`
|
||||||
find /dev -name 'sd*' -o -name 'nvme*' > /tmp/filelist.txt
|
find /dev -name 'sd*' -o -name 'nvme*' > /tmp/filelist.txt
|
||||||
file_selector "/tmp/filelist.txt" "Choose the default /boot device.\n\nCurrently set to $CURRENT_OPTION."
|
file_selector "/tmp/filelist.txt" "Choose the default /boot device.\n\nCurrently set to $CURRENT_OPTION."
|
||||||
if [ "$FILE" == "" ]; then
|
if [ "$FILE" == "" ]; then
|
||||||
@ -85,7 +76,8 @@ while true; do
|
|||||||
SELECTED_FILE=$FILE
|
SELECTED_FILE=$FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
replace_config "CONFIG_BOOT_DEV" "$SELECTED_FILE"
|
replace_config /etc/config.user "CONFIG_BOOT_DEV" "$SELECTED_FILE"
|
||||||
|
combine_configs
|
||||||
|
|
||||||
whiptail --title 'Config change successful' \
|
whiptail --title 'Config change successful' \
|
||||||
--msgbox "The /boot device was successfully changed to $SELECTED_FILE" 16 60
|
--msgbox "The /boot device was successfully changed to $SELECTED_FILE" 16 60
|
||||||
@ -94,7 +86,7 @@ while true; do
|
|||||||
whiptail --title 'Insert a USB thumb drive' \
|
whiptail --title 'Insert a USB thumb drive' \
|
||||||
--msgbox "Insert a USB thumb drive so we can detect the device" 16 60
|
--msgbox "Insert a USB thumb drive so we can detect the device" 16 60
|
||||||
mount-usb
|
mount-usb
|
||||||
CURRENT_OPTION=`grep 'CONFIG_USB_BOOT_DEV=' /etc/config | cut -f2 -d '=' | tr -d '"'`
|
CURRENT_OPTION=`grep 'CONFIG_USB_BOOT_DEV=' /tmp/config | cut -f2 -d '=' | tr -d '"'`
|
||||||
find /dev -name 'sd*' -o -name 'nvme*' > /tmp/filelist.txt
|
find /dev -name 'sd*' -o -name 'nvme*' > /tmp/filelist.txt
|
||||||
file_selector "/tmp/filelist.txt" "Choose the default USB boot device.\n\nCurrently set to $CURRENT_OPTION."
|
file_selector "/tmp/filelist.txt" "Choose the default USB boot device.\n\nCurrently set to $CURRENT_OPTION."
|
||||||
if [ "$FILE" == "" ]; then
|
if [ "$FILE" == "" ]; then
|
||||||
@ -103,7 +95,8 @@ while true; do
|
|||||||
SELECTED_FILE=$FILE
|
SELECTED_FILE=$FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
replace_config "CONFIG_USB_BOOT_DEV" "$SELECTED_FILE"
|
replace_config /etc/config.user "CONFIG_USB_BOOT_DEV" "$SELECTED_FILE"
|
||||||
|
combine_configs
|
||||||
|
|
||||||
whiptail --title 'Config change successful' \
|
whiptail --title 'Config change successful' \
|
||||||
--msgbox "The USB boot device was successfully changed to $SELECTED_FILE" 16 60
|
--msgbox "The USB boot device was successfully changed to $SELECTED_FILE" 16 60
|
||||||
@ -116,10 +109,10 @@ while true; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (cbfs -o /tmp/config-gui.rom -l | grep -q "heads/initrd/etc/config") then
|
if (cbfs -o /tmp/config-gui.rom -l | grep -q "heads/initrd/etc/config.user") then
|
||||||
cbfs -o /tmp/config-gui.rom -d "heads/initrd/etc/config"
|
cbfs -o /tmp/config-gui.rom -d "heads/initrd/etc/config.user"
|
||||||
fi
|
fi
|
||||||
cbfs -o /tmp/config-gui.rom -a "heads/initrd/etc/config" -f /etc/config
|
cbfs -o /tmp/config-gui.rom -a "heads/initrd/etc/config.user" -f /etc/config.user
|
||||||
|
|
||||||
if (whiptail --title 'Update ROM?' \
|
if (whiptail --title 'Update ROM?' \
|
||||||
--yesno "This will reflash your BIOS with the updated version\n\nDo you want to proceed?" 16 90) then
|
--yesno "This will reflash your BIOS with the updated version\n\nDo you want to proceed?" 16 90) then
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
mount_usb(){
|
mount_usb(){
|
||||||
# Mount the USB boot device
|
# Mount the USB boot device
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
case "$CONFIG_BOARD" in
|
case "$CONFIG_BOARD" in
|
||||||
librem* )
|
librem* )
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Boot from a local disk installation
|
# Boot from a local disk installation
|
||||||
|
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
mount_boot()
|
mount_boot()
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
CONFIG_BOOT_GUI_MENU_NAME='Heads Boot Menu'
|
CONFIG_BOOT_GUI_MENU_NAME='Heads Boot Menu'
|
||||||
|
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
mount_boot()
|
mount_boot()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Launches kexec from saved configuration entries
|
# Launches kexec from saved configuration entries
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
|
|
||||||
dryrun="n"
|
dryrun="n"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Boot from signed ISO
|
# Boot from signed ISO
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
MOUNTED_ISO_PATH="$1"
|
MOUNTED_ISO_PATH="$1"
|
||||||
ISO_PATH="$2"
|
ISO_PATH="$2"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Save these options to be the persistent default
|
# Save these options to be the persistent default
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
|
|
||||||
while getopts "b:d:p:i:" arg; do
|
while getopts "b:d:p:i:" arg; do
|
||||||
|
@ -11,7 +11,7 @@ TPM_SEALED="/tmp/secret/secret.sealed"
|
|||||||
RECOVERY_KEY="/tmp/secret/recovery.key"
|
RECOVERY_KEY="/tmp/secret/recovery.key"
|
||||||
|
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
paramsdir=$1
|
paramsdir=$1
|
||||||
if [ -z "$paramsdir" ]; then
|
if [ -z "$paramsdir" ]; then
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Generic configurable boot script via kexec
|
# Generic configurable boot script via kexec
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
|
|
||||||
add=""
|
add=""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Sign a valid directory of kexec params
|
# Sign a valid directory of kexec params
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
|
|
||||||
rollback="n"
|
rollback="n"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Boot a USB installation
|
# Boot a USB installation
|
||||||
|
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
if [ "$CONFIG_TPM" = "y" ]; then
|
if [ "$CONFIG_TPM" = "y" ]; then
|
||||||
# Extend PCR4 as soon as possible
|
# Extend PCR4 as soon as possible
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Scan for USB installation options
|
# Scan for USB installation options
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
# Unmount any previous boot device
|
# Unmount any previous boot device
|
||||||
if grep -q /boot /proc/mounts ; then
|
if grep -q /boot /proc/mounts ; then
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# invoke a recovery shell and prompt the user for how to proceed
|
# invoke a recovery shell and prompt the user for how to proceed
|
||||||
|
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
. /tmp/config
|
||||||
|
|
||||||
insmod /lib/modules/ehci-hcd.ko
|
insmod /lib/modules/ehci-hcd.ko
|
||||||
insmod /lib/modules/ehci-pci.ko
|
insmod /lib/modules/ehci-pci.ko
|
||||||
|
@ -217,3 +217,20 @@ preserve_rom() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
replace_config() {
|
||||||
|
CONFIG_FILE=$1
|
||||||
|
CONFIG_OPTION=$2
|
||||||
|
NEW_SETTING=$3
|
||||||
|
|
||||||
|
# first pull out the existing option from the global config and place in a tmp file
|
||||||
|
awk "gsub(\"^export ${CONFIG_OPTION}=.*\",\"export ${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config > ${CONFIG_FILE}.tmp
|
||||||
|
awk "gsub(\"^${CONFIG_OPTION}=.*\",\"${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config >> ${CONFIG_FILE}.tmp
|
||||||
|
|
||||||
|
# then copy any remaining settings from the existing config file, minus the option you changed
|
||||||
|
grep -v "^export ${CONFIG_OPTION}=" ${CONFIG_FILE} | grep -v "^${CONFIG_OPTION}=" >> ${CONFIG_FILE}.tmp
|
||||||
|
|
||||||
|
mv ${CONFIG_FILE}.tmp ${CONFIG_FILE}
|
||||||
|
}
|
||||||
|
combine_configs() {
|
||||||
|
sort /etc/config* | uniq > /tmp/config
|
||||||
|
}
|
||||||
|
@ -40,7 +40,8 @@ hwclock -l -s
|
|||||||
|
|
||||||
# Read the system configuration parameters
|
# Read the system configuration parameters
|
||||||
. /etc/functions
|
. /etc/functions
|
||||||
. /etc/config
|
combine_configs
|
||||||
|
. /tmp/config
|
||||||
|
|
||||||
# Add our boot devices into the /etc/fstab, if they are defined
|
# Add our boot devices into the /etc/fstab, if they are defined
|
||||||
# in the configuration file.
|
# in the configuration file.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user