minikurse:raspberry:pdf_automatisierung_mit_bash_und_cron_raspberry_pi_und_dokuwiki:start

Dies ist eine alte Version des Dokuments!


PDF-Automatisierung mit Bash & Cron – Raspberry Pi & DokuWiki

In diesem Mini-Kurs richtest du eine automatische PDF-Erzeugung für dein DokuWiki ein – ganz ohne manuelles Klicken. Das PDF wird täglich erstellt und auf deiner SD-Karte gespeichert.

sudo nano /home/pi/pdf_export.sh

Inhalt:

#!/bin/bash
# PDF-Export-Skript für DokuWiki mit dw2pdf
 
DATUM=$(date +%F)
ZIEL="/home/pi/pdf_exports/kursmaterial_${DATUM}.pdf"
PDF_URL="http://localhost/doku.php?do=export_pdfbook&id=start"
 
wget -O "$ZIEL" "$PDF_URL"

Ausführbar machen:

chmod +x /home/pi/pdf_export.sh
mkdir -p /home/pi/pdf_exports
sudo usermod -aG www-data pi
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 2775 {} \;
sudo find /var/www/html -type f -exec chmod 664 {} \;
sudo chmod g+s /var/www/html

Ergebnis: Du kannst als <code>pi</code> direkt PDF-Dateien schreiben, Skripte anlegen oder Wiki-Dateien ändern – ohne <code>sudo</code>.

sudo mkdir -p /var/www/html/lib/plugins/dw2pdf/tpl/odp

Pfad:

/var/www/html/lib/plugins/dw2pdf/tpl/odp/cover.html
<html>
  <head>
    <style>
      pre {
        font-family: monospace;
        white-space: pre-wrap;
        text-align: center;
        font-size: 14pt;
      }
    </style>
  </head>
  <body>
    <pre>
    ██████╗ ██████╗ ███████╗
    ██╔══██╗██╔══██╗██╔════╝
    ██████╔╝██████╔╝█████╗  
    ██╔═══╝ ██╔═══╝ ██╔══╝  
    ██║     ██║     ███████╗
    ╚═╝     ╚═╝     ╚══════╝
 
     PDF-Kursmaterial
    </pre>
  </body>
</html>
<div style="text-align:right; font-size:10pt;">
  Seite [[@PAGE@]]
</div>
<div style="text-align:center; font-size:8pt; color:#999;">
  © Olaf Droste Products, Immermannstr. 31, 44147 Dortmund
</div>

→ Admin → PDF Export → Template: odp

crontab -e

Einfügen:

0 0 * * * /home/pi/pdf_export.sh && /home/pi/update_pdf_links.sh
sudo nano /home/pi/update_pdf_links.sh

Inhalt:

#!/bin/bash
 
DATUM=$(date +%F)
ZIELDATEI="/var/www/html/data/pages/pdfs/start.txt"
 
cat <<EOF > "$ZIELDATEI"
====== PDF-Downloadübersicht ======
 
Hier findest du automatisch erzeugte PDFs deines Raspberry-Kurs-Wikis:
 
  * [[file:/home/pi/pdf_exports/kursmaterial_${DATUM}.pdf|📄 Kursmaterial vom ${DATUM}]]
 
→ Diese Seite wird täglich automatisch aktualisiert.
EOF
 
chown www-data:www-data "$ZIELDATEI"
chmod 664 "$ZIELDATEI"

Ausführbar machen:

chmod +x /home/pi/update_pdf_links.sh
sudo apt install php-mbstring -y
sudo systemctl restart apache2
/home/pi/pdf_export.sh && /home/pi/update_pdf_links.sh

→ Prüfe: * Liegt eine neue PDF im Ordner `/home/pi/pdf_exports/`? * Ist die Seite `pdfs:start` im Wiki automatisch aktualisiert?

Tipp: Du kannst die PDFs später auch automatisch per PHP oder FTP bereitstellen.

  • minikurse/raspberry/pdf_automatisierung_mit_bash_und_cron_raspberry_pi_und_dokuwiki/start.1750960043.txt.gz
  • Zuletzt geändert: 2025/06/26 19:47
  • von strangelove