1
0
forked from finn/tinyboard

Compare commits

..

2 Commits

Author SHA1 Message Date
Justin Oros
50fb313f9a fix hardcoded armbian string in user creation log message 2026-04-16 10:30:47 -07:00
Justin Oros
d21997af43 prompt for hub username with armbian as default, replace all hardcoded references 2026-04-16 10:29:53 -07:00

View File

@@ -16,6 +16,9 @@ header() { echo -e "\n${CYAN}═════════════════
header "TinyBoard Hub Setup"
read -rp "Hub username [armbian]: " HUB_USER
HUB_USER="${HUB_USER:-armbian}"
header "Detecting Package Manager"
if command -v apt-get >/dev/null 2>&1; then
PKG_MANAGER="apt"
@@ -69,39 +72,39 @@ else
fi
header "Armbian User Setup"
if id armbian >/dev/null 2>&1; then
warn "User 'armbian' already exists, skipping creation."
if id "$HUB_USER" >/dev/null 2>&1; then
warn "User '$HUB_USER' already exists, skipping creation."
else
info "Creating armbian user..."
groupadd -g 1000 armbian 2>/dev/null || true
useradd -m -u 1000 -g 1000 -s /bin/bash armbian
info "Creating $HUB_USER user..."
groupadd -g 1000 "$HUB_USER" 2>/dev/null || true
useradd -m -u 1000 -g 1000 -s /bin/bash "$HUB_USER"
ADDED_TO_GROUP=false
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
fi
fi
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
fi
fi
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
info "armbian user created."
info "$HUB_USER user created."
echo ""
warn "Set a password for the armbian user:"
passwd armbian
warn "Set a password for the $HUB_USER user:"
passwd "$HUB_USER"
fi
ARMBIAN_HOME="/home/armbian"
ARMBIAN_HOME="/home/$HUB_USER"
SSH_DIR="$ARMBIAN_HOME/.ssh"
mkdir -p "$SSH_DIR"
touch "$SSH_DIR/authorized_keys"
chown -R armbian:armbian "$SSH_DIR"
chown -R "$HUB_USER":"$HUB_USER" "$SSH_DIR"
chmod 700 "$SSH_DIR"
chmod 600 "$SSH_DIR/authorized_keys"
@@ -146,17 +149,17 @@ else
fi
groupadd fuse 2>/dev/null || true
usermod -aG fuse armbian 2>/dev/null || true
info "armbian added to fuse group."
usermod -aG fuse "$HUB_USER" 2>/dev/null || true
info "$HUB_USER added to fuse group."
header "Rclone Setup"
RCLONE_CONF="$ARMBIAN_HOME/.config/rclone/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
touch "$RCLONE_CONF"
chown armbian:armbian "$RCLONE_CONF"
chown "$HUB_USER":"$HUB_USER" "$RCLONE_CONF"
info "Empty rclone.conf created at $RCLONE_CONF."
else
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
MOUNT_POINT="${MOUNT_POINT:-/mnt/hub}"
mkdir -p "$MOUNT_POINT"
chown armbian:armbian "$MOUNT_POINT"
chown "$HUB_USER":"$HUB_USER" "$MOUNT_POINT"
info "Mount point created at $MOUNT_POINT."
header "Crontab Setup"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HELPER="$SCRIPT_DIR/../hubspoke-helper.sh"
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
warn "Crontab entry already exists, skipping."
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."
fi
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 " FUSE: ${GREEN}user_allow_other enabled${NC}"
echo -e " rclone config: ${GREEN}$RCLONE_CONF${NC}"