From 2c65c9b8dcca77e002e53fe0808384b76ec92232 Mon Sep 17 00:00:00 2001 From: Adrian Wannenmacher Date: Fri, 12 Feb 2021 18:18:54 +0100 Subject: [PATCH] feat: :sparkles: read config from a file inside /etc --- install.fish | 3 +++ src/config.fish | 44 +++++++++++++++++++++++++++++++++++++++++++ src/snap-pac-uki.fish | 16 +--------------- 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100755 src/config.fish diff --git a/install.fish b/install.fish index e0d4da7..adab4f5 100755 --- a/install.fish +++ b/install.fish @@ -2,6 +2,9 @@ cp ./src/snap-pac-uki.fish /usr/local/bin/snap-pac-uki echo "installed creation script." +cp ./src/config.fish /etc/snap-pac-uki/config.fish +echo "installed config script." + cp ./pacman/* /usr/share/libalpm/hooks/ echo "installed pacman hooks." diff --git a/src/config.fish b/src/config.fish new file mode 100755 index 0000000..997bd9e --- /dev/null +++ b/src/config.fish @@ -0,0 +1,44 @@ +function config -d "sets some configuration variables" + + # A directory where ukis can be built. + # + # It is recommended to keep this within /tmp, as the generated data will not + # be needed later. + # It is recommended to not set this to a path with data inside. This program + # will sometimes remove all content of specific subfolders. + set -g CFG_BUILD_DIR "/tmp/snap-pac-uki" + + # The subvolume to use on the kernel command line when generating current + # images. + set -g CFG_DEFAULT_SUBVOL "@" + + # The device the EFI partition resides on + set -g CFG_EFI_DEV "/dev/nvme0n1" + + # The "efi directory" that will contain the ukis + set -g CFG_EFI_PATH "\EFI\Linux" + + # The efi partitions number on the device + set -g CFG_EFI_PART "1" + + # The snapper config name + set -g CFG_SNAPSHOT_CONFIG "root" + + # The linux fs path containing all snapshot data + set -g CFG_SNAPSHOT_PATH "/.snapshots" + + # The name of the subvolume containing all snapshots + set -g CFG_SNAPSHOT_SUBVOL "@snapshots" + + # The directory to put uki files in + set -g CFG_UKI_DIR "/efi/EFI/Linux" + + # Whether generated uki files should be signed + set -g CFG_SECUREBOOT "yes" + + # The path to the .key file with which to sign uki files + set -g CFG_SECUREBOOT_KEY "/etc/secureboot/keys/db/db.key" + + # The path to the .crt file with which to sign uki files + set -g CFG_SECUREBOOT_CERT "/etc/secureboot/keys/db/db.crt" +end diff --git a/src/snap-pac-uki.fish b/src/snap-pac-uki.fish index 9bcc178..da252ab 100755 --- a/src/snap-pac-uki.fish +++ b/src/snap-pac-uki.fish @@ -23,21 +23,6 @@ function check_deps -d "checks if all dependencies are available" end end -function config -d "sets some configuration variables" - set -g CFG_BUILD_DIR "/tmp/snap-pac-uki" - set -g CFG_DEFAULT_SUBVOL "@" - set -g CFG_EFI_DEV "/dev/nvme0n1" - set -g CFG_EFI_PATH "\EFI\Linux" - set -g CFG_EFI_PART "1" - set -g CFG_SNAPSHOT_CONFIG "root" - set -g CFG_SNAPSHOT_PATH "/.snapshots" - set -g CFG_SNAPSHOT_SUBVOL "@snapshots" - set -g CFG_UKI_DIR "/efi/EFI/Linux" - set -g CFG_SECUREBOOT "yes" - set -g CFG_SECUREBOOT_KEY "/etc/secureboot/keys/db/db.key" - set -g CFG_SECUREBOOT_CERT "/etc/secureboot/keys/db/db.crt" -end - function find_tasks -d "finds out what the program needs to do" set -ge TASK_UKI @@ -138,6 +123,7 @@ end function main # prepare for execution check_deps + source "/etc/snap-pac-uki/config.fish" config switch $argv[1]