Update os agent to also run flatpak if flatpak exists.

This commit is contained in:
Eric Renfro 2024-06-27 22:29:39 -04:00
parent 3073d18f0b
commit e4880cde6f
Signed by: psi-jack
SSH key fingerprint: SHA256:1TKB8Z257L8EHK8GWNxKgMhD8a+FAR+f+j3nnlcuNVM
3 changed files with 47 additions and 3 deletions

View file

@ -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
}

View file

@ -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 $?
}

View file

@ -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 <<EOF
#!/bin/bash