#!/bin/bash
# FefeBot: Minimalistischer KI-Fefe-Blog mit Leserbrief-Input
# proudly made without PHP, Java, JavaScript, Perl, MySQL, Postgres, MongoDB or Node.js
# Struktur:
# - /srv/fefebot/queue (Eingehende Leserbriefe)
# - /srv/fefebot/processed (Verarbeitete Leserbriefe)
# - /srv/fefebot/output (Generierte Texte)
# - /srv/fefebot/www (Output fuer Web)
# - /srv/fefebot/cgi-bin (CGI Skripte)
# Deployment Setup
mkdir -p /srv/fefebot/{queue,processed,output,www,cgi-bin}
# 1. CGI-Formular (puristisches HTML, kein JS)
cat <<EOF > /srv/fefebot/www/index.html
<!DOCTYPE html>
<html><head><title>FefeBot</title></head><body>
<h1>FefeBot: Pfreng-Automat</h1>
<form method="POST" action="/cgi-bin/submit.sh">
<label>Thema:</label><br>
<input type="text" name="subject"><br><br>
<label>Leserbrief / Link / Kommentar:</label><br>
<textarea name="body" rows="10" cols="60"></textarea><br><br>
<input type="submit" value="Absenden">
</form>
</body></html>
EOF
# 2. CGI-Skript zum Empfangen der Leserbriefe
cat <<'EOF' > /srv/fefebot/cgi-bin/submit.sh
#!/bin/sh
echo "Content-type: text/plain"
echo ""
IFS='&'
read QUERY_STRING
echo "$QUERY_STRING" | sed 's/+/ /g; s/%0D//g; s/%0A/\n/g; s/%3A/:/g; s/%3D/=/g; s/%2F/\//g' \
| awk -F= '{ print $2 }' \
> /srv/fefebot/queue/entry.$(date +%s).txt
echo "Danke. Wird verarbeitet."
EOF
chmod +x /srv/fefebot/cgi-bin/submit.sh
# 3. Generator-Skript (verwendet OpenAI API via curl)
cat <<'EOF' > /srv/fefebot/generate.sh
#!/bin/bash
QUEUE_DIR="/srv/fefebot/queue"
PROCESSED_DIR="/srv/fefebot/processed"
OUTPUT_DIR="/srv/fefebot/output"
API_KEY="DEIN_OPENAI_API_KEY_HIER"
for FILE in "$QUEUE_DIR"/*.txt; do
[ -f "$FILE" ] || continue
CONTENT=$(cat "$FILE")
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "Du bist Fefe. Du schreibst kurze, ironische, wütende Kommentare zu Nachrichten oder Leserbriefen. Stil: direkt, polemisch, technikkritisch, sarkastisch."},
{"role": "user", "content": "'"$(echo "$CONTENT" | sed 's/"/\\"/g')"'"}
],
"temperature": 0.8
}' | jq -r '.choices[0].message.content')
OUTFILE="$OUTPUT_DIR/$(basename "$FILE")"
echo "$RESPONSE" > "$OUTFILE"
mv "$FILE" "$PROCESSED_DIR/"
done
EOF
chmod +x /srv/fefebot/generate.sh
# 4. Minimaler Gatling-Ersatz: Output als Blog kopieren
cat <<'EOF' > /srv/fefebot/deploy.sh
#!/bin/bash
OUTPUT_DIR="/srv/fefebot/output"
WWW_DIR="/srv/fefebot/www"
for FILE in "$OUTPUT_DIR"/*.txt; do
TITLE=$(head -n 1 "$FILE")
BODY=$(tail -n +2 "$FILE")
BASENAME=$(basename "$FILE" .txt)
POSTFILE="$WWW_DIR/$BASENAME.html"
echo "<html><body><pre>" > "$POSTFILE"
echo "$TITLE" >> "$POSTFILE"
echo "" >> "$POSTFILE"
echo "$BODY" >> "$POSTFILE"
echo "</pre></body></html>" >> "$POSTFILE"
done
EOF
chmod +x /srv/fefebot/deploy.sh
# Fertig – Jetzt nur noch per cron o.ä. regelmäßig:
# /srv/fefebot/generate.sh && /srv/fefebot/deploy.sh
Perfekt – hier kommt dein vollständiges, manuell installierbares KI-Fefeblog-Paket, ganz im Stil von Fefe: keine Datenbank, kein JavaScript, kein unnötiger Kram – nur Shell, HTML und ein bisschen Sed.
📁 Verzeichnisstruktur
Lege dir ein Verzeichnis wie /var/blogbot/ an mit folgender Struktur:
/var/blogbot/
├── cgi-bin/
│ └── submit.sh # CGI-Skript
├── queue/ # eingehende Leserbriefe
├── processed/ # abgearbeitete Leserbriefe
├── output/ # generierter Blog (HTML-Dateien)
├── scripts/
│ ├── generate.sh # generiert den Blog
│ └── deploy.sh # (optional) kopiert HTML ins Webverzeichnis
└── index.html # HTML-Formularseite
🖋️ Datei: cgi-bin/submit.sh
#!/bin/sh
echo "Content-type: text/html"
echo ""
cat <<EOF
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>Danke!</title>
<style>
body { background: #fff; color: #000; font-family: Helvetica, sans-serif; font-size: 12pt; max-width: 800px; margin: 2em auto; }
</style>
</head><body><h1>Danke für den Leserbrief.</h1><p>Wird verarbeitet!</p>
EOF
IFS='&'
read QUERY_STRING
mkdir -p ../queue
echo "$QUERY_STRING" | sed 's/+/ /g; s/%0D//g; s/%0A/\\n/g; s/%3A/:/g' > ../queue/entry.$(date +%s)
cat <<EOF
</body></html>
EOF
✅ Mach sie ausführbar: chmod +x /var/blogbot/cgi-bin/submit.sh
🖋️ Datei: index.html
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>Fefebot</title>
<style>
body { background: #fff; color: #000; font-family: Helvetica, sans-serif; font-size: 12pt; max-width: 800px; margin: 2em auto; }
input, textarea { font-family: monospace; font-size: 12pt; width: 100%; box-sizing: border-box; margin-bottom: 1em; }
</style>
</head>
<body>
<h1>Fefebot – Pfreng-Maschine</h1>
<form method="POST" action="/cgi-bin/submit.sh">
<label>Thema:</label><br><input type="text" name="subject"><br>
<label>Inhalt:</label><br><textarea name="body" rows="10"></textarea><br>
<input type="submit" value="Absenden">
</form>
</body>
</html>
🧠 Datei: scripts/generate.sh
[code]
#!/bin/bash
QUEUE="../queue"
PROCESSED="../processed"
OUT="../output/blog.html"
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Fefebot</title></head><body>' > "$OUT"
for f in "$QUEUE"/*; do
[ -f "$f" ] || continue
echo "<hr><pre>" >> "$OUT"
cat "$f" | sed 's/\\+/ /g; s/%0D//g; s/%0A/\\n/g' >> "$OUT"
echo "</pre>" >> "$OUT"
mv "$f" "$PROCESSED/"
done
echo '</body></html>' >> "$OUT"
✅ Mach sie ausführbar: chmod +x /var/blogbot/scripts/generate.sh
🚚 Datei: scripts/deploy.sh (optional)
#!/bin/bash
cp ../output/blog.html /var/www/html/fefeblog.html
✅ Mach sie ausführbar: chmod +x /var/blogbot/scripts/deploy.sh
⏲️ Cronjob (Beispiel)
*/5 * * * * /var/blogbot/scripts/generate.sh && /var/blogbot/scripts/deploy.sh
Eintragen mit: crontab -e
🧠 Optional: GPT-Autor ergänzen
Wenn du aus Leserbriefen automatisch "fefeske" Posts machen willst, kann ich dir auch noch ein Bash-Wrapper-Tool mit openai-CLI bauen, das Inhalte an GPT-4 schickt und im Stil von Fefe verarbeitet. Sag einfach Bescheid.
Bereit zum Pfrengen. 💥