Update with gum confirm

This commit is contained in:
Stephan Raabe 2023-11-20 22:11:39 +01:00
parent 0038510d56
commit 7707ac4206
4 changed files with 61 additions and 90 deletions

View File

@ -25,35 +25,29 @@ echo -e "${NONE}"
echo "~/dotfiles-versions/backups/$datets/.bashrc-old" echo "~/dotfiles-versions/backups/$datets/.bashrc-old"
echo "" echo ""
fi fi
while true; do if gum confirm "Do you want to proceed?" ;then
read -p "Do you want to proceed? (Yy/Nn): " yn if [ ! -d ~/dotfiles-versions ]; then
case $yn in mkdir ~/dotfiles-versions
[Yy]* ) echo "~/dotfiles-versions created."
if [ ! -d ~/dotfiles-versions ]; then fi
mkdir ~/dotfiles-versions if [ ! -d ~/dotfiles-versions/backups ]; then
echo "~/dotfiles-versions created." mkdir ~/dotfiles-versions/backups
fi echo "~/dotfiles-versions/backups created"
if [ ! -d ~/dotfiles-versions/backups ]; then fi
mkdir ~/dotfiles-versions/backups if [ ! -d ~/dotfiles-versions/backups/$datets ]; then
echo "~/dotfiles-versions/backups created" mkdir ~/dotfiles-versions/backups/$datets
fi echo "~/dotfiles-versions/backups/$datets created"
if [ ! -d ~/dotfiles-versions/backups/$datets ]; then fi
mkdir ~/dotfiles-versions/backups/$datets if [ -d ~/dotfiles ]; then
echo "~/dotfiles-versions/backups/$datets created" rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/
fi echo "Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created."
if [ -d ~/dotfiles ]; then fi
rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/ if [ -f ~/.bashrc ]; then
echo "Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created." cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old
fi echo "Existing .bashrc file found in homefolder. .bashrc-old created"
if [ -f ~/.bashrc ]; then fi
cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old else
echo "Existing .bashrc file found in homefolder. .bashrc-old created" echo "Backup skipped."
fi fi
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
echo "" echo ""
fi fi

View File

@ -4,30 +4,21 @@
echo "IMPORTANT: Please make sure that your system and your packages are up to date." echo "IMPORTANT: Please make sure that your system and your packages are up to date."
echo "You can cancel the installation at any time with CMD + C" echo "You can cancel the installation at any time with CMD + C"
echo ""
SCRIPT=$(realpath "$0") SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTPATH=$(dirname "$SCRIPT")
if [ $SCRIPTPATH = "/home/$USER/dotfiles" ]; then if [ $SCRIPTPATH = "/home/$USER/dotfiles" ]; then
echo "IMPORTANT: You're running the installation script from the installation target directory." echo "IMPORTANT: You're running the installation script from the installation target directory."
echo "Please move the installation folder dotfiles e.g. to ~/Downloads/ and start the script again." echo "Please move the installation folder dotfiles e.g. to ~/Downloads/ and start the script again."
echo "Proceeding is not recommended!" echo "Proceeding is not recommended!"
echo ""
if [ ! $mode == "dev" ]; then if [ ! $mode == "dev" ]; then
exit exit
fi fi
fi fi
while true; do if gum confirm "DO YOU WANT TO START THE INSTALLATION NOW?" ;then
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn echo "Installation started."
case $yn in else
[Yy]* ) echo "Installation canceled."
echo "Installation started." exit;
break;; fi
[Nn]* )
echo "Installation canceled."
exit;
break;;
* ) echo "Please answer yes or no.";;
esac
done
echo "" echo ""

View File

@ -14,17 +14,10 @@ cat <<"EOF"
EOF EOF
echo -e "${NONE}" echo -e "${NONE}"
while true; do if gum confirm "Do you want to install the custom tty login issue?" ;then
read -p "Do you want to install the custom tty login issue (Yy/Nn): " yn sudo cp login/issue /etc/issue
case $yn in else
[Yy]* ) echo "Setup tty login skipped."
sudo cp login/issue /etc/issue fi
break;;
[Nn]* )
echo "Setup tty login skipped."
break;;
* ) echo "Please answer yes or no.";;
esac
done
echo "" echo ""
fi fi

View File

@ -39,41 +39,34 @@ echo -e "${NONE}"
fi fi
fi fi
echo "" echo ""
if gum confirm "Do you want to restore the files now and use it on your new installation?" ;then
while true; do if [ -f ~/dotfiles/.bashrc ]; then
read -p "Do you want to restore the files now and use it on your new installation (Yy/Nn): " yn cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/
case $yn in echo ".bashrc restored!"
[Yy]* ) fi
if [ -f ~/dotfiles/.bashrc ]; then if [ $profile == "Hyprland" ] || [ $profile == "All" ]; then
cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/ if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then
echo ".bashrc restored!" cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland keyboard.conf restored!"
fi fi
if [ $profile == "Hyprland" ] || [ $profile == "All" ]; then if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then
if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/
cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/ echo "Hyprland monitor.conf restored!"
echo "Hyprland keyboard.conf restored!"
fi
if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then
cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland monitor.conf restored!"
fi
if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then
cp ~/dotfiles/hypr/conf/keybindings.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland keybindings.conf restored!"
fi
fi fi
if [ $profile == "Qtile" ] || [ $profile == "All" ]; then if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then
if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then cp ~/dotfiles/hypr/conf/keybindings.conf ~/dotfiles-versions/$version/hypr/conf/
cp ~/dotfiles/qtile/conf/keyboard.py ~/dotfiles-versions/$version/qtile/conf/ echo "Hyprland keybindings.conf restored!"
echo "Qtile keyboard.py restored!"
fi
fi fi
restored=1 fi
break;; if [ $profile == "Qtile" ] || [ $profile == "All" ]; then
[Nn]* ) if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then
break;; cp ~/dotfiles/qtile/conf/keyboard.py ~/dotfiles-versions/$version/qtile/conf/
* ) echo "Please answer yes or no.";; echo "Qtile keyboard.py restored!"
esac fi
done fi
restored=1
else
echo "Restore skipped"
fi
echo "" echo ""
fi fi