Hyprland-dotfiles/setup.sh

136 lines
3.5 KiB
Bash
Raw Normal View History

2024-05-07 15:02:31 -04:00
#!/bin/bash
clear
2024-05-23 07:58:08 -04:00
# Check if package is installed
_isInstalledPacman() {
package="$1";
check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
# Install required packages
_installPackagesPacman() {
toInstall=();
for pkg; do
if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then
echo "${pkg} is already installed.";
continue;
fi;
toInstall+=("${pkg}");
done;
if [[ "${toInstall[@]}" == "" ]] ; then
# echo "All pacman packages are already installed.";
return;
fi;
printf "Package not installed:\n%s\n" "${toInstall[@]}";
sudo pacman --noconfirm -S "${toInstall[@]}";
}
# Required packages for the installer
packages=(
"wget"
"unzip"
"gum"
"rsync"
)
2024-05-07 15:02:31 -04:00
# Some colors
GREEN='\033[0;32m'
NONE='\033[0m'
# Header
echo -e "${GREEN}"
cat <<"EOF"
2024-05-23 07:58:08 -04:00
___ _ _ _
|_ _|_ __ ___| |_ __ _| | | ___ _ __
| || '_ \/ __| __/ _` | | |/ _ \ '__|
| || | | \__ \ || (_| | | | __/ |
|___|_| |_|___/\__\__,_|_|_|\___|_|
2024-05-07 15:02:31 -04:00
EOF
2024-05-23 07:58:08 -04:00
echo "for ML4W Dotfiles"
2024-05-07 15:02:31 -04:00
echo
echo -e "${NONE}"
2024-05-23 07:58:08 -04:00
echo "This script will support you to download and install the ML4W Dotfiles".
2024-05-07 15:02:31 -04:00
echo
while true; do
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn
case $yn in
[Yy]* )
2024-05-27 11:02:57 -04:00
echo ":: Installation started."
2024-05-07 15:02:31 -04:00
echo
break;;
[Nn]* )
2024-05-27 11:02:57 -04:00
echo ":: Installation canceled."
2024-05-07 15:02:31 -04:00
exit;
break;;
2024-05-27 11:02:57 -04:00
* ) echo ":: Please answer yes or no.";;
2024-05-07 15:02:31 -04:00
esac
done
2024-05-29 10:16:42 -04:00
# Remove existing download folder and zip files
if [ -f $HOME/Downloads/dotfiles-main.zip ] ;then
rm $HOME/Downloads/dotfiles-main.zip
fi
if [ -f $HOME/Downloads/dotfiles-dev.zip ] ;then
rm $HOME/Downloads/dotfiles-dev.zip
fi
if [ -f $HOME/Downloads/dotfiles.zip ] ;then
rm $HOME/Downloads/dotfiles.zip
fi
if [ -d $HOME/Downloads/dotfiles ] ;then
rm -rf $HOME/Downloads/dotfiles
fi
if [ -d $HOME/Downloads/dotfiles-main ] ;then
rm -rf $HOME/Downloads/dotfiles-main
fi
if [ -d $HOME/Downloads/dotfiles-dev ] ;then
rm -rf $HOME/Downloads/dotfiles-dev
fi
2024-05-23 07:58:08 -04:00
# Synchronizing package databases
sudo pacman -Sy
echo
# Install required packages
echo ":: Checking that required packages are installed..."
_installPackagesPacman "${packages[@]}";
echo
2024-05-07 15:02:31 -04:00
2024-05-23 07:58:08 -04:00
# Double check rsync
if ! command -v rsync &> /dev/null; then
echo ":: Force rsync installation"
sudo pacman -S rsync --noconfirm
else
echo ":: rsync double checked"
2024-05-07 15:02:31 -04:00
fi
2024-05-23 07:58:08 -04:00
echo
2024-05-07 15:02:31 -04:00
2024-05-23 07:58:08 -04:00
# Select the dotfiles version
echo "Please choose between the main-release or the rolling-release (development version):"
version=$(gum choose "main-release" "rolling-release")
if [ "$version" == "main-release" ] ;then
wget -P ~/Downloads/ https://gitlab.com/stephan-raabe/dotfiles/-/archive/main/dotfiles-main.zip
v="main"
elif [ "$version" == "rolling-release" ] ;then
wget -P ~/Downloads/ https://gitlab.com/stephan-raabe/dotfiles/-/archive/dev/dotfiles-dev.zip
v="dev"
else
exit 130
fi
echo ":: Download complete."
echo
2024-05-07 15:02:31 -04:00
2024-05-23 07:58:08 -04:00
# Unzip
unzip -o -q ~/Downloads/dotfiles-$v.zip -d ~/Downloads/
echo ":: Unzip complete."
cd $HOME/Downloads/dotfiles-$v
echo ":: Changed into ~/Downloads/dotfiles-$v/"
2024-05-27 11:02:57 -04:00
echo
2024-05-29 10:16:42 -04:00
gum spin --spinner dot --title "Starting the installation now..." -- sleep 3
./install.sh