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 ""
fi
while true; do
read -p "Do you want to proceed? (Yy/Nn): " yn
case $yn in
[Yy]* )
if [ ! -d ~/dotfiles-versions ]; then
mkdir ~/dotfiles-versions
echo "~/dotfiles-versions created."
fi
if [ ! -d ~/dotfiles-versions/backups ]; then
mkdir ~/dotfiles-versions/backups
echo "~/dotfiles-versions/backups created"
fi
if [ ! -d ~/dotfiles-versions/backups/$datets ]; then
mkdir ~/dotfiles-versions/backups/$datets
echo "~/dotfiles-versions/backups/$datets created"
fi
if [ -d ~/dotfiles ]; then
rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/
echo "Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created."
fi
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old
echo "Existing .bashrc file found in homefolder. .bashrc-old created"
fi
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
if gum confirm "Do you want to proceed?" ;then
if [ ! -d ~/dotfiles-versions ]; then
mkdir ~/dotfiles-versions
echo "~/dotfiles-versions created."
fi
if [ ! -d ~/dotfiles-versions/backups ]; then
mkdir ~/dotfiles-versions/backups
echo "~/dotfiles-versions/backups created"
fi
if [ ! -d ~/dotfiles-versions/backups/$datets ]; then
mkdir ~/dotfiles-versions/backups/$datets
echo "~/dotfiles-versions/backups/$datets created"
fi
if [ -d ~/dotfiles ]; then
rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/
echo "Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created."
fi
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old
echo "Existing .bashrc file found in homefolder. .bashrc-old created"
fi
else
echo "Backup skipped."
fi
echo ""
fi

View File

@ -4,30 +4,21 @@
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 ""
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
if [ $SCRIPTPATH = "/home/$USER/dotfiles" ]; then
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 "Proceeding is not recommended!"
echo ""
if [ ! $mode == "dev" ]; then
exit
fi
fi
while true; do
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn
case $yn in
[Yy]* )
echo "Installation started."
break;;
[Nn]* )
echo "Installation canceled."
exit;
break;;
* ) echo "Please answer yes or no.";;
esac
done
if gum confirm "DO YOU WANT TO START THE INSTALLATION NOW?" ;then
echo "Installation started."
else
echo "Installation canceled."
exit;
fi
echo ""

View File

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

View File

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