diff --git a/run_onchange_after_install_main_deps.sh.tmpl b/run_onchange_after_install_main_deps.sh.tmpl index 2865b5f..23ed2e0 100644 --- a/run_onchange_after_install_main_deps.sh.tmpl +++ b/run_onchange_after_install_main_deps.sh.tmpl @@ -33,6 +33,15 @@ PAD_LEN=4 BASE_PACKAGES="gnupg curl wget git" ACT_PACKAGES="ripgrep unzip htop fzf bat gawk jq nnn tmux mc nethogs ngrep mtr gcc" +# Prefer doas over sudo (FreeBSD) +if command -v doas >/dev/null 2>&1; then + SUDO="doas" +elif command -v sudo >/dev/null 2>&1; then + SUDO="sudo" +else + SUDO="" +fi + # Non-interactive mode flags ASSUME_YES=0 NON_INTERACTIVE=0 @@ -146,7 +155,7 @@ pad() { {{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.osRelease.id "almalinux" "rocky" "fedora" -}} echo -e "--> "$Blue$1$Blue"Installing prerequestative ncurses for this script's interface"$NC - sudo dnf install ncurses -y 2>&1|pad + $SUDO dnf install ncurses -y 2>&1|pad {{ end -}} {{ end -}} @@ -158,7 +167,7 @@ print_block new_line "Update caches and upgrade packages" {{ if eq .chezmoi.os "freebsd" -}} - sudo pkg update 2>&1|pad + $SUDO pkg update 2>&1|pad {{ else if eq .chezmoi.os "darwin" -}} @@ -173,14 +182,14 @@ new_line "Update caches and upgrade packages" brew update 2>&1|pad {{ else if eq .chezmoi.osRelease.id "fedora" "almalinux" "rocky" -}} - sudo dnf update -y 2>&1|pad + $SUDO dnf update -y 2>&1|pad {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - sudo apt-get update 2>&1|pad - sudo DEBIAN_FRONTEND=noninteractive apt-get -o "Dpkg::Options::=--force-confold" -o "Dpkg::Options::=--force-confdef" upgrade -y --allow-downgrades --allow-remove-essential --allow-change-held-packages 2>&1|pad + $SUDO apt-get update 2>&1|pad + DEBIAN_FRONTEND=noninteractive $SUDO apt-get -o "Dpkg::Options::=--force-confold" -o "Dpkg::Options::=--force-confdef" upgrade -y --allow-downgrades --allow-remove-essential --allow-change-held-packages 2>&1|pad {{ else if eq .chezmoi.osRelease.id "arch" "archarm" -}} - sudo pacman -Syu --noconfirm 2>&1|pad + $SUDO pacman -Syu --noconfirm 2>&1|pad {{ end -}} @@ -189,24 +198,24 @@ new_line "Install base packages" {{ if eq .chezmoi.os "freebsd" -}} - sudo pkg install --yes $BASE_PACKAGES py39-pipx direnv 2>&1|pad + $SUDO pkg install --yes $BASE_PACKAGES py39-pipx direnv 2>&1|pad {{ else if eq .chezmoi.os "darwin" -}} brew install -q $BASE_PACKAGES python pipx direnv goku 2>&1|pad {{ else if eq .chezmoi.osRelease.id "fedora" -}} - sudo dnf install $BASE_PACKAGES direnv kitty-terminfo util-linux-user pipx -y 2>&1|pad + $SUDO dnf install $BASE_PACKAGES direnv kitty-terminfo util-linux-user pipx -y 2>&1|pad {{ else if eq .chezmoi.osRelease.id "almalinux" "rocky" -}} - sudo dnf install epel-release -y 2>&1|pad - sudo dnf install $BASE_PACKAGES kitty-terminfo which util-linux-user xz pipx -y 2>&1|pad + $SUDO dnf install epel-release -y 2>&1|pad + $SUDO dnf install $BASE_PACKAGES kitty-terminfo which util-linux-user xz pipx -y 2>&1|pad {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - sudo apt-get install $BASE_PACKAGES kitty-terminfo direnv pipx python3-venv -y 2>&1|pad - sudo apt-get install software-properties-common -y 2>&1|pad + $SUDO apt-get install $BASE_PACKAGES kitty-terminfo direnv pipx python3-venv -y 2>&1|pad + $SUDO apt-get install software-properties-common -y 2>&1|pad {{ else if eq .chezmoi.osRelease.id "arch" "archarm" -}} - sudo pacman -Sy --noconfirm $BASE_PACKAGES kitty-terminfo python-pipx 2>&1|pad + $SUDO pacman -Sy --noconfirm $BASE_PACKAGES kitty-terminfo python-pipx 2>&1|pad {{ end -}} @@ -233,20 +242,20 @@ fi new_line "Subscribe to PPA for fish" ## Setup fish repo in debian VERS={{ .chezmoi.osRelease.versionID }} - echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_$VERS/ /" | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list 2>/dev/null - curl -fsSL "https://download.opensuse.org/repositories/shells:fish:release:3/Debian_$VERS/Release.key" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null + echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_$VERS/ /" | $SUDO tee /etc/apt/sources.list.d/shells:fish:release:3.list 2>/dev/null + curl -fsSL "https://download.opensuse.org/repositories/shells:fish:release:3/Debian_$VERS/Release.key" | gpg --dearmor | $SUDO tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null {{ else -}} new_line "Subscribe to PPA for fish" ## Setup fish repo in ubuntu - sudo apt-add-repository ppa:fish-shell/release-3 -y 2>&1|pad + $SUDO apt-add-repository ppa:fish-shell/release-3 -y 2>&1|pad new_line "Subscribe to PPA for neovim" ## Neovim ppa - sudo add-apt-repository ppa:neovim-ppa/unstable -y 2>&1|pad + $SUDO add-apt-repository ppa:neovim-ppa/unstable -y 2>&1|pad {{ end -}} -sudo apt-get update 2>&1|pad +$SUDO apt-get update 2>&1|pad {{ end -}} {{ end -}} @@ -257,7 +266,7 @@ new_line "Install neovim, fish, atuin, jump and the rest" {{ if eq .chezmoi.os "freebsd" -}} -sudo pkg install --yes $ACT_PACKAGES neovim fish atuin lazygit fd-find pam_ssh_agent_auth fd 2>&1|pad +$SUDO pkg install --yes $ACT_PACKAGES neovim fish atuin lazygit fd-find pam_ssh_agent_auth fd 2>&1|pad {{ else if eq .chezmoi.os "darwin" -}} brew install -q fish neovim $ACT_PACKAGES atuin jump fd sk dust lazygit 2>&1|pad @@ -269,7 +278,7 @@ sudo pkg install --yes $ACT_PACKAGES neovim fish atuin lazygit fd-find pam_ssh_a else echo -e "${Yello}WARNING: pam_ssh_agent_auth not available in repos. sudo via SSH agent won't work.${NC}" fi - sudo dnf install neovim fish $ACT_PACKAGES fd-find ${PAM_SSH_PKG:+$PAM_SSH_PKG} -y 2>&1|pad + $SUDO dnf install neovim fish $ACT_PACKAGES fd-find ${PAM_SSH_PKG:+$PAM_SSH_PKG} -y 2>&1|pad new_line "via NIX" nix-env -iA nixpkgs.atuin nixpkgs.jump nixpkgs.du-dust nixpkgs.lazygit nixpkgs.skim 2>&1|pad @@ -278,21 +287,21 @@ new_line "via NIX" if dnf list --quiet pam_ssh_agent_auth >/dev/null 2>&1; then PAM_SSH_PKG="pam_ssh_agent_auth" else - echo -e "${Yello}WARNING: pam_ssh_agent_auth not available in repos. sudo via SSH agent won't work.${NC}" + echo -e "${Yello}WARNING: pam_ssh_agent_auth not available in repos. $SUDO via SSH agent won't work.${NC}" fi - sudo dnf install neovim fish $ACT_PACKAGES fd-find ${PAM_SSH_PKG:+$PAM_SSH_PKG} -y 2>&1|pad + $SUDO dnf install neovim fish $ACT_PACKAGES fd-find ${PAM_SSH_PKG:+$PAM_SSH_PKG} -y 2>&1|pad new_line "via NIX" nix-env -iA nixpkgs.fish nixpkgs.neovim nixpkgs.direnv nixpkgs.atuin nixpkgs.jump nixpkgs.du-dust nixpkgs.lazygit 2>&1|pad {{ else if eq .chezmoi.osRelease.id "arch" "archarm" -}} - sudo pacman -Sy --noconfirm neovim fish atuin $ACT_PACKAGES fd skim lazygit 2>&1|pad + $SUDO pacman -Sy --noconfirm neovim fish atuin $ACT_PACKAGES fd skim lazygit 2>&1|pad new_line "via NIX" nix-env -iA nixpkgs.jump nixpkgs.du-dust 2>&1|pad {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - sudo apt-get install fish -y 2>&1|pad - sudo apt-get install neovim -y 2>&1|pad - sudo apt-get install $ACT_PACKAGES fd-find libpam-ssh-agent-auth -y 2>&1|pad + $SUDO apt-get install fish -y 2>&1|pad + $SUDO apt-get install neovim -y 2>&1|pad + $SUDO apt-get install $ACT_PACKAGES fd-find libpam-ssh-agent-auth -y 2>&1|pad new_line "via NIX" nix-env -iA nixpkgs.neovim nixpkgs.lazygit nixpkgs.jump nixpkgs.skim nixpkgs.du-dust nixpkgs.atuin 2>&1|pad @@ -319,7 +328,7 @@ fi {{ if eq .chezmoi.os "linux" -}} if [ "$SKIP_TIMEZONE" -eq 0 ]; then new_line "Setting timezone to Moscow" - sudo timedatectl set-timezone Europe/Moscow + $SUDO timedatectl set-timezone Europe/Moscow fi {{ end -}} @@ -337,7 +346,7 @@ new_line "Change default shell to fish for user $USER" ## Change default shell to fish if [ "$(basename $SHELL)" != "fish" ] then - sudo chsh -s $(command -v fish) $USER + $SUDO chsh -s $(command -v fish) $USER fi tput csr 0 $LINES