Testing installation script

This commit is contained in:
Darkkal44
2023-04-28 20:14:08 +05:30
parent 72c656b28f
commit 1c683b43fe
+15 -31
View File
@@ -1,52 +1,36 @@
#!/bin/bash
# Check if script is run as root
if [[ "$(id -u)" -eq 0 ]]; then
echo "This script must not be run as root"
exit 1
fi
is_installed() {
pacman -Qi "$1" &>/dev/null
return $?
}
# Update system
sudo pacman -Syu
if ! is_installed git; then
sudo pacman -S git --noconfirm
# Install Git
if command -v git &>/dev/null; then
echo "Git v$(git -v | cut -d' ' -f3) is already installed in your system"
else
echo "git v$(git -v | cut -d' ' -f3) is already installed in your system"
sudo pacman -S git --noconfirm
fi
# Clone and install Paru
if command -v paru &>/dev/null; then
echo "paru $(paru -V | cut -d' ' -f2) is already installed in your system"
echo "Paru $(paru -V | cut -d' ' -f2) is already installed in your system"
else
if command -v yay &>/dev/null; then
"yay $(yay -V | cut -d' ' -f2) is installed in your system"
echo "Yay $(yay -V | cut -d' ' -f2) is installed in your system"
else
echo "Both yay and paru are not present in your system."
echo "Installing paru..."
echo "Neither Paru nor Yay is present in your system."
echo "Installing Paru..."
git clone https://aur.archlinux.org/paru-bin.git && cd paru-bin && makepkg -si --noconfirm && cd ..
fi
fi
# Update and install dependencies
if command -v paru &>/dev/null
then
paru -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git --noconfirm --needed
if ! is_installed lightdm && ! is_installed sddm
paru -S sddm
fi
else
if command -v yay &>/dev/null
then
yay -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git sddm --noconfirm --needed
if ! is_installed lightdm && ! is_installed sddm
yay -S sddm
fi
fi
# Install packages
sudo paru -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git sddm zsh-autosuggestions zsh-syntax-highlighting --noconfirm --needed
# Check and set Zsh as the default shell
[[ "$(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) " =~ "zsh " ]] || chsh -s $(which zsh)
@@ -70,7 +54,7 @@ for folder in .config/*; do
if [ -d ~/.config/$rel ]; then
echo "Backing up ~/.config/$rel"
cp -r ~/.config/$rel ~/.cozy.bak
echo "Backed up ~/.config/$rel" successfully.
echo "Backed up ~/.config/$rel successfully."
echo "Removing old config for $rel"
rm -rf ~/.config/$rel
echo "Copying new config for $rel"
@@ -82,10 +66,10 @@ for folder in .config/*; do
fi
done
cp -R ~/Fonts/Jetbrains/ttf/. ~/.local/share/fonts/
# Enable and start SDDM
if is_installed sddm
sudo systemctl enable sddm && sudo systemctl start sddm
if is_installed sddm; then
sudo systemctl disable --now lightdm 2>/dev/null || true
sudo systemctl enable --now sddm
fi