From 944129b4073c06317d2b0c714d7eae71e76cfc72 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Fri, 22 Sep 2023 10:05:21 -0400 Subject: [PATCH] Added ability to failover any missing/unknown packages on restore --- scripts/os_debian | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/os_debian b/scripts/os_debian index 9b89c57..b59cbe5 100755 --- a/scripts/os_debian +++ b/scripts/os_debian @@ -43,6 +43,7 @@ fi install="" +echo " * Installing required packages" dpkg-query -s 'rsync' &>/dev/null || install+=" rsync" dpkg-query -s 'aptitude' &>/dev/null || install+=" aptitude" dpkg-query -s 'borgbackup' &>/dev/null || install+=" borgbackup" @@ -53,8 +54,10 @@ if [[ -n "\$install" ]]; then apt -y install \$install fi +echo " * Enabling 32-bit packages" grep ':i386' InstallOnly.list &>/dev/null && dpkg --add-architecture i386 +echo " * Restoring repositories and keys" cp -a sources.list /etc/apt/sources.list rsync --ignore-existing -raz sources.list.d/ /etc/apt/sources.list.d/ rsync --ignore-existing -raz trusted.gpg.d/ /etc/apt/trusted.gpg.d/ @@ -62,8 +65,32 @@ rsync --ignore-existing -raz trusted.gpg.d/ /etc/apt/trusted.gpg.d/ apt update -xargs aptitude --schedule-only install < InstallOnly.list +failinstall="" + +echo " * Gathering installed packages" +#xargs aptitude --schedule-only install < InstallOnly.list +while read p; do + dpkg-query -s "$p" &>/dev/null + if [[ "$?" -eq 1 ]]; then + aptitude --schedule-only install "$p" + if [[ "$?" -ne 0 ]]; then + if [[ -z "$failinstall" ]]; then + failinstall+="$p" + else + failinstall+=", $p" + fi + fi + fi +done < InstallOnly.list + +echo "Packages that failed to schedule for install:" +echo "$failinstall" + +echo " * Restoring installed packages (please confirm)" aptitude install + +echo "Packages that failed to schedule for install:" +echo "$failinstall" EOF chmod ug+rx restore.sh popd || exit 2