add config file: aria2 asdf zellij zsh bash starship Initial commit Changes to be committed: new file: .gitignore new file: app/aria2/AriaNg_config.json new file: app/aria2/AriaNg_config.toml new file: bombadil.toml new file: common/shell/asdf/asdfrc new file: common/shell/bash/bash.toml new file: common/shell/bash/bashrc new file: common/shell/shell.toml new file: common/shell/starship/starship.toml new file: common/shell/zellij/.config.kdl.swp new file: common/shell/zellij/config.kdl new file: common/shell/zellij/themes/README.md new file: common/shell/zellij/themes/catppuccin.kdl new file: common/shell/zellij/themes/dracula.kdl new file: common/shell/zellij/themes/everforest-dark.kdl new file: common/shell/zellij/themes/everforest-light.kdl new file: common/shell/zellij/themes/gruvbox.kdl new file: common/shell/zellij/themes/kanagawa.kdl new file: common/shell/zellij/themes/molokai-dark.kdl new file: common/shell/zellij/themes/nord.kdl new file: common/shell/zellij/themes/one-half-dark.kdl new file: common/shell/zellij/themes/solarized-dark.kdl new file: common/shell/zellij/themes/solarized-light.kdl new file: common/shell/zellij/themes/tokyo-night-dark.kdl new file: common/shell/zellij/themes/tokyo-night-light.kdl new file: common/shell/zellij/themes/tokyo-night-storm.kdl new file: common/shell/zellij/themes/tokyo-night.kdl new file: common/shell/zsh/check.sh new file: common/shell/zsh/zsh.toml new file: common/shell/zsh/zshenv new file: common/shell/zsh/zshrc new file: scripts/check.sh
45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
have() {
|
|
have=$(which "$1" 2>/dev/null) && test -n "$have"
|
|
}
|
|
|
|
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
user_can_sudo() {
|
|
# Check if sudo is installed
|
|
command_exists sudo || return 1
|
|
# The following command has 3 parts:
|
|
#
|
|
# 1. Run `sudo` with `-v`. Does the following:
|
|
# • with privilege: asks for a password immediately.
|
|
# • without privilege: exits with error code 1 and prints the message:
|
|
# Sorry, user <username> may not run sudo on <hostname>
|
|
#
|
|
# 2. Pass `-n` to `sudo` to tell it to not ask for a password. If the
|
|
# password is not required, the command will finish with exit code 0.
|
|
# If one is required, sudo will exit with error code 1 and print the
|
|
# message:
|
|
# sudo: a password is required
|
|
#
|
|
# 3. Check for the words "may not run sudo" in the output to really tell
|
|
# whether the user has privileges or not. For that we have to make sure
|
|
# to run `sudo` in the default locale (with `LANG=`) so that the message
|
|
# stays consistent regardless of the user's locale.
|
|
#
|
|
! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
|
|
}
|
|
|
|
[[ $EUID -ne 0 ]] && SUDO=sudo
|
|
|
|
command_exists apt && PACKAGE=apt
|
|
command_exists yum && PACKAGE=yum
|
|
command_exists pkg && PACKAGE=pkg
|
|
command_exists zypper && PACKAGE=zypper
|
|
|
|
|
|
|