From e8a75bf3dfaa244227d07b8c495b5b057f8498f7 Mon Sep 17 00:00:00 2001 From: Paul M Date: Thu, 5 Oct 2023 15:04:12 -0500 Subject: [PATCH] Arch support added in theory --- restore.arch.bash | 64 ++++++++++++++++++++++++++++++++ restore.bash => restore.deb.bash | 0 syssetup.bash | 13 +++++-- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100755 restore.arch.bash rename restore.bash => restore.deb.bash (100%) diff --git a/restore.arch.bash b/restore.arch.bash new file mode 100755 index 0000000..6f4d24f --- /dev/null +++ b/restore.arch.bash @@ -0,0 +1,64 @@ +#!/bin/bash + +function cprint () { + color="$1" + shift + echo "$(tput setaf $color)$*$(tput sgr0)" + +} + +function mprint (){ + echo " $1 - $2" +} + +function incorrect_selection() { + cprint 1 "Incorrect selection! Try again." +} + +function press_enter() { + echo "" + cprint 3 "Press Enter to continue " + read + clear +} + +function restore_config() { + cprint 2 "Restoring system..." + sleep 1 + aptpkgfile="installed_packages" + # restore apt first + cp -R etc/pacman.d /etc + cp pacman.conf /etc + pacman --noconfirm -Sy + pacman -S - < $aptpkgfile + # we should be set app wise now the configs + cp -R etc/ /etc + cprint 3 "You may want to reboot for changes to take effect" + cprint 2 "Done!" +} + +# 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 + if [ -f /etc/debian_version ]; then + cprint 3 "Notice: This script may need to be run as root on Debian, especially if its a stock install. Also requires makeself to created a distributable self restorable package" ; press_enter ; + fi +fi + +until [ "$selection" = "0" ]; do +clear + echo "" + cprint 3 " Main Menu" + mprint 1 "Restore" + mprint 0 "Exit" + echo "" + echo -n " Enter selection: " + read selection + echo "" + case $selection in + 1 ) clear ; restore_config ; press_enter ;; + 2 ) clear ; menu_option_two ; press_enter ;; + 0 ) clear ; exit ;; + * ) clear ; incorrect_selection ; press_enter ;; + esac +done \ No newline at end of file diff --git a/restore.bash b/restore.deb.bash similarity index 100% rename from restore.bash rename to restore.deb.bash diff --git a/syssetup.bash b/syssetup.bash index 708faa0..d8b2a22 100755 --- a/syssetup.bash +++ b/syssetup.bash @@ -48,13 +48,20 @@ function copy_config() { tmpdir=$(mktemp -d) echo $tmpdir cp -r /etc/ $tmpdir - # if [${osp} = "Debian"]; then - dpkg --get-selections > $tmpdir/installed_packages + if [ "$osp" = "Debian" ]; then + dpkg --get-selections > $tmpdir/installed_packages + cp ./restore.deb.bash $tmpdir/restore.bash +fi + +if [ "$osp" = "Arch" ]; then + pacman -Qqen > $tmpdir/installed_packages + cp ./restore.arch.bash $tmpdir/restore.bash +fi + arcdir=$(mktemp -d) echo $arcdir mkslf=$(which makeself.sh) echo $mkslf - cp ./restore.bash $tmpdir $mkslf --gzip $tmpdir $arcdir/restore.run "SFX archive for restoration" ./restore.bash cp $arcdir/restore.run ./