Skip to content

Commit

Permalink
Update setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
salehabdullah216 committed Jun 29, 2024
1 parent 19c3b38 commit 99a6c7f
Showing 1 changed file with 24 additions and 37 deletions.
61 changes: 24 additions & 37 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ checkEnv() {
exit 1
fi

## Check if member of the sudo group.
if ! groups | grep sudo >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!${RC}"
echo -e "${RED}Warning: You are not in the sudo group.${RC}"
fi

## Check Package Handeler
PACKAGEMANAGER='apt yum dnf pacman zypper emerge xbps-install nix-env'
PACKAGEMANAGER='apt yum dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
Expand All @@ -53,16 +59,6 @@ checkEnv() {
exit 1
fi

if command_exists sudo; then
SUDO_CMD="sudo"
elif command_exists doas && [ -f "/etc/doas.conf" ]; then
SUDO_CMD="doas"
else
SUDO_CMD="su -c"
fi

echo "Using ${SUDO_CMD} as privilege escalation software"

## Check if the current directory is writable.
GITPATH="$(dirname "$(realpath "$0")")"
if [[ ! -w ${GITPATH} ]]; then
Expand All @@ -79,26 +75,23 @@ checkEnv() {
fi
done

## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!"
exit 1
if [ -z "${SUGROUP}" ]; then
echo -e "${RED}Warning: You are not in the sudo group.${RC}"
fi

}

installDepend() {
## Check for dependencies.
DEPENDENCIES='bash bash-completion tar neovim bat tree multitail fastfetch'
DEPENDENCIES='bash bash-completion tar tree multitail fastfetch tldr trash-cli'
echo -e "${YELLOW}Installing dependencies...${RC}"
if [[ $PACKAGER == "pacman" ]]; then
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
${SUDO_CMD} ${PACKAGER} --noconfirm -S base-devel
cd /opt && ${SUDO_CMD} git clone https://aur.archlinux.org/yay-git.git && ${SUDO_CMD} chown -R ${USER}:${USER} ./yay-git
sudo ${PACKAGER} --noconfirm -S base-devel
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
cd yay-git && makepkg --noconfirm -si
else
echo "AUR helper already installed"
echo "Aur helper already installed"
fi
if command_exists yay; then
AUR_HELPER="yay"
Expand All @@ -109,14 +102,8 @@ installDepend() {
exit 1
fi
${AUR_HELPER} --noconfirm -S ${DEPENDENCIES}
elif [[ $PACKAGER == "emerge" ]]; then
${PACKAGER} -v app-shells/bash app-shells/bash-completion app-arch/tar app-editors/neovim sys-apps/bat app-text/tree app-text/multitail app-misc/fastfetch
elif [[ $PACKAGER == "xbps-install" ]]; then
${PACKAGER} -v ${DEPENDENCIES}
elif [[ $PACKAGER == "nix-env" ]]; then
${PACKAGER} -iA nixos.bash nixos.bash-completion nixos.gnutar nixos.neovim nixos.bat nixos.tree nixos.multitail nixos.fastfetch
else
${SUDO_CMD} ${PACKAGER} install -yq ${DEPENDENCIES}
sudo ${PACKAGER} install -yq ${DEPENDENCIES}
fi
}

Expand Down Expand Up @@ -151,25 +138,25 @@ installZoxide() {
}

install_additional_dependencies() {
case $(command -v apt || command -v zypper || command -v dnf || command -v pacman) in
case $(command -v apt || command -v zypper || command -v dnf || command -v pacman) in
*apt)
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage --appimage-extract
${SUDO_CMD} mv squashfs-root /opt/neovim
${SUDO_CMD} ln -s /opt/neovim/AppRun /usr/bin/nvim
sudo mv squashfs-root /opt/neovim
sudo ln -s /opt/neovim/AppRun /usr/bin/nvim
;;
*zypper)
${SUDO_CMD} zypper refresh
${SUDO_CMD} zypper install -y neovim
sudo zypper refresh
sudo zypper install -y neovim
;;
*dnf)
${SUDO_CMD} dnf check-update
${SUDO_CMD} dnf install -y neovim
sudo dnf check-update
sudo dnf install -y neovim
;;
*pacman)
${SUDO_CMD} pacman -Syu
${SUDO_CMD} pacman -S --noconfirm neovim
sudo pacman -Syu
sudo pacman -S --noconfirm neovim
;;
*)
echo "No supported package manager found. Please install neovim manually."
Expand Down Expand Up @@ -207,4 +194,4 @@ if linkConfig; then
echo -e "${GREEN}Done!\nrestart your shell to see the changes.${RC}"
else
echo -e "${RED}Something went wrong!${RC}"
fi
fi

0 comments on commit 99a6c7f

Please sign in to comment.