From 3356bab676d63a032cf67695c08bc18acd9de4d3 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Sun, 7 Jul 2024 16:17:01 -0400 Subject: [PATCH] Stylize output with bold --- scripts/os_debian | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/scripts/os_debian b/scripts/os_debian index 1ac8bb0..9450143 100755 --- a/scripts/os_debian +++ b/scripts/os_debian @@ -42,6 +42,8 @@ if [[ ! -d "trusted.gpg.d" ]]; then fi TMPDIR="\$(mktemp -d -t restore-XXXX)" +bold="$(tput bold)" +normal="$(tput sgr0)" cleanup() { [[ -n "\$TMPDIR" && -d "\$TMPDIR" ]] && rm -rf "\$TMPDIR" @@ -54,7 +56,7 @@ trap cleanup EXIT install="" -echo " * Installing required packages" +echo "\${bold} * Installing required packages\${normal}" dpkg-query -s 'rsync' &>/dev/null || install+=" rsync" #dpkg-query -s 'borgbackup' &>/dev/null || install+=" borgbackup" #dpkg-query -s 'borgmatic' &>/dev/null || install+=" borgmatic" @@ -64,18 +66,25 @@ if [[ -n "\$install" ]]; then apt -y install \$install fi -echo " * Enabling 32-bit packages" +echo "\${bold} * Enabling 32-bit packages\${normal}" 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 - echo + echo "\${bold}" echo "==============================" echo "INSTALL REPOS" echo "==============================" - echo - read -p "Do you want to continue to install backup repositories? [Y/n] " -n 1 -sr promptRepos + echo "\${normal} + + read -p "\${bold}Do you want to continue to install backup repositories? [Y/n]\${normal} " -n 1 -sr promptRepos if [[ "\$promptRepos" =~ ^[Yy]$ ]]; then echo "Yes" cp -a sources.list /etc/apt/sources.list @@ -88,18 +97,12 @@ if [[ -r "sources.list" ]]; then fi fi -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 - -echo +echo "\${bold}" echo "==============================" echo "INSTALL PACKAGES" 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 if [[ "\$promptPkgs" =~ ^[Yy] ]]; then echo "Yes" @@ -111,8 +114,9 @@ if [[ "\$promptPkgs" =~ ^[Yy] ]]; then echo "Packages that were omitted because they could not be found:" cat "\${TMPDIR}/diff.fail" | tr '\n' ' ' | fold -s 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 comm --nocheck-order -23 "\${TMPDIR}/diff.list" "\${TMPDIR}/diff.fail" | xargs apt-get install else @@ -122,7 +126,7 @@ else echo -e "Cancelled\n" 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 EOF chmod ug+rx restore.sh