#!/bin/bash
cd ~/firefrost-work/firefrost-operations-manual

cat > docs/wikijs-deployment.md << 'DOC'
# Wiki.js Dual Deployment - Subscribers + Staff

**Date:** February 9, 2026  
**Server:** Ghost VPS (64.50.188.14)  
**Status:** ✅ OPERATIONAL  
**Services:** 5 & 6 of 7 (Phase 0.5: 86% complete)

---

## Deployment Summary

**Duration:** ~30 minutes  
**Instances Deployed:** 2 (Subscribers + Staff)

**URLs:**
- https://subscribers.firefrostgaming.com (port 3100)
- https://staff.firefrostgaming.com (port 3101)

**Components:**
- Wiki.js 2.5.311
- PostgreSQL (2 databases)
- Node.js 22.22.0
- Nginx reverse proxy
- SSL certificates (Let's Encrypt)

---

## Installation

1. **PostgreSQL Setup**
   - Created 2 databases: wikijs_subscribers, wikijs_staff
   - Created wikijs user with proper grants
   - Fixed schema permissions (GRANT ALL ON SCHEMA public)

2. **Wiki.js Installation**
   - Downloaded to /var/www/wikijs-subscribers
   - Downloaded to /var/www/wikijs-staff
   - Configured separate ports (3100, 3101)

3. **Configuration**
   - HTTPS host URLs configured
   - PostgreSQL connections
   - Separate systemd services

4. **Nginx + SSL**
   - Reverse proxy for both domains
   - Single SSL certificate covering both
   - Expires: May 11, 2026

---

## Verification

✅ Both services running  
✅ HTTPS working (HTTP/2 200)  
✅ SSL certificate valid  
✅ Setup wizards accessible  
✅ PostgreSQL connections stable  

---

**Fire + Frost = Where Passion Meets Precision** 🔥❄️
DOC

# Update manifest
sed -i 's/Wiki.js (Sub).*Ghost VPS.*⏳ PENDING/Wiki.js (Sub)   | Ghost VPS       | 64.50.188.14 | subscribers.firefrostgaming.com | ✅ OPERATIONAL/' Firefrost_Infrastructure_Manifest.md
sed -i 's/Wiki.js (Staff).*Ghost VPS.*⏳ PENDING/Wiki.js (Staff) | Ghost VPS       | 64.50.188.14 | staff.firefrostgaming.com       | ✅ OPERATIONAL/' Firefrost_Infrastructure_Manifest.md

cp Firefrost_Infrastructure_Manifest.md project-files/Firefrost_Vanilla_Manifest.md

git add -A
git commit -m "Wiki.js dual deployment complete - subscribers + staff

Services 5 & 6 of 7 deployed on Ghost VPS.
Phase 0.5: 86% complete (6/7 services operational)"

git push

echo "Wiki.js documented and committed!"
