feature/os-debian-no-aptitude #1
1 changed files with 21 additions and 17 deletions
|
@ -42,6 +42,8 @@ if [[ ! -d "trusted.gpg.d" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMPDIR="\$(mktemp -d -t restore-XXXX)"
|
TMPDIR="\$(mktemp -d -t restore-XXXX)"
|
||||||
|
bold="$(tput bold)"
|
||||||
|
normal="$(tput sgr0)"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
[[ -n "\$TMPDIR" && -d "\$TMPDIR" ]] && rm -rf "\$TMPDIR"
|
[[ -n "\$TMPDIR" && -d "\$TMPDIR" ]] && rm -rf "\$TMPDIR"
|
||||||
|
@ -54,7 +56,7 @@ trap cleanup EXIT
|
||||||
|
|
||||||
install=""
|
install=""
|
||||||
|
|
||||||
echo " * Installing required packages"
|
echo "\${bold} * Installing required packages\${normal}"
|
||||||
dpkg-query -s 'rsync' &>/dev/null || install+=" rsync"
|
dpkg-query -s 'rsync' &>/dev/null || install+=" rsync"
|
||||||
#dpkg-query -s 'borgbackup' &>/dev/null || install+=" borgbackup"
|
#dpkg-query -s 'borgbackup' &>/dev/null || install+=" borgbackup"
|
||||||
#dpkg-query -s 'borgmatic' &>/dev/null || install+=" borgmatic"
|
#dpkg-query -s 'borgmatic' &>/dev/null || install+=" borgmatic"
|
||||||
|
@ -64,18 +66,25 @@ if [[ -n "\$install" ]]; then
|
||||||
apt -y install \$install
|
apt -y install \$install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " * Enabling 32-bit packages"
|
echo "\${bold} * Enabling 32-bit packages\${normal}"
|
||||||
grep ':i386' InstallOnly.list &>/dev/null && dpkg --add-architecture i386
|
grep ':i386' InstallOnly.list &>/dev/null && dpkg --add-architecture i386
|
||||||
|
|
||||||
echo " * Checking for flatpak"
|
echo "\${bold} * Checking for flatpak\${normal}"
|
||||||
|
flatpak=0
|
||||||
|
grep 'flatpak' InstallOnly.list &>/dev/null && flatpak=1
|
||||||
|
if [[ "\$flatpak" -eq 1 ]]; then
|
||||||
|
echo " * Adding flatpak repo: Flathub"
|
||||||
|
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -r "sources.list" ]]; then
|
if [[ -r "sources.list" ]]; then
|
||||||
echo
|
echo "\${bold}"
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
echo "INSTALL REPOS"
|
echo "INSTALL REPOS"
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
echo
|
echo "\${normal}
|
||||||
read -p "Do you want to continue to install backup repositories? [Y/n] " -n 1 -sr promptRepos
|
|
||||||
|
read -p "\${bold}Do you want to continue to install backup repositories? [Y/n]\${normal} " -n 1 -sr promptRepos
|
||||||
if [[ "\$promptRepos" =~ ^[Yy]$ ]]; then
|
if [[ "\$promptRepos" =~ ^[Yy]$ ]]; then
|
||||||
echo "Yes"
|
echo "Yes"
|
||||||
cp -a sources.list /etc/apt/sources.list
|
cp -a sources.list /etc/apt/sources.list
|
||||||
|
@ -88,18 +97,12 @@ if [[ -r "sources.list" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
flatpak=0
|
echo "\${bold}"
|
||||||
grep 'flatpak' InstallOnly.list &>/dev/null && flatpak=1
|
|
||||||
if [[ "\$flatpak" -eq 1 ]]; then
|
|
||||||
echo " * Adding flatpak repo: Flathub"
|
|
||||||
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
echo "INSTALL PACKAGES"
|
echo "INSTALL PACKAGES"
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
echo
|
echo "\${normal}"
|
||||||
|
|
||||||
read -p "About to install the system packages per the backup. Do you want to continue? [Y/n] " -n 1 -sr promptPkgs
|
read -p "About to install the system packages per the backup. Do you want to continue? [Y/n] " -n 1 -sr promptPkgs
|
||||||
if [[ "\$promptPkgs" =~ ^[Yy] ]]; then
|
if [[ "\$promptPkgs" =~ ^[Yy] ]]; then
|
||||||
echo "Yes"
|
echo "Yes"
|
||||||
|
@ -111,8 +114,9 @@ if [[ "\$promptPkgs" =~ ^[Yy] ]]; then
|
||||||
echo "Packages that were omitted because they could not be found:"
|
echo "Packages that were omitted because they could not be found:"
|
||||||
cat "\${TMPDIR}/diff.fail" | tr '\n' ' ' | fold -s
|
cat "\${TMPDIR}/diff.fail" | tr '\n' ' ' | fold -s
|
||||||
echo
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
read -p "Did everything above look okay and do you want to proceed? [Y/n] " -n 1 -sr promptPkgsDo
|
read -p "\${bold}Did everything above look okay and do you want to proceed? [Y/n]\${normal} " -n 1 -sr promptPkgsDo
|
||||||
if [[ "\$promptPkgsDo" =~ ^[Yy] ]]; then
|
if [[ "\$promptPkgsDo" =~ ^[Yy] ]]; then
|
||||||
comm --nocheck-order -23 "\${TMPDIR}/diff.list" "\${TMPDIR}/diff.fail" | xargs apt-get install
|
comm --nocheck-order -23 "\${TMPDIR}/diff.list" "\${TMPDIR}/diff.fail" | xargs apt-get install
|
||||||
else
|
else
|
||||||
|
@ -122,7 +126,7 @@ else
|
||||||
echo -e "Cancelled\n"
|
echo -e "Cancelled\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Packages that failed to schedule for install:"
|
echo "\${bold}Packages that failed to schedule for install:\${normal}"
|
||||||
cat "\${TMPDIR}/diff.fail" | tr '\n' ' ' | fold -s
|
cat "\${TMPDIR}/diff.fail" | tr '\n' ' ' | fold -s
|
||||||
EOF
|
EOF
|
||||||
chmod ug+rx restore.sh
|
chmod ug+rx restore.sh
|
||||||
|
|
Loading…
Reference in a new issue