From e4880cde6f092d7b3d9f5107c4c9f2817da81f3b Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Thu, 27 Jun 2024 22:29:39 -0400 Subject: [PATCH] Update os agent to also run flatpak if flatpak exists. --- scripts/flatpak | 39 +++++++++++++++++++++++++++++++++++++-- scripts/os | 9 ++++++++- scripts/os_fedora | 2 ++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/scripts/flatpak b/scripts/flatpak index 89564f9..90bd4ca 100755 --- a/scripts/flatpak +++ b/scripts/flatpak @@ -18,9 +18,44 @@ if [[ ! -f "flatpaks.lst" ]]; then exit 1 fi -which flatpak || exit 0 -xargs flatpak install -y < flatpaks.lst +# Removal uninstalled packages: +echo +echo "==============================" +echo "INSTALL FLATPAK PACKAGES" +echo "==============================" +echo +echo "The following flatpak packages are listed to be installed:" +cat flatpaks.lst +echo +read -p "Do you want to proceed? [Y/n] " -n 1 -sr promptFlatpak +if [[ "\$promptFlatpak" =~ ^[Yy]$ ]]; then + # Do the thing + echo "Yes" + + read -p "Do you want to omit any packages or cancel? [N, y, c] " -n 1 -sr promptFlatpakVerify + if [[ "\$promptFlatpakVerify" =~ ^[Yy]$ ]]; then + echo + read -p "What do you want to omit, seperated by spaces? " -r promptFlatpakOmit + omitfp="\$(echo "\$promptFlatpakOmit" | tr ' ' '|')" + echo + elif [[ "\$promptFlatpakVerify" =~ ^[Cc]$ ]]; then + echo -e "Cancelled\n" + omitfp="CANCEL" + else + omitfp="" + echo + fi + + if [[ "\$omitfp" != "CANCEL" ]]; then + egrep -v "(\$omitfp)" flatpaks.lst | xargs flatpak install -y + fi +else + echo -e "Cancelled\n" +fi EOF +#which flatpak || exit 0 +#xargs flatpak install -y < flatpaks.lst +#EOF popd || exit 2 } diff --git a/scripts/os b/scripts/os index 6d00c2f..6f2fb88 100755 --- a/scripts/os +++ b/scripts/os @@ -24,6 +24,11 @@ checkOS() { elif [[ "$kernel" == "Linux" ]]; then if [[ -f /etc/os-release ]]; then source /etc/os-release + DISTRO="$ID" + DISTRO_CURRENT="$DISTRO" + if [[ -n "$ID_LIKE" ]]; then + DISTRO="$ID_LIKE" + fi return 0 else echo "Unknown Linux Distribution" @@ -39,7 +44,7 @@ runOsHook() { if [[ "$kernel" == "Darwin" ]]; then "${scriptPath}/os_macos" "$hook" elif [[ "$kernel" == "Linux" ]]; then - case "$ID" in + case "$DISTRO" in debian) "${scriptPath}/os_debian" "$hook";; fedora) "${scriptPath}/os_fedora" "$hook";; garuda) "${scriptPath}/os_garuda" "$hook";; @@ -47,6 +52,8 @@ runOsHook() { opensuse-leap) "${scriptPath}/os_suse" "$hook";; opensuse-tumbleweed) "${scriptPath}/os_suse" "$hook";; esac + + command -v flatpak &>/dev/null && "${scriptPath}/flatpak" "$hook" fi return $? } diff --git a/scripts/os_fedora b/scripts/os_fedora index a815278..095dd0e 100755 --- a/scripts/os_fedora +++ b/scripts/os_fedora @@ -8,6 +8,8 @@ hook_before() { rpm -qa | sort > Package.versions.list rpm -qa --queryformat '%{NAME}.%{ARCH}\n' | sort > Package.list + #FIXME Need to put this to use for explicitely installed packages. + dnf repoquery --userinstalled > Package.userinstalled.list cat > restore.sh <