diff --git a/modules/credentials-pdf.nix b/modules/credentials-pdf.nix index e8085af..1312de5 100644 --- a/modules/credentials-pdf.nix +++ b/modules/credentials-pdf.nix @@ -2,6 +2,7 @@ let fonts = pkgs.liberation_ttf; + backticks = "'\"\`\`\`\"'"; in { # ── 1. Auto-Generate Root Password (Runs once) ───────────── @@ -55,6 +56,8 @@ in FILE="/tmp/magic_keys.md" mkdir -p "$DOC_DIR" + FENCE='```' + # ── Read secrets (default to placeholder if missing) ── read_secret() { if [ -f "$1" ]; then cat "$1"; else echo "$2"; fi; } @@ -74,7 +77,7 @@ in fi if [ -n "$ZEUS_URL" ]; then - ZEUS_QR_TEXT=$(qrencode -t ANSIUTF8 "$ZEUS_URL" 2>/dev/null || true) + ZEUS_QR_TEXT=$(qrencode -t UTF8 "$ZEUS_URL" 2>/dev/null || true) fi # ── Build the Markdown document ── @@ -139,17 +142,111 @@ BITCOIN # --- ZEUS MOBILE WALLET QR CODE --- if [ -n "$ZEUS_QR_TEXT" ]; then - cat >> "$FILE" << 'ZEUSHEADER' - -## 📱 Connect Zeus Mobile Wallet - -Take your Bitcoin Lightning node anywhere in the world! Scan this QR code with the **Zeus** app on your phone to instantly connect your mobile wallet to your Lightning node. - -1. Download **Zeus** from the App Store or Google Play -2. Open Zeus and tap **"Scan Node Config"** -3. Point your phone's camera at this QR code: - -```text -ZEUSHEADER + echo "" >> "$FILE" + echo "## 📱 Connect Zeus Mobile Wallet" >> "$FILE" + echo "" >> "$FILE" + echo "Take your Bitcoin Lightning node anywhere in the world! Scan this QR code with the **Zeus** app on your phone to instantly connect your mobile wallet to your Lightning node." >> "$FILE" + echo "" >> "$FILE" + echo "1. Download **Zeus** from the App Store or Google Play" >> "$FILE" + echo "2. Open Zeus and tap **\"Scan Node Config\"**" >> "$FILE" + echo "3. Point your phone's camera at this QR code:" >> "$FILE" + echo "" >> "$FILE" + echo "$FENCE" >> "$FILE" echo "$ZEUS_QR_TEXT" >> "$FILE" - cat >> "$FILE" << 'ZEUSFOOTER' + echo "$FENCE" >> "$FILE" + echo "" >> "$FILE" + echo "That's it! You're now mobile. Send and receive Bitcoin anywhere in the world, powered by your very own node! ⚡" >> "$FILE" + elif [ -n "$ZEUS_URL" ]; then + echo "" >> "$FILE" + echo "## 📱 Connect Zeus Mobile Wallet" >> "$FILE" + echo "" >> "$FILE" + echo "Take your Bitcoin Lightning node anywhere in the world! Paste this connection URL into the **Zeus** app on your phone:" >> "$FILE" + echo "" >> "$FILE" + echo "1. Download **Zeus** from the App Store or Google Play" >> "$FILE" + echo "2. Open Zeus and tap **\"Scan Node Config\"** then **\"Paste Node Config\"**" >> "$FILE" + echo "3. Paste this URL:" >> "$FILE" + echo "" >> "$FILE" + echo "$FENCE" >> "$FILE" + echo "$ZEUS_URL" >> "$FILE" + echo "$FENCE" >> "$FILE" + echo "" >> "$FILE" + echo "That's it! You're now mobile. Send and receive Bitcoin anywhere in the world, powered by your very own node! ⚡" >> "$FILE" + fi + + # --- MATRIX / ELEMENT --- + if [ -f "/var/lib/secrets/matrix-users" ]; then + echo "" >> "$FILE" + echo "## 💬 Your Private Chat (Matrix / Element)" >> "$FILE" + echo "This is your very own private messaging app! Log in using an app like Element with these details:" >> "$FILE" + echo "$FENCE" >> "$FILE" + cat /var/lib/secrets/matrix-users >> "$FILE" + echo "$FENCE" >> "$FILE" + fi + + # --- GNOME RDP --- + if [ -f "/var/lib/gnome-remote-desktop/rdp-credentials" ]; then + echo "" >> "$FILE" + echo "## 🌎 Connect from Far Away (Remote Desktop)" >> "$FILE" + echo "This lets you control your computer screen from another device!" >> "$FILE" + echo "$FENCE" >> "$FILE" + cat /var/lib/gnome-remote-desktop/rdp-credentials >> "$FILE" + echo "$FENCE" >> "$FILE" + fi + + # --- NEXTCLOUD --- + if [ -f "/var/lib/secrets/nextcloud-admin" ]; then + echo "" >> "$FILE" + echo "## ☁️ Your Personal Cloud (Nextcloud)" >> "$FILE" + echo "This is like your own private Google Drive!" >> "$FILE" + echo "$FENCE" >> "$FILE" + cat /var/lib/secrets/nextcloud-admin >> "$FILE" + echo "$FENCE" >> "$FILE" + fi + + # --- WORDPRESS --- + if [ -f "/var/lib/secrets/wordpress-admin" ]; then + echo "" >> "$FILE" + echo "## 📝 Your Website (WordPress)" >> "$FILE" + echo "This is your very own website where you can write blogs or make pages." >> "$FILE" + echo "$FENCE" >> "$FILE" + cat /var/lib/secrets/wordpress-admin >> "$FILE" + echo "$FENCE" >> "$FILE" + fi + + # --- VAULTWARDEN --- + if [ -f "/var/lib/domains/vaultwarden" ]; then + DOMAIN=$(cat /var/lib/domains/vaultwarden) + VW_ADMIN_TOKEN="Not found" + if [ -f "/var/lib/secrets/vaultwarden/vaultwarden.env" ]; then + VW_ADMIN_TOKEN=$(grep -oP 'ADMIN_TOKEN=\K.*' /var/lib/secrets/vaultwarden/vaultwarden.env || echo "Not found") + fi + echo "" >> "$FILE" + echo "## 🔐 Your Password Manager (Vaultwarden)" >> "$FILE" + echo "This keeps all your other passwords safe! Go to this website to use it:" >> "$FILE" + echo "- **Website:** https://$DOMAIN" >> "$FILE" + echo "- **Admin Panel:** https://$DOMAIN/admin" >> "$FILE" + echo "- **Admin Token:** \`$VW_ADMIN_TOKEN\`" >> "$FILE" + echo "" >> "$FILE" + echo "*(Create your own account on the main page. Use the Admin Token to access the admin panel and manage your server.)*" >> "$FILE" + fi + + # --- BTCPAY SERVER --- + if [ -f "/var/lib/domains/btcpayserver" ]; then + DOMAIN=$(cat /var/lib/domains/btcpayserver) + echo "" >> "$FILE" + echo "## ₿ Your Bitcoin Store (BTCPay Server)" >> "$FILE" + echo "This lets you accept Bitcoin like a real shop!" >> "$FILE" + echo "- **Website:** https://$DOMAIN" >> "$FILE" + echo "*(You make up your own Admin Password the first time you visit!)*" >> "$FILE" + fi + + # ── Generate PDF ── + pandoc "$FILE" -o "$OUTPUT" --pdf-engine=typst \ + -V mainfont="Liberation Sans" \ + -V monofont="Liberation Mono" + + chown free:users "$OUTPUT" + rm -f "$FILE" + ''; + }; +}