feat: add distro compatibility check for system restore process
This commit is contained in:
parent
11d375b38b
commit
67109343ef
3 changed files with 37 additions and 1 deletions
|
@ -76,6 +76,11 @@ function restore_config() {
|
||||||
cprint 2 "Done!"
|
cprint 2 "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Distro check..."
|
||||||
|
|
||||||
|
check_distro
|
||||||
|
|
||||||
|
|
||||||
# Check for root only important on pure Debian as there is no sudo by default
|
# Check for root only important on pure Debian as there is no sudo by default
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
# check is the system is debian
|
# check is the system is debian
|
||||||
|
@ -84,8 +89,10 @@ if [ "$(id -u)" != "0" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
until [ "$selection" = "0" ]; do
|
until [ "$selection" = "0" ]; do
|
||||||
clear
|
#clear
|
||||||
echo ""
|
echo ""
|
||||||
cprint 3 " Main Menu"
|
cprint 3 " Main Menu"
|
||||||
mprint 1 "Restore"
|
mprint 1 "Restore"
|
||||||
|
|
|
@ -39,3 +39,28 @@ else
|
||||||
echo "Checksum files not found"
|
echo "Checksum files not found"
|
||||||
fi
|
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
|
||||||
|
}
|
|
@ -69,6 +69,10 @@ function copy_config() {
|
||||||
if [ -f ./exclusions ]; then
|
if [ -f ./exclusions ]; then
|
||||||
cp ./exclusions $tmpdir
|
cp ./exclusions $tmpdir
|
||||||
fi
|
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
|
if [ "$osp" = "Debian" ]; then
|
||||||
dpkg --get-selections > $tmpdir/installed_packages
|
dpkg --get-selections > $tmpdir/installed_packages
|
||||||
cp ./restore.deb.bash $tmpdir/restore.bash
|
cp ./restore.deb.bash $tmpdir/restore.bash
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue