Files

HydroLord Website Automation Scripts

This directory contains automation scripts for the HydroLord Hugo website.

Scripts

generate_blog_post.py

Generates a new blog post using Ollama's AI model and adds it to the Hugo blog.

Configuration:

  • Ollama Endpoint: http://10.30.20.110:11434
  • Model: drjones-posts-to-much
  • Output Directory: /root/hydro-sterile/content/blog/
  • Schedule: Runs automatically every 3 days via systemd timer
  • Randomization: Each run uses a randomly varied prompt to ensure unique content

Features:

  • Automatically finds the next available post number
  • Generates title and summary from content
  • Creates proper Hugo frontmatter
  • Fails quietly if Ollama endpoint is unavailable (will retry in 3 days)

Usage:

python3 generate_blog_post.py

Error Handling: If the Ollama endpoint is down, the script exits gracefully with code 0 (no error) to prevent systemd from logging failures. It will automatically retry in 3 days when the timer runs again.

start_hugo_server.sh

Starts the Hugo development server for the website.

Configuration:

  • Port: 1313 (configurable via HUGO_PORT env var)
  • Bind Address: 0.0.0.0 (all interfaces, configurable via HUGO_BIND env var)
  • Base URL: Read from hugo.yaml

Usage:

./start_hugo_server.sh

Systemd Services

Hugo Website Service

Service: hugo-hydrolord.service

Starts the Hugo server at boot and keeps it running.

Commands:

# Enable service to start at boot
sudo systemctl enable hugo-hydrolord.service

# Start service now
sudo systemctl start hugo-hydrolord.service

# Check status
sudo systemctl status hugo-hydrolord.service

# View logs
sudo journalctl -u hugo-hydrolord.service -f

Blog Post Generator

Service: hugo-blog-generator.service
Timer: hugo-blog-generator.timer

Automatically generates blog posts every 3 days.

Commands:

# Enable timer
sudo systemctl enable hugo-blog-generator.timer

# Start timer
sudo systemctl start hugo-blog-generator.timer

# Check timer status
sudo systemctl status hugo-blog-generator.timer

# List all timers
systemctl list-timers hugo-blog-generator.timer

# Run generator manually (for testing)
sudo systemctl start hugo-blog-generator.service

# View logs
sudo journalctl -u hugo-blog-generator.service -f

Installation

  1. Install Python dependencies:

    pip3 install ollama
    
  2. Make scripts executable:

    chmod +x /root/hydro-sterile/scripts/*.py
    chmod +x /root/hydro-sterile/scripts/*.sh
    
  3. Enable and start Hugo service:

    sudo systemctl daemon-reload
    sudo systemctl enable hugo-hydrolord.service
    sudo systemctl start hugo-hydrolord.service
    
  4. Enable and start blog generator timer:

    sudo systemctl enable hugo-blog-generator.timer
    sudo systemctl start hugo-blog-generator.timer
    
  5. Verify everything is running:

    sudo systemctl status hugo-hydrolord.service
    sudo systemctl status hugo-blog-generator.timer
    

Troubleshooting

Hugo Server Not Starting

  • Check if port 1313 is already in use: sudo lsof -i :1313
  • Check logs: sudo journalctl -u hugo-hydrolord.service -n 50
  • Verify Hugo is installed: which hugo or check node_modules/.bin/hugo

Blog Generator Not Running

  • Check if Ollama endpoint is accessible: curl http://10.30.20.110:11434/api/tags
  • Check timer status: systemctl list-timers hugo-blog-generator.timer
  • View logs: sudo journalctl -u hugo-blog-generator.service -n 50
  • Test script manually: python3 /root/hydro-sterile/scripts/generate_blog_post.py

Ollama Endpoint Down

The script is designed to fail quietly if Ollama is unavailable. It will exit with code 0 (success) and retry automatically in 3 days. No action needed.

Configuration Changes

To change the Ollama endpoint or model, edit /root/hydro-sterile/scripts/generate_blog_post.py and modify the constants at the top:

OLLAMA_HOST = "http://10.30.20.110:11434"
MODEL = "drjones-posts-to-much"

Note: The script now includes random prompt variations to ensure each blog post is unique. The model generates titles with credentials, which the script automatically extracts and separates from the article content.

After making changes, restart the timer:

sudo systemctl restart hugo-blog-generator.timer

Files Location

  • Scripts: /root/hydro-sterile/scripts/
  • Systemd Services: /etc/systemd/system/hugo-*.service
  • Systemd Timers: /etc/systemd/system/hugo-*.timer
  • Blog Posts: /root/hydro-sterile/content/blog/
  • Logs: journalctl -u hugo-hydrolord.service or journalctl -u hugo-blog-generator.service