feat: request sudo credentials upfront to avoid interruptions during setup
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
This commit is contained in:
parent
d3caf87696
commit
59fc5e5e10
18
setup.sh
18
setup.sh
@ -37,6 +37,21 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Request sudo credentials upfront
|
||||
request_sudo() {
|
||||
log_info "Requesting sudo privileges to avoid interruptions later..."
|
||||
sudo -v || die "Failed to obtain sudo privileges"
|
||||
|
||||
# Keep sudo credentials refreshed in the background
|
||||
(while true; do sudo -v; sleep 50; done) &
|
||||
SUDO_KEEPALIVE_PID=$!
|
||||
|
||||
# Ensure we kill the keepalive process when the script exits
|
||||
trap 'kill $SUDO_KEEPALIVE_PID 2>/dev/null || true' EXIT
|
||||
|
||||
log_success "Sudo privileges obtained."
|
||||
}
|
||||
|
||||
# Ensure we're running interactively
|
||||
ensure_interactive() {
|
||||
# If stdin is not a terminal, reconnect stdin to /dev/tty
|
||||
@ -369,6 +384,9 @@ main() {
|
||||
die "Hostname is required as the first argument. Usage: $0 <hostname> [--continue]"
|
||||
fi
|
||||
|
||||
# Request sudo credentials upfront
|
||||
request_sudo
|
||||
|
||||
# Clone dotfiles if needed
|
||||
if [ ! -d "$DOTFILES_PATH" ]; then
|
||||
log_info "Cloning dotfiles repo..."
|
||||
|
Loading…
x
Reference in New Issue
Block a user