#!/bin/bash
# Fix Git repository ownership

# Add safe directory
git config --global --add safe.directory /var/www/mkdocs/site

# Fix ownership
chown -R root:root /var/www/mkdocs/site

# Now update the footer and push
cd /var/www/mkdocs/site/docs
sed -i "s/\$(date)/$(date '+%B %d, %Y')/" index.md

# Rebuild
cd /var/www/mkdocs/site
source /var/www/mkdocs/venv/bin/activate
mkdocs build

# Commit and push
git add docs/index.md
git commit -m "Fix footer date: $(date '+%B %d, %Y')"
git push origin main

echo "Git ownership fixed, footer updated, pushed to Git"
