Couple improvements to the install-stormux script. make sure hostname doesn't contain spaces. Try to make sure current information for mirrors even if current iso is a bit out of date.

This commit is contained in:
Storm Dragon
2026-05-23 06:44:20 -04:00
parent 9a0a6fef00
commit 973b2573c8
+84 -2
View File
@@ -933,12 +933,55 @@ get_bios_install_disk() {
# System information gathering # System information gathering
# #
is_valid_hostname() {
local candidate="$1"
local label
local -a labels
if [[ -z "$candidate" ]] || [[ ${#candidate} -gt 253 ]]; then
return 1
fi
if [[ "$candidate" == .* ]] || [[ "$candidate" == *. ]] || [[ "$candidate" == *..* ]]; then
return 1
fi
if [[ "$candidate" == *[!A-Za-z0-9.-]* ]]; then
return 1
fi
IFS=. read -r -a labels <<< "$candidate"
for label in "${labels[@]}"; do
if [[ -z "$label" ]] || [[ ${#label} -gt 63 ]]; then
return 1
fi
if [[ ! "$label" =~ ^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$ ]]; then
return 1
fi
done
return 0
}
gather_system_info() { gather_system_info() {
log_info "=== System Configuration ===" log_info "=== System Configuration ==="
# Hostname # Hostname
echo "Enter hostname for the new system:" echo "Hostnames may contain letters, numbers, and hyphens, with optional dots between name parts."
read -r hostname echo "They cannot contain spaces or underscores, and each part must start and end with a letter or number."
echo "Examples: stormux, stormux-laptop, stormux-desktop"
while true; do
echo "Enter hostname for the new system:"
read -r hostname
if is_valid_hostname "$hostname"; then
break
fi
echo "ERROR: Invalid hostname."
echo "Use letters, numbers, and hyphens only; do not use spaces. Example: stormux-laptop"
done
log_info "Hostname set to: $hostname" log_info "Hostname set to: $hostname"
# Root password # Root password
@@ -1173,6 +1216,40 @@ gather_system_info() {
# Base system installation # Base system installation
# #
refresh_package_sources() {
local mirrorlist="/etc/pacman.d/mirrorlist"
local mirrorlistBackup="${mirrorlist}.stormux-backup"
local targetSyncDir="$mountPoint/var/lib/pacman/sync"
log_info "Refreshing package mirrors and databases"
if command -v reflector >/dev/null 2>&1; then
log_info "Selecting recently synced fast Arch mirrors"
cp -a "$mirrorlist" "$mirrorlistBackup"
if reflector --protocol https --latest 20 --sort rate --number 10 --save "$mirrorlist"; then
log_info "Mirrorlist refreshed"
else
log_warning "Mirror refresh failed; keeping the existing mirrorlist"
cp -a "$mirrorlistBackup" "$mirrorlist"
fi
else
log_warning "reflector is not installed; using the existing mirrorlist"
fi
log_info "Forcing package database refresh"
if ! pacman -Syy --noconfirm; then
log_error "Package database refresh failed"
return 1
fi
log_info "Clearing target package sync cache for pacstrap"
mkdir -p "$targetSyncDir"
rm -f "$targetSyncDir"/*.db "$targetSyncDir"/*.db.sig "$targetSyncDir"/*.files "$targetSyncDir"/*.files.sig
return 0
}
install_base_system() { install_base_system() {
log_info "=== Installing Base System ===" log_info "=== Installing Base System ==="
@@ -1278,6 +1355,11 @@ install_base_system() {
log_info "Installing packages: ${allPackages[*]}" log_info "Installing packages: ${allPackages[*]}"
log_info "Installing packages (this may take several minutes)" log_info "Installing packages (this may take several minutes)"
if ! refresh_package_sources; then
log_error "Could not refresh package sources"
return 1
fi
# Run pacstrap # Run pacstrap
if ! pacstrap "$mountPoint" "${allPackages[@]}"; then if ! pacstrap "$mountPoint" "${allPackages[@]}"; then
log_error "pacstrap failed" log_error "pacstrap failed"