mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -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
|
||||
fi
|
||||
|
||||
if ! sudo -n true 2>/dev/null; then
|
||||
log_message "ERROR" "This script requires sudo privileges"
|
||||
exit 4
|
||||
# Check if sudo is available, but don't require it upfront
|
||||
if sudo -n true 2>/dev/null; then
|
||||
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
|
||||
|
||||
debug_log "Sudo privileges confirmed"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -239,7 +241,7 @@ detect_os() {
|
||||
log_message "INFO" "Detecting operating system..."
|
||||
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
# shellcheck source=/etc/os-release
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
OS_NAME="$ID"
|
||||
OS_VERSION="$VERSION_ID"
|
||||
|
||||
Reference in New Issue
Block a user