forked from finn/tinyboard
fix function ordering and RCLONE_CONF used before definition in setup-hub.sh
This commit is contained in:
@@ -7,6 +7,23 @@ YELLOW='\033[1;33m'
|
|||||||
CYAN='\033[0;36m'
|
CYAN='\033[0;36m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
info() { echo -e "${GREEN}[+]${NC} $*"; }
|
||||||
|
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
|
||||||
|
die() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
|
||||||
|
header() { echo -e "\n${CYAN}══════════════════════════════════════════${NC}"; echo -e "${CYAN} $*${NC}"; echo -e "${CYAN}══════════════════════════════════════════${NC}"; }
|
||||||
|
|
||||||
|
check_deps() {
|
||||||
|
local missing=()
|
||||||
|
for cmd in "$@"; do
|
||||||
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||||
|
missing+=("$cmd")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ${#missing[@]} -gt 0 ]; then
|
||||||
|
die "Missing required dependencies: ${missing[*]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
check_permissions() {
|
check_permissions() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local label="$2"
|
local label="$2"
|
||||||
@@ -32,24 +49,6 @@ check_permissions() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
info() { echo -e "${GREEN}[+]${NC} $*"; }
|
|
||||||
check_deps() {
|
|
||||||
local missing=()
|
|
||||||
for cmd in "$@"; do
|
|
||||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
||||||
missing+=("$cmd")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ ${#missing[@]} -gt 0 ]; then
|
|
||||||
die "Missing required dependencies: ${missing[*]}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
|
|
||||||
die() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
|
|
||||||
header() { echo -e "\n${CYAN}══════════════════════════════════════════${NC}"; echo -e "${CYAN} $*${NC}"; echo -e "${CYAN}══════════════════════════════════════════${NC}"; }
|
|
||||||
|
|
||||||
[ "$(id -u)" -eq 0 ] || die "Run as root"
|
[ "$(id -u)" -eq 0 ] || die "Run as root"
|
||||||
|
|
||||||
check_deps ssh ssh-keygen systemctl useradd groupadd crontab
|
check_deps ssh ssh-keygen systemctl useradd groupadd crontab
|
||||||
@@ -227,11 +226,6 @@ groupadd fuse 2>/dev/null || true
|
|||||||
usermod -aG fuse "$HUB_USER" 2>/dev/null || true
|
usermod -aG fuse "$HUB_USER" 2>/dev/null || true
|
||||||
info "$HUB_USER added to fuse group."
|
info "$HUB_USER added to fuse group."
|
||||||
|
|
||||||
header "Permission Checks"
|
|
||||||
info "Checking SSH directory permissions..."
|
|
||||||
check_permissions "$SSH_DIR/authorized_keys" "authorized_keys"
|
|
||||||
[ -f "$RCLONE_CONF" ] && check_permissions "$RCLONE_CONF" "rclone.conf" || true
|
|
||||||
|
|
||||||
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")"
|
||||||
@@ -245,6 +239,11 @@ else
|
|||||||
warn "rclone.conf already exists, skipping."
|
warn "rclone.conf already exists, skipping."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
header "Permission Checks"
|
||||||
|
info "Checking SSH directory permissions..."
|
||||||
|
check_permissions "$SSH_DIR/authorized_keys" "authorized_keys"
|
||||||
|
check_permissions "$RCLONE_CONF" "rclone.conf"
|
||||||
|
|
||||||
header "Mount Point Setup"
|
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}"
|
||||||
|
|||||||
Reference in New Issue
Block a user