Add gopher deployment to remote_publish.sh (Phase 3)

Add --gopher and --gopher-only flags to deploy blog posts to SDF
gopherspace. Builds gopher content locally then rsyncs to server.
This commit is contained in:
mnw
2026-01-14 16:24:09 -06:00
parent bd45fc9e82
commit 0fb8d32e45
+85 -8
View File
@@ -1,11 +1,14 @@
#!/bin/bash
# Remote publish script for marcus-web
# Pushes local changes if needed, then builds on SDF
# Optionally deploys to gopher with --gopher or --gopher-only
set -e
SDF_HOST="mnw@sdf.org"
REMOTE_DIR="~/marcus-web"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Colors for output
RED='\033[0;31m'
@@ -13,7 +16,47 @@ GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Flags
GOPHER=false
GOPHER_ONLY=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--gopher)
GOPHER=true
shift
;;
--gopher-only)
GOPHER_ONLY=true
GOPHER=true
shift
;;
--help|-h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --gopher Deploy to both Hugo site and gopher"
echo " --gopher-only Deploy only to gopher (skip Hugo)"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo -e "${GREEN}=== Remote Publish ===${NC}"
if [[ "$GOPHER" == "true" ]]; then
if [[ "$GOPHER_ONLY" == "true" ]]; then
echo -e "${YELLOW}Mode: Gopher only${NC}"
else
echo -e "${YELLOW}Mode: Hugo + Gopher${NC}"
fi
fi
echo ""
# Check if we're in a git repo
@@ -119,18 +162,52 @@ echo ""
echo -e "${GREEN}=== Connecting to SDF ===${NC}"
echo ""
# Build the remote command
REMOTE_CMD="cd $REMOTE_DIR && git pull && hugo && mkhomepg -p"
# Try SSH with key auth first, fall back to password prompt
# Test SSH connectivity
SSH_AUTH="password"
if ssh -o BatchMode=yes -o ConnectTimeout=5 "$SDF_HOST" "echo 'SSH key auth successful'" 2>/dev/null; then
SSH_AUTH="key"
echo "Using SSH key authentication..."
ssh "$SDF_HOST" "$REMOTE_CMD"
else
echo "SSH key auth failed or not configured, using password..."
echo "Using password authentication..."
fi
# Hugo deployment (unless --gopher-only)
if [[ "$GOPHER_ONLY" != "true" ]]; then
echo ""
echo -e "${GREEN}=== Deploying Hugo Site ===${NC}"
REMOTE_CMD="cd $REMOTE_DIR && git pull && hugo && mkhomepg -p"
ssh "$SDF_HOST" "$REMOTE_CMD"
echo ""
echo -e "${GREEN}Hugo site published!${NC}"
echo "Site is live at: https://mnw.sdf.org/"
fi
# Gopher deployment (if --gopher or --gopher-only)
if [[ "$GOPHER" == "true" ]]; then
echo ""
echo -e "${GREEN}=== Deploying to Gopher ===${NC}"
# Build gopher content locally
echo "Converting posts to gopher format..."
cd "$PROJECT_ROOT"
python3 "$SCRIPT_DIR/gopher/convert_to_gopher.py" --all --output "$PROJECT_ROOT/gopher_build/blog/"
echo "Generating gophermaps..."
python3 "$SCRIPT_DIR/gopher/generate_gophermaps.py" --output "$PROJECT_ROOT/gopher_build/blog/"
# Sync to SDF (--delete removes posts where phlog was set to false)
echo "Syncing to SDF gopherspace..."
rsync -avz --delete "$PROJECT_ROOT/gopher_build/blog/" "$SDF_HOST:~/gopher/blog/"
# Fix permissions on SDF
echo "Setting permissions..."
ssh "$SDF_HOST" "find ~/gopher/blog -type f -exec chmod 644 {} \; && find ~/gopher/blog -type d -exec chmod 755 {} \;"
echo ""
echo -e "${GREEN}Gopher published!${NC}"
echo "Gopher is live at: gopher://sdf.org/1/users/mnw/blog/"
echo "Web proxy: https://gopher.floodgap.com/gopher/gw?a=gopher://sdf.org/1/users/mnw/blog/"
fi
echo ""
echo -e "${GREEN}=== Published successfully! ===${NC}"
echo "Site is live at: https://mnw.sdf.org/"
echo -e "${GREEN}=== All done! ===${NC}"