feat: add distro compatibility check for system restore process

This commit is contained in:
kake26 2025-05-10 21:29:00 -05:00
parent 11d375b38b
commit 67109343ef
Signed by: kake26
GPG key ID: E0A989B571D1F99F
3 changed files with 37 additions and 1 deletions

View file

@ -76,6 +76,11 @@ function restore_config() {
cprint 2 "Done!"
}
echo "Distro check..."
check_distro
# Check for root only important on pure Debian as there is no sudo by default
if [ "$(id -u)" != "0" ]; then
# check is the system is debian
@ -84,8 +89,10 @@ if [ "$(id -u)" != "0" ]; then
fi
fi
until [ "$selection" = "0" ]; do
clear
#clear
echo ""
cprint 3 " Main Menu"
mprint 1 "Restore"

View file

@ -38,4 +38,29 @@ if [ -f $pkgsum ] && [ -f $hostsum ]; then
else
echo "Checksum files not found"
fi
}
function check_distro() {
if [ -f ./distro_info ]; then
. ./distro_info
source_distro="$DISTRO_ID"
source_version="$DISTRO_VERSION"
else
cprint 1 "Warning: No distro info found in archive. Cannot verify compatibility."
return
fi
. /etc/os-release
target_distro="$ID"
target_version="$VERSION_ID"
if [ "$source_distro" != "$target_distro" ] || [ "$source_version" != "$target_version" ]; then
cprint 3 "Warning: This restore was created on $source_distro $source_version, but the target system is $target_distro $target_version."
cprint 3 "Restoration may fail if packages or configurations are incompatible."
cprint 3 "Press Enter to continue, or Ctrl+C to abort."
read
else
cprint 2 "Distro match: $source_distro $source_version. Proceeding with restoration."
fi
}

View file

@ -69,6 +69,10 @@ function copy_config() {
if [ -f ./exclusions ]; then
cp ./exclusions $tmpdir
fi
# Save distro info
. /etc/os-release
echo "DISTRO_ID=$ID" > $tmpdir/distro_info
echo "DISTRO_VERSION=$VERSION_ID" >> $tmpdir/distro_info
if [ "$osp" = "Debian" ]; then
dpkg --get-selections > $tmpdir/installed_packages
cp ./restore.deb.bash $tmpdir/restore.bash