testing
This commit is contained in:
parent
c811cea4b3
commit
55d75c6e4b
1 changed files with 154 additions and 154 deletions
74
distros.sh
74
distros.sh
|
@ -1,48 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
{
|
||||
distro=""
|
||||
ubuntu="false"
|
||||
debian="false"
|
||||
arch="false"
|
||||
fedora="false"
|
||||
alpine="false"
|
||||
opensuse="false"
|
||||
|
||||
distro=""
|
||||
ubuntu="false"
|
||||
debian="false"
|
||||
arch="false"
|
||||
fedora="false"
|
||||
alpine="false"
|
||||
opensuse="false"
|
||||
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
silentexec() {
|
||||
}
|
||||
silentexec() {
|
||||
echo_note "Refreshing repositories.."
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
}
|
||||
|
||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||
check_root() {
|
||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
|
@ -55,10 +54,10 @@ check_root() {
|
|||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
@ -157,9 +156,9 @@ get_packager() {
|
|||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
if check_root; then
|
||||
if check_root; then
|
||||
get_packager &&
|
||||
if $arch; then
|
||||
echo "Arch it is.."
|
||||
|
@ -175,4 +174,5 @@ if check_root; then
|
|||
echo "Alpine it is.."
|
||||
fi
|
||||
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue