mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 03:20:12 -08:00
fix: Improve sudo privilege check and provide user guidance for password prompts
This commit is contained in:
12
update.sh
12
update.sh
@@ -135,12 +135,14 @@ check_privileges() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! sudo -n true 2>/dev/null; then
|
# Check if sudo is available, but don't require it upfront
|
||||||
log_message "ERROR" "This script requires sudo privileges"
|
if sudo -n true 2>/dev/null; then
|
||||||
exit 4
|
debug_log "Sudo privileges confirmed and cached"
|
||||||
|
else
|
||||||
|
log_message "INFO" "Sudo credentials not cached - you may be prompted for password during updates"
|
||||||
|
log_message "INFO" "To avoid prompts, run: sudo -v before running this script"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug_log "Sudo privileges confirmed"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +241,7 @@ detect_os() {
|
|||||||
log_message "INFO" "Detecting operating system..."
|
log_message "INFO" "Detecting operating system..."
|
||||||
|
|
||||||
if [[ -f /etc/os-release ]]; then
|
if [[ -f /etc/os-release ]]; then
|
||||||
# shellcheck source=/etc/os-release
|
# shellcheck disable=SC1091
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
OS_NAME="$ID"
|
OS_NAME="$ID"
|
||||||
OS_VERSION="$VERSION_ID"
|
OS_VERSION="$VERSION_ID"
|
||||||
|
|||||||
Reference in New Issue
Block a user