]> ###2026.05.28 - Initial release /dev/null) [[ -n "$_sd" ]] && SCRIPTS_DIR="$_sd" fi SCRIPTS_DIR="${SCRIPTS_DIR:-/mnt/user/appdata/Varaverk}" CONF_DIR="$SCRIPTS_DIR/Configurations" # Array must be started — appdata must be available if ! df --output=fstype /mnt/user 2>/dev/null | grep -q 'shfs'; then log "Array not started — cannot install to appdata" log "Start the array then reinstall, or wait for next boot" exit 0 fi # Clone or update repo if [[ ! -d "$SCRIPTS_DIR/.git" ]]; then log "Cloning $GITHUB ($BRANCH) → $SCRIPTS_DIR" if ! git clone --branch "$BRANCH" "$GITHUB" "$SCRIPTS_DIR" >> "$LOG" 2>&1; then log "ERROR: git clone failed — check internet access and GitHub URL" exit 1 fi log "Clone complete" else log "Updating repo in $SCRIPTS_DIR" git -C "$SCRIPTS_DIR" pull --ff-only origin "$BRANCH" >> "$LOG" 2>&1 \ && log "Pull complete" \ || log "WARNING: git pull failed — repo may have local modifications" fi # Sanity check — Plugin/unraid must exist after clone if [[ ! -d "$SCRIPTS_DIR/Plugin/unraid" ]]; then log "ERROR: Plugin/unraid not found in cloned repo — unexpected repo structure" exit 1 fi # Symlink web files if [[ -L "$WEB_DIR" ]]; then rm "$WEB_DIR" elif [[ -d "$WEB_DIR" ]]; then log "WARNING: $WEB_DIR is a real directory — not replacing (remove manually if needed)" fi if [[ ! -e "$WEB_DIR" ]]; then ln -s "$SCRIPTS_DIR/Plugin/unraid" "$WEB_DIR" log "Symlinked: $WEB_DIR → $SCRIPTS_DIR/Plugin/unraid" fi # Write varaverk.cfg if not present if [[ ! -f "$CFG_FILE" ]]; then printf 'SCRIPTS_DIR="%s"\n' "$SCRIPTS_DIR" > "$CFG_FILE" log "Created varaverk.cfg (SCRIPTS_DIR=$SCRIPTS_DIR)" fi # Create Configurations dir if git clone didn't mkdir -p "$CONF_DIR" # Bootstrap master.conf from template on first install if [[ ! -f "$CONF_DIR/master.conf" ]]; then if [[ -f "$SCRIPTS_DIR/Configurations/master.conf.template" ]]; then cp "$SCRIPTS_DIR/Configurations/master.conf.template" "$CONF_DIR/master.conf" log "Created master.conf from template — fill in HOST1 and HOST2 to continue" else log "WARNING: master.conf.template not found — master.conf not created" fi fi log "Install complete — open Varaverk in Unraid to complete setup" log "→ Plugins → Varaverk (or navigate to Settings → Utilities → Varaverk)" ]]> /dev/null) fi SCRIPTS_DIR="${_sd:-/mnt/user/appdata/Varaverk}" # Only act if source exists (array started) and symlink is missing if [[ -d "$SCRIPTS_DIR/Plugin/unraid" ]] && [[ ! -e "$WEB_DIR" ]]; then [[ -L "$WEB_DIR" ]] && rm "$WEB_DIR" ln -s "$SCRIPTS_DIR/Plugin/unraid" "$WEB_DIR" fi ]]>