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