Compare commits

..

No commits in common. "1f59cb6a36c63e46a3495165eff027adb35a8419" and "11a4c59e18c2d5b76f0a88e30d3b82d7dbf3e5da" have entirely different histories.

2 changed files with 38 additions and 56 deletions

View file

@ -7,7 +7,7 @@ It uses a twostage approach:
- Prompts for root if needed
- Downloads and runs the latest interactive wizard
2. **Remote setup wizard** (pulled from Git)
- Menudriven (`whiptail`) configuration: updates, sudo, hostname, SSH keys, aliases, fastfetch, CIFS mounts, etc.
- Menudriven (`whiptail`) configuration: updates, sudo, hostname, SSH keys, aliases, neofetch, CIFS mounts, etc.
---

View file

@ -1,7 +1,7 @@
#!/bin/bash
###############################################################################
# setup.sh - Interactive Debian VM bootstrap wizard #
# Jordan-friendly edition (whiptail UI, aliases, fastfetch, CIFS, etc.) #
# Jordan-friendly edition (whiptail UI, aliases, neofetch, CIFS, etc.) #
###############################################################################
set -euo pipefail
@ -63,7 +63,7 @@ fi
# Welcome #
###############################################################################
whiptail --title "VM Setup Wizard" --yesno "\
Welcome!\n\nThis wizard will update the system, configure sudo, hostname,\naliases, fastfetch, optional tools, CIFS mounts, and SSH keys.\n\nContinue?" 12 70 || exit 0
Welcome!\n\nThis wizard will update the system, configure sudo, hostname,\naliases, neofetch, optional tools, CIFS mounts, and SSH keys.\n\nContinue?" 12 70 || exit 0
###############################################################################
# Core packages & sudo #
@ -100,44 +100,44 @@ hostnamectl set-hostname "$NEW_HOST"
msg "Hostname set to $NEW_HOST"
###############################################################################
# SSH keys for root (idempotent overwrite per run) #
# SSH keys for root #
###############################################################################
install -d -m 700 /root/.ssh
chmod 700 /root/.ssh
TMP_KEYS_ROOT=$(mktemp)
if [[ -n "$DEFAULT_SSH_KEY" ]]; then
printf '%s\n' "$DEFAULT_SSH_KEY" >>"$TMP_KEYS_ROOT"
fi
test -n "$DEFAULT_SSH_KEY" && {
grep -qxF "$DEFAULT_SSH_KEY" /root/.ssh/authorized_keys 2>/dev/null || \
echo "$DEFAULT_SSH_KEY" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
msg "Default SSH key added for root"
}
if confirm "Add additional SSH public key for root?"; then
KEY=$(whiptail --title "SSH Key (root)" --inputbox "Paste your public key for root:" 12 70 3>&1 1>&2 2>&3) || die "Cancelled"
[[ -n "$KEY" ]] && printf '%s\n' "$KEY" >>"$TMP_KEYS_ROOT"
fi
# de-duplicate and overwrite authorized_keys
awk '!seen[$0]++' "$TMP_KEYS_ROOT" > /root/.ssh/authorized_keys
grep -qxF "$KEY" /root/.ssh/authorized_keys 2>/dev/null || echo "$KEY" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
msg "Root authorized_keys updated (overwritten this run)"
rm -f "$TMP_KEYS_ROOT"
msg "Additional SSH key added for root"
fi
###############################################################################
# SSH keys for user jordanwages (idempotent overwrite per run) #
# SSH keys for user jordanwages #
###############################################################################
USER_NAME="jordanwages"
USER_HOME="/home/$USER_NAME"
install -d -m 700 "$USER_HOME/.ssh"
chown $USER_NAME:$USER_NAME "$USER_HOME/.ssh"
TMP_KEYS_USER=$(mktemp)
if [[ -n "$DEFAULT_SSH_KEY" ]]; then
printf '%s\n' "$DEFAULT_SSH_KEY" >>"$TMP_KEYS_USER"
fi
if confirm "Add additional SSH public key for $USER_NAME?"; then
KEY=$(whiptail --title "SSH Key ($USER_NAME)" --inputbox "Paste public key for $USER_NAME:" 12 70 3>&1 1>&2 2>&3) || die "Cancelled"
[[ -n "$KEY" ]] && printf '%s\n' "$KEY" >>"$TMP_KEYS_USER"
fi
awk '!seen[$0]++' "$TMP_KEYS_USER" > "$USER_HOME/.ssh/authorized_keys"
test -n "$DEFAULT_SSH_KEY" && {
grep -qxF "$DEFAULT_SSH_KEY" "$USER_HOME/.ssh/authorized_keys" 2>/dev/null || \
echo "$DEFAULT_SSH_KEY" >> "$USER_HOME/.ssh/authorized_keys"
chown $USER_NAME:$USER_NAME "$USER_HOME/.ssh/authorized_keys"
chmod 600 "$USER_HOME/.ssh/authorized_keys"
msg "$USER_NAME authorized_keys updated (overwritten this run)"
rm -f "$TMP_KEYS_USER"
msg "Default SSH key added for $USER_NAME"
}
if confirm "Add additional SSH public key for $USER_NAME?"; then
KEY=$(whiptail --title "SSH Key ($USER_NAME)" --inputbox "Paste public key for $USER_NAME:" 12 70 3>&1 1>&2 2>&3) || die "Cancelled"
grep -qxF "$KEY" "$USER_HOME/.ssh/authorized_keys" 2>/dev/null || echo "$KEY" >> "$USER_HOME/.ssh/authorized_keys"
chown $USER_NAME:$USER_NAME "$USER_HOME/.ssh/authorized_keys"
chmod 600 "$USER_HOME/.ssh/authorized_keys"
msg "Additional SSH key added for $USER_NAME"
fi
###############################################################################
# Optional utilities #
@ -148,18 +148,16 @@ SEL_RAW=$(whiptail --title "Extra Utilities" --checklist \
"Select additional packages to install:" 15 60 8 \
"${OPTS[@]}" 3>&1 1>&2 2>&3) || true
IFS=' ' read -r -a SEL_PKGS <<< "${SEL_RAW//\"/}"
ensure_pkgs bat ncdu fastfetch cifs-utils "${SEL_PKGS[@]}"
ensure_pkgs bat ncdu neofetch cifs-utils "${SEL_PKGS[@]}"
# Aliases
echo "alias cat='batcat --paging=never'" >/etc/profile.d/10-bat_alias.sh
echo "alias du='ncdu'" >/etc/profile.d/10-ncdu_alias.sh
chmod +x /etc/profile.d/10-*alias.sh
# Ensure only fastfetch runs on login
rm -f /etc/profile.d/90-neofetch.sh
echo 'fastfetch' >/etc/profile.d/90-fastfetch.sh
chmod +x /etc/profile.d/90-fastfetch.sh
echo 'neofetch' >/etc/profile.d/90-neofetch.sh
chmod +x /etc/profile.d/90-neofetch.sh
###############################################################################
# NFS mounts (managed block, idempotent) #
# NFS mounts #
###############################################################################
NFS_HOSTS=(jimmu keiko keitai)
OPTS=(); for h in "${NFS_HOSTS[@]}"; do OPTS+=("$h" "" OFF); done
@ -168,33 +166,17 @@ SEL_HOSTS=$(whiptail --title "NFS Mounts" --checklist \
"${OPTS[@]}" 3>&1 1>&2 2>&3) || true
mkdir -p /media
for host in "${NFS_HOSTS[@]}"; do
[[ $SEL_HOSTS == *\"$host\"* ]] && mkdir -p "/media/$host"
done
# Clean up legacy lines from prior runs (pre-managed-block versions)
for host in "${NFS_HOSTS[@]}"; do
TEMPLATE="${host}.wageshouse:/Data /media/${host} nfs4 _netdev,x-systemd.automount,noatime 0 0"
sed -i "#^${host}\.wageshouse:/Data /media/${host} nfs4 _netdev,x-systemd.automount,noatime 0 0$#d" /etc/fstab || true
sed -i "#^# ${host}\.wageshouse:/Data /media/${host} nfs4 _netdev,x-systemd.automount,noatime 0 0$#d" /etc/fstab || true
done
# Replace the managed block with current selections
BLOCK_START="# BEGIN setup.sh managed NFS"
BLOCK_END="# END setup.sh managed NFS"
sed -i "/^$BLOCK_START$/,/^$BLOCK_END$/d" /etc/fstab || true
{
echo "$BLOCK_START"
for host in "${NFS_HOSTS[@]}"; do
TEMPLATE="${host}.wageshouse:/Data /media/${host} nfs4 _netdev,x-systemd.automount,noatime 0 0"
if [[ $SEL_HOSTS == *\"$host\"* ]]; then
echo "$TEMPLATE"
mkdir -p "/media/$host"
grep -q "${host}.wageshouse" /etc/fstab && \
sed -i "#${host}\.wageshouse#d" /etc/fstab
echo "$TEMPLATE" >> /etc/fstab
else
echo "# $TEMPLATE"
grep -q "${host}.wageshouse" /etc/fstab || echo "# $TEMPLATE" >> /etc/fstab
fi
done
echo "$BLOCK_END"
} >> /etc/fstab
if ! mount -a 2>>"$LOGFILE"; then
msg "⚠️ Some NFS mounts failed. Re-run the script to check configuration."
@ -204,4 +186,4 @@ fi
# Summary #
###############################################################################
msg "\
Setup complete!\n\n• Hostname: $NEW_HOST\n• Sudoers: ${SEL_SUDO//\"/ }\n• Packages: bat ncdu fastfetch ${SEL_PKGS[*]}\n• CIFS: ${SEL_HOSTS//\"/ }\n\nLog saved to $LOGFILE\n\nEnjoy your new Debian VM!"
Setup complete!\n\n• Hostname: $NEW_HOST\n• Sudoers: ${SEL_SUDO//\"/ }\n• Packages: bat ncdu neofetch ${SEL_PKGS[*]}\n• CIFS: ${SEL_HOSTS//\"/ }\n\nLog saved to $LOGFILE\n\nEnjoy your new Debian VM!"