feat: improve user prompts and logging in setup script for better clarity
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
b3a4c4bd78
commit
5aada55fd3
39
setup.sh
39
setup.sh
@ -111,7 +111,7 @@ die() {
|
||||
|
||||
# Request sudo credentials upfront
|
||||
request_sudo() {
|
||||
log_info "Requesting sudo privileges to avoid interruptions later..."
|
||||
log_info "This script requires sudo privileges to run, please enter your password."
|
||||
sudo -v || die "Failed to obtain sudo privileges"
|
||||
|
||||
# Keep sudo credentials refreshed in the background
|
||||
@ -120,8 +120,6 @@ request_sudo() {
|
||||
|
||||
# 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
|
||||
@ -281,7 +279,9 @@ prepare_hostname() {
|
||||
log_success "Hostname already found in $hostname_file. Using $hostname."
|
||||
return
|
||||
else
|
||||
die "No hostname provided. Please provide a hostname as the first argument."
|
||||
hostname=$(hostname)
|
||||
log_warning "No hostname provided. Defaulting to the currently set hostname on the system. ($hostname)"
|
||||
return
|
||||
fi
|
||||
|
||||
log_info "Setting hostname to $hostname..."
|
||||
@ -292,15 +292,14 @@ prepare_hostname() {
|
||||
}
|
||||
|
||||
warning_prompt() {
|
||||
log_success "This script will set up your machine using Menno's Dotfiles repository.\n"
|
||||
log_error "Please ensure you have a backup of your data before proceeding."
|
||||
log_error "This script will modify system files and may require sudo permissions.\n"
|
||||
log_info "This script works best on a fresh Fedora, Ubuntu or Arch Linux installation."
|
||||
log_info "Setup starts in 5 seconds, to abort use Ctrl+C to exit NOW."
|
||||
sleep 5
|
||||
|
||||
echo ""
|
||||
log_info "Starting setup..."
|
||||
log_error "Please ensure you have a backup of your data before proceeding."
|
||||
log_error "This script will modify system files and may require sudo permissions."
|
||||
echo ""
|
||||
log_info "This script has been tested on Ubuntu 24.04, Ubuntu 24.10, and Fedora 41."
|
||||
log_info "Setup starts in 10 seconds, to abort use Ctrl+C to exit NOW."
|
||||
echo ""
|
||||
sleep 10
|
||||
}
|
||||
|
||||
check_selinux() {
|
||||
@ -451,18 +450,15 @@ main() {
|
||||
local hostname="${1:-}"
|
||||
local continue_flag="${2:-}"
|
||||
|
||||
# Require hostname
|
||||
if [ -z "$hostname" ]; then
|
||||
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..."
|
||||
echo ""
|
||||
git clone "$GIT_REPO" "$DOTFILES_PATH" || die "Failed to clone dotfiles repository"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "$continue_flag" = "--continue" ]; then
|
||||
@ -497,9 +493,12 @@ EOF
|
||||
touch "$SETUP_MARKER" || die "Failed to create setup marker"
|
||||
|
||||
# Final success message
|
||||
log_success "\nSetup complete. Please logout / restart to continue with 'dotf update'.\n"
|
||||
log_error "\n!!! Please logout / restart to continue !!!"
|
||||
log_error "~~~ Proceed by running 'dotf update' ~~~\n"
|
||||
echo ""
|
||||
log_success "Setup complete. Please logout / restart to continue."
|
||||
echo ""
|
||||
log_error "!!! Please logout / restart to continue !!!"
|
||||
log_error "~~~ Proceed by running 'dotf update' ~~~"
|
||||
echo ""
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user