From d25618deb0b005e8ecc01212a8ecf3ae14e1c4d3 Mon Sep 17 00:00:00 2001 From: pika <67532734+pik4li@users.noreply.github.com> Date: Tue, 7 Jan 2025 03:58:46 +0100 Subject: [PATCH] addet repetetive code..g --- .bash/.aliases.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.bash/.aliases.sh b/.bash/.aliases.sh index 69d96f3..9ae6e80 100644 --- a/.bash/.aliases.sh +++ b/.bash/.aliases.sh @@ -1,3 +1,19 @@ +# ─< 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_warning "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_info "Root access confirmed." + _sudo="" + fi +} + __autopackager__() { . /etc/os-release case "$ID" in