This commit is contained in:
Stephan Raabe 2024-05-23 13:58:08 +02:00
parent 478a02e483
commit d1cdc5d648

113
setup.sh
View File

@ -1,6 +1,44 @@
#!/bin/bash #!/bin/bash
clear clear
# 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"
)
# Some colors # Some colors
GREEN='\033[0;32m' GREEN='\033[0;32m'
NONE='\033[0m' NONE='\033[0m'
@ -8,18 +46,17 @@ NONE='\033[0m'
# Header # Header
echo -e "${GREEN}" echo -e "${GREEN}"
cat <<"EOF" cat <<"EOF"
____ _ ___ _ _ _
/ ___| ___| |_ _ _ _ __ |_ _|_ __ ___| |_ __ _| | | ___ _ __
\___ \ / _ \ __| | | | '_ \ | || '_ \/ __| __/ _` | | |/ _ \ '__|
___) | __/ |_| |_| | |_) | | || | | \__ \ || (_| | | | __/ |
|____/ \___|\__|\__,_| .__/ |___|_| |_|___/\__\__,_|_|_|\___|_|
|_|
EOF EOF
echo "for ML4W Hyprland Settings App" echo "for ML4W Dotfiles"
echo echo
echo -e "${NONE}" echo -e "${NONE}"
echo "This script will download the ML4W Dotfiles and start the installation." echo "This script will support you to download and install the ML4W Dotfiles".
echo echo
while true; do while true; do
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn
@ -36,19 +73,55 @@ while true; do
esac esac
done done
# Change into your Downloads directory # Synchronizing package databases
cd ~/Downloads sudo pacman -Sy
echo
# Remove existing folder # Install required packages
if [ -d ~/Downloads/dotfiles ] ;then echo ":: Checking that required packages are installed..."
rm -rf ~/Downloads/dotfiles _installPackagesPacman "${packages[@]}";
echo
# Double check rsync
if ! command -v rsync &> /dev/null; then
echo ":: Force rsync installation"
sudo pacman -S rsync --noconfirm
else
echo ":: rsync double checked"
fi fi
echo
# Clone the packages # Select the dotfiles version
git clone --depth 1 https://gitlab.com/stephan-raabe/dotfiles.git 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
# Change into the folder # Unzip
cd ml4w-hyprland-settings unzip -o -q ~/Downloads/dotfiles-$v.zip -d ~/Downloads/
echo ":: Unzip complete."
cd $HOME/Downloads/dotfiles-$v
echo ":: Changed into ~/Downloads/dotfiles-$v/"
# Start the script # Start the installatiom
./install.sh if gum confirm "DO YOU WANT TO START THE INSTALLATION NOW?" ;then
echo
echo "Starting the installation now..."
sleep 2
./install.sh
elif [ $? -eq 130 ]; then
exit 130
else
echo "Installation canceled."
echo "You can start the installation manually with ~/Downloads/dotfiles-$version/install.sh"
exit;
fi