#!/bin/bash # # Hugo Server Startup Script # # This script starts the Hugo development server with production-like settings. # It's designed to be run as a systemd service. # # Configuration: # - Site directory: /root/hydro-sterile # - Port: 1313 (Hugo default) # - Bind: 0.0.0.0 (all interfaces) # - Base URL: From hugo.yaml config # set -e SITE_DIR="/root/hydro-sterile" PORT="${HUGO_PORT:-7575}" BIND="${HUGO_BIND:-0.0.0.0}" BASEURL="${HUGO_BASEURL:-$(grep '^baseURL:' hugo.yaml | sed 's/.*: //' | tr -d "'\"")}" cd "$SITE_DIR" || exit 1 # Check if Hugo is available via npm if command -v npm >/dev/null 2>&1 && [ -d "node_modules/.bin" ]; then HUGO_CMD="./node_modules/.bin/hugo" elif command -v hugo >/dev/null 2>&1; then HUGO_CMD="hugo" else echo "ERROR: Hugo not found. Please install Hugo or run 'npm install' in $SITE_DIR" >&2 exit 1 fi # Start Hugo server # Using --noHTTPCache for development, remove for production exec "$HUGO_CMD" server \ --bind "$BIND" \ --port "$PORT" \ --baseURL "$BASEURL" \ --appendPort=false \ --disableFastRender