This commit is contained in:
2026-07-09 10:17:57 +02:00
parent d9927618f5
commit dfa7ef98ef
15 changed files with 411 additions and 36 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
"""
Generate `blog/manifest.json` from the text files present in the blog/ folder.
Run this in the project root to refresh the manifest after adding/removing blog entries.
"""
import os
import json
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
BLOGDIR = os.path.join(BASEDIR, 'blog')
def main():
exts = ('.txt', '.text')
files = [f for f in sorted(os.listdir(BLOGDIR)) if f.lower().endswith(exts)]
out = os.path.join(BLOGDIR, 'manifest.json')
with open(out, 'w', encoding='utf-8') as fh:
json.dump(files, fh, indent=2)
print(f'Wrote {len(files)} entries to {out}')
if __name__ == '__main__':
main()
+13
View File
@@ -0,0 +1,13 @@
[Unit]
Description=Sync website content from Git repository
After=network.target
[Service]
Type=oneshot
WorkingDirectory=%h/website-but-better
Environment=GIT_REPO_URL=https://git.organic-server.org/organic-CPU/website-but-better.git
Environment=GIT_BRANCH=main
Environment=DEPLOY_DIR=/var/www/html
ExecStart=/bin/bash /home/USERNAME/website-but-better/scripts/sync_site.sh
User=www-data
Group=www-data
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
REPO_URL="${GIT_REPO_URL:-https://git.organic-server.org/organic-CPU/website-but-better.git}"
BRANCH="${GIT_BRANCH:-main}"
DEPLOY_DIR="${DEPLOY_DIR:-/var/www/html}"
cd "$ROOT_DIR"
if [ ! -d .git ]; then
if [ "$(find . -maxdepth 1 -mindepth 1 | wc -l)" -eq 0 ]; then
echo "Cloning website repository from $REPO_URL into $ROOT_DIR"
git clone "$REPO_URL" .
else
echo "Error: $ROOT_DIR is not a git repository and is not empty." >&2
echo "Please clone the repository into this directory or initialize git manually." >&2
exit 1
fi
fi
echo "Syncing website from $REPO_URL ($BRANCH)"
git remote set-url origin "$REPO_URL"
git fetch origin --prune
git checkout "$BRANCH"
git pull --ff-only origin "$BRANCH"
echo "Regenerating manifests"
if command -v python3 >/dev/null 2>&1; then
python3 scripts/generate_blog_manifest.py
python3 scripts/generate_manifest.py
else
echo "Warning: python3 not found; manifest regeneration skipped." >&2
fi
if [ "$DEPLOY_DIR" != "$ROOT_DIR" ]; then
echo "Deploying website files to $DEPLOY_DIR"
mkdir -p "$DEPLOY_DIR"
rsync -a --delete \
--exclude '.git' \
--exclude 'scripts/' \
--exclude 'nginx/' \
--exclude '.gitignore' \
--exclude '*.sh' \
"$ROOT_DIR/" "$DEPLOY_DIR/"
fi
echo "Website sync complete."
+9
View File
@@ -0,0 +1,9 @@
[Unit]
Description=Run website sync every 12 hours
[Timer]
OnCalendar=*-*-* 00,12:00:00
Persistent=true
[Install]
WantedBy=timers.target