1
0
forked from finn/tinyboard

prompt for hub username with armbian as default, replace all hardcoded references

This commit is contained in:
Justin Oros
2026-04-16 10:29:53 -07:00
parent 95a56ef4f0
commit d21997af43

View File

@@ -16,6 +16,9 @@ header() { echo -e "\n${CYAN}═════════════════
header "TinyBoard Hub Setup" header "TinyBoard Hub Setup"
read -rp "Hub username [armbian]: " HUB_USER
HUB_USER="${HUB_USER:-armbian}"
header "Detecting Package Manager" header "Detecting Package Manager"
if command -v apt-get >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then
PKG_MANAGER="apt" PKG_MANAGER="apt"
@@ -69,39 +72,39 @@ else
fi fi
header "Armbian User Setup" header "Armbian User Setup"
if id armbian >/dev/null 2>&1; then if id "$HUB_USER" >/dev/null 2>&1; then
warn "User 'armbian' already exists, skipping creation." warn "User '$HUB_USER' already exists, skipping creation."
else else
info "Creating armbian user..." info "Creating armbian user..."
groupadd -g 1000 armbian 2>/dev/null || true groupadd -g 1000 "$HUB_USER" 2>/dev/null || true
useradd -m -u 1000 -g 1000 -s /bin/bash armbian useradd -m -u 1000 -g 1000 -s /bin/bash "$HUB_USER"
ADDED_TO_GROUP=false ADDED_TO_GROUP=false
if getent group sudo >/dev/null 2>&1; then if getent group sudo >/dev/null 2>&1; then
if usermod -aG sudo armbian 2>/dev/null; then if usermod -aG sudo "$HUB_USER" 2>/dev/null; then
ADDED_TO_GROUP=true ADDED_TO_GROUP=true
fi fi
fi fi
if [ "$ADDED_TO_GROUP" = false ] && getent group wheel >/dev/null 2>&1; then if [ "$ADDED_TO_GROUP" = false ] && getent group wheel >/dev/null 2>&1; then
if usermod -aG wheel armbian 2>/dev/null; then if usermod -aG wheel "$HUB_USER" 2>/dev/null; then
ADDED_TO_GROUP=true ADDED_TO_GROUP=true
fi fi
fi fi
if [ "$ADDED_TO_GROUP" = false ]; then if [ "$ADDED_TO_GROUP" = false ]; then
warn "Neither sudo nor wheel group found — armbian user has no sudo access." warn "Neither sudo nor wheel group found — $HUB_USER user has no sudo access."
fi fi
info "armbian user created." info "$HUB_USER user created."
echo "" echo ""
warn "Set a password for the armbian user:" warn "Set a password for the $HUB_USER user:"
passwd armbian passwd "$HUB_USER"
fi fi
ARMBIAN_HOME="/home/armbian" ARMBIAN_HOME="/home/$HUB_USER"
SSH_DIR="$ARMBIAN_HOME/.ssh" SSH_DIR="$ARMBIAN_HOME/.ssh"
mkdir -p "$SSH_DIR" mkdir -p "$SSH_DIR"
touch "$SSH_DIR/authorized_keys" touch "$SSH_DIR/authorized_keys"
chown -R armbian:armbian "$SSH_DIR" chown -R "$HUB_USER":"$HUB_USER" "$SSH_DIR"
chmod 700 "$SSH_DIR" chmod 700 "$SSH_DIR"
chmod 600 "$SSH_DIR/authorized_keys" chmod 600 "$SSH_DIR/authorized_keys"
@@ -146,17 +149,17 @@ else
fi fi
groupadd fuse 2>/dev/null || true groupadd fuse 2>/dev/null || true
usermod -aG fuse armbian 2>/dev/null || true usermod -aG fuse "$HUB_USER" 2>/dev/null || true
info "armbian added to fuse group." info "$HUB_USER added to fuse group."
header "Rclone Setup" header "Rclone Setup"
RCLONE_CONF="$ARMBIAN_HOME/.config/rclone/rclone.conf" RCLONE_CONF="$ARMBIAN_HOME/.config/rclone/rclone.conf"
mkdir -p "$(dirname "$RCLONE_CONF")" mkdir -p "$(dirname "$RCLONE_CONF")"
chown -R armbian:armbian "$ARMBIAN_HOME/.config" chown -R "$HUB_USER":"$HUB_USER" "$ARMBIAN_HOME/.config"
if [ ! -f "$RCLONE_CONF" ]; then if [ ! -f "$RCLONE_CONF" ]; then
touch "$RCLONE_CONF" touch "$RCLONE_CONF"
chown armbian:armbian "$RCLONE_CONF" chown "$HUB_USER":"$HUB_USER" "$RCLONE_CONF"
info "Empty rclone.conf created at $RCLONE_CONF." info "Empty rclone.conf created at $RCLONE_CONF."
else else
warn "rclone.conf already exists, skipping." warn "rclone.conf already exists, skipping."
@@ -166,24 +169,24 @@ header "Mount Point Setup"
read -rp "Mount point for spoke filesystems [/mnt/hub]: " MOUNT_POINT read -rp "Mount point for spoke filesystems [/mnt/hub]: " MOUNT_POINT
MOUNT_POINT="${MOUNT_POINT:-/mnt/hub}" MOUNT_POINT="${MOUNT_POINT:-/mnt/hub}"
mkdir -p "$MOUNT_POINT" mkdir -p "$MOUNT_POINT"
chown armbian:armbian "$MOUNT_POINT" chown "$HUB_USER":"$HUB_USER" "$MOUNT_POINT"
info "Mount point created at $MOUNT_POINT." info "Mount point created at $MOUNT_POINT."
header "Crontab Setup" header "Crontab Setup"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HELPER="$SCRIPT_DIR/../hubspoke-helper.sh" HELPER="$SCRIPT_DIR/../hubspoke-helper.sh"
CRON_LINE="@reboot $HELPER hub start-background" CRON_LINE="@reboot $HELPER hub start-background"
EXISTING=$(crontab -u armbian -l 2>/dev/null || true) EXISTING=$(crontab -u "$HUB_USER" -l 2>/dev/null || true)
if echo "$EXISTING" | grep -qF "hub start-background"; then if echo "$EXISTING" | grep -qF "hub start-background"; then
warn "Crontab entry already exists, skipping." warn "Crontab entry already exists, skipping."
else else
(echo "$EXISTING"; echo "$CRON_LINE") | crontab -u armbian - (echo "$EXISTING"; echo "$CRON_LINE") | crontab -u "$HUB_USER" -
info "Added @reboot crontab entry for rclone mount." info "Added @reboot crontab entry for rclone mount."
fi fi
header "Hub Setup Complete" header "Hub Setup Complete"
echo -e " Armbian user: ${GREEN}armbian${NC}" echo -e " Hub user: ${GREEN}$HUB_USER${NC}"
echo -e " SSH config: ${GREEN}GatewayPorts yes, AllowTcpForwarding yes${NC}" echo -e " SSH config: ${GREEN}GatewayPorts yes, AllowTcpForwarding yes${NC}"
echo -e " FUSE: ${GREEN}user_allow_other enabled${NC}" echo -e " FUSE: ${GREEN}user_allow_other enabled${NC}"
echo -e " rclone config: ${GREEN}$RCLONE_CONF${NC}" echo -e " rclone config: ${GREEN}$RCLONE_CONF${NC}"