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=""
|
||||
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."
|
||||
|
@ -54,10 +53,10 @@
|
|||
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
|
||||
|
@ -156,9 +155,9 @@
|
|||
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.."
|
||||
|
@ -174,5 +173,4 @@
|
|||
echo "Alpine it is.."
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue