From 5dbdf3d311f158e00f36b56d6c1a9f984fe22581 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Fri, 22 Mar 2024 22:14:13 +0100 Subject: [PATCH] Add some improvements --- autoinstall/bashly.yml | 6 ++++++ autoinstall/before.sh | 7 +++++++ autoinstall/run_command.sh | 5 +++-- run.sh | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/autoinstall/bashly.yml b/autoinstall/bashly.yml index dfdcba5..526b258 100644 --- a/autoinstall/bashly.yml +++ b/autoinstall/bashly.yml @@ -30,6 +30,12 @@ commands: - name: group required: true help: The group to install + flags: + - long: --file + short: -f + help: File from which to read autoinstall-config + arg: file + default: $XDG_CONFIG_HOME/autoinstall.toml - name: git help: Install a git repository diff --git a/autoinstall/before.sh b/autoinstall/before.sh index f88899b..b5da850 100644 --- a/autoinstall/before.sh +++ b/autoinstall/before.sh @@ -19,5 +19,12 @@ fi if [ -n "$clean" ] || [ -n "${AUTOINSTALL_CLEAN:-}" ] then echo "Cleaning $target" + + # sanity checks + if [ -z "$target" ] || [ "$target" = "/" ] || [ "$target" = "$HOME" ] || [ "$target" = "$HOME/" ] + then + echo "Invalid target: '$target'" + exit 1 + fi rm -rf "$target" fi diff --git a/autoinstall/run_command.sh b/autoinstall/run_command.sh index 0bbc760..968d4b1 100644 --- a/autoinstall/run_command.sh +++ b/autoinstall/run_command.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash group=${args[group]:?} +file=${args[--file]:-} clean=${args[--clean]:-} _config_query() { tomlq -c --arg group "$group" \ '.autoinstall | map(select(.groups + ["all"] | contains([$group]))) | '"$1" \ - "$XDG_CONFIG_HOME/autoinstall.toml" + "$file" } _config_query ".[]" | while read -r entry; do @@ -43,5 +44,5 @@ _config_query ".[]" | while read -r entry; do install_args+=("$(eval "echo $target")") - autoinstall "${install_args[@]}" + "$0" "${install_args[@]}" done diff --git a/run.sh b/run.sh index 67177b3..7cb49dc 100755 --- a/run.sh +++ b/run.sh @@ -6,4 +6,6 @@ target=$(cat .target) make generate +printf "\nBuild complete. Running...\n==========================\n\n" + "./output/$target" "$@"