From cadb8e01d0590dd06377d04dd021613b058eae8b Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Sun, 12 May 2024 23:50:11 +0200 Subject: [PATCH] Add autoinstall flatpak --- autoinstall/bashly.yml | 10 ++++++++++ autoinstall/before.sh | 4 ++-- autoinstall/flatpak_command.sh | 13 +++++++++++++ autoinstall/run_command.sh | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 autoinstall/flatpak_command.sh diff --git a/autoinstall/bashly.yml b/autoinstall/bashly.yml index 526b258..7a9cedc 100644 --- a/autoinstall/bashly.yml +++ b/autoinstall/bashly.yml @@ -115,3 +115,13 @@ commands: - name: target required: true help: The path to write the result to + + - name: flatpak + help: Install a flatpak + args: + - name: flatpak + required: true + help: The flatpak to install + - name: mode + required: true + help: The target to install into (user or system) diff --git a/autoinstall/before.sh b/autoinstall/before.sh index b5da850..24b4323 100644 --- a/autoinstall/before.sh +++ b/autoinstall/before.sh @@ -2,8 +2,8 @@ action=${action:?} -# if action is run or completions, do nothing -if [ "$action" = "run" ] || [ "$action" = "completions" ] +# do nothing on some selected actions +if [ "$action" = "completions" ] || [ "$action" = "flatpak" ] || [ "$action" = "run" ] then return fi diff --git a/autoinstall/flatpak_command.sh b/autoinstall/flatpak_command.sh new file mode 100644 index 0000000..89f6e54 --- /dev/null +++ b/autoinstall/flatpak_command.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +flatpak=${args[flatpak]:?} +mode=${args[mode]:?} + +if ! flatpak info "$flatpak" &> /dev/null +then + echo "Installing flatpak $flatpak" + + flatpak install -y "--$mode" "$flatpak" + + _run_hook +fi diff --git a/autoinstall/run_command.sh b/autoinstall/run_command.sh index 968d4b1..a45399c 100644 --- a/autoinstall/run_command.sh +++ b/autoinstall/run_command.sh @@ -44,5 +44,5 @@ _config_query ".[]" | while read -r entry; do install_args+=("$(eval "echo $target")") - "$0" "${install_args[@]}" + "$0" "${install_args[@]}" || true # Continue on error done