Run with sudo if not root

This commit is contained in:
Thomas Avé 2023-05-17 11:40:50 +02:00
parent e48dcf8b55
commit c74d9b1a5b
1 changed files with 33 additions and 28 deletions

View File

@ -1,16 +1,21 @@
#!/bin/bash
# Headless
NVIM=true
ZSH=true
PROFILE=true
TMUX=true
NVIM=false
ZSH=false
PROFILE=false
TMUX=false
# GUI
AWESOME=false
ALACRITTY=false
MPV=false
SUDO="sudo"
if [[ $(whoami) == "root" ]]; then
SUDO=""
fi
#################################################
# Basic Preparation #
@ -34,13 +39,13 @@ fi
if $NVIM; then
dependencies="neovim git npm unzip fzf cmake gcc make curl wget"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies
$SUDO pacman -Sy --needed --noconfirm $dependencies
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y software-properties-common
add-apt-repository ppa:neovim-ppa/unstable -y
apt update
apt install -y $dependencies python-venv
$SUDO apt update
$SUDO apt install -y software-properties-common
$SUDO add-apt-repository ppa:neovim-ppa/unstable -y
$SUDO apt update
$SUDO apt install -y $dependencies
fi
ln -s $PWD/nvim $XDG_CONFIG_HOME/nvim
@ -56,11 +61,11 @@ if $ZSH; then
PROFILE=true
dependencies="fzf zsh curl"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies
$SUDO pacman -Sy --needed --noconfirm $dependencies
echo "Please manually install yay and autojump-rs"
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y $dependencies autojump
$SUDO apt update
$SUDO apt install -y $dependencies autojump
fi
ln -s $PWD/zsh $XDG_CONFIG_HOME/zsh
@ -84,10 +89,10 @@ fi
if $AWESOME; then
dependencies="awesome picom numlockx xcape rofi"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies network-manager-applet xorg-xmodmap adobe-source-code-pro-fonts noto-fonts ttf-nerd-fonts-symbols
$SUDO pacman -Sy --needed --noconfirm $dependencies network-manager-applet xorg-xmodmap adobe-source-code-pro-fonts noto-fonts ttf-nerd-fonts-symbols
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y $dependencies awesome-extra
$SUDO apt update
$SUDO apt install -y $dependencies awesome-extra
fi
ln -s $PWD/awesome $XDG_CONFIG_HOME/awesome
@ -103,13 +108,13 @@ fi
if $ALACRITTY; then
dependencies="alacritty"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies
$SUDO pacman -Sy --needed --noconfirm $dependencies
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y software-properties-common
add-apt-repository ppa:aslatter/ppa -y
apt update
apt install -y $dependencies
$SUDO apt update
$SUDO apt install -y software-properties-common
$SUDO add-apt-repository ppa:aslatter/ppa -y
$SUDO apt update
$SUDO apt install -y $dependencies
fi
ln -s $PWD/alacritty $XDG_CONFIG_HOME/alacritty
@ -122,10 +127,10 @@ fi
if $MPV; then
dependencies="mpv"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies
$SUDO pacman -Sy --needed --noconfirm $dependencies
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y $dependencies
$SUDO apt update
$SUDO apt install -y $dependencies
fi
ln -s $PWD/mpv $XDG_CONFIG_HOME/mpv
@ -138,10 +143,10 @@ fi
if $TMUX; then
dependencies="tmux git zsh xdg-utils"
if [[ $OS == "NAME=\"Arch Linux\"" ]]; then
pacman -Sy --needed --noconfirm $dependencies
$SUDO pacman -Sy --needed --noconfirm $dependencies
elif [[ $OS == "NAME=\"Ubuntu\"" ]]; then
apt update
apt install -y $dependencies
$SUDO apt update
$SUDO apt install -y $dependencies
fi
ln -s $PWD/tmux $XDG_CONFIG_HOME/tmux