Compare commits

...

No commits in common. "homeserver-vps" and "vps-only" have entirely different histories.

3 changed files with 35 additions and 14 deletions

View File

@ -27,8 +27,11 @@ run_deployment_chain() {
echo "4. 🗺️ Generating redirect map..."
python3 redirect-site-upload-map/generate-nginx-map.py
echo "5. ☁️ Uploading map via SFTP..."
bash redirect-site-upload-map/upload-map.sftp.sh
# 5. ☁️ (DISABLED) Uploading map via SFTP — no longer needed
# bash redirect-site-upload-map/upload-map.sftp.sh
echo "5. 🗺️ Skipping SFTP upload — map is now written directly on the VPS"
echo "6. 🔄 Restarting Hugo Professional site to update latest contents on Local Home Server 🏠📰"
cd /var/www/html/professional-site/ && sudo hugo

View File

@ -6,6 +6,10 @@ CONTENT_DIR = "/var/www/html/arulbalaji.xyz/content/journal"
OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "redirect-slugs")
OUTPUT_FILE = os.path.join(OUTPUT_DIR, "tech-blogs.map")
# NEW: Path to live NGINX map file on the same VPS
LIVE_NGINX_MAP = "/root/redirect-slugs/tech-blogs.map"
def extract_tags_and_slug(filepath):
print(f"Processing file: {filepath}")
with open(filepath, "r", encoding="utf-8") as f:
@ -35,9 +39,11 @@ def extract_tags_and_slug(filepath):
print(f"Error parsing {filepath}: {e}")
return None
def generate_map():
os.makedirs(OUTPUT_DIR, exist_ok=True)
entries = []
for filename in os.listdir(CONTENT_DIR):
if filename.endswith(".md"):
path = os.path.join(CONTENT_DIR, filename)
@ -45,6 +51,7 @@ def generate_map():
if result:
entries.append(f"{result} 1;")
# Write file into project folder (for logs/backups)
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
f.write("# Auto-generated by Python\n")
for entry in sorted(entries):
@ -52,6 +59,17 @@ def generate_map():
print(f"✅ Generated NGINX map at {OUTPUT_FILE} with {len(entries)} entries.")
# ALSO write directly to live NGINX directory
try:
os.makedirs(os.path.dirname(LIVE_NGINX_MAP), exist_ok=True)
with open(LIVE_NGINX_MAP, "w", encoding="utf-8") as f:
f.write("# Auto-generated by Python\n")
for entry in sorted(entries):
f.write(entry + "\n")
print(f"🚀 Updated live NGINX map at {LIVE_NGINX_MAP}")
except Exception as e:
print(f"❌ Failed to update live NGINX map: {e}")
if __name__ == "__main__":
generate_map()

View File

@ -1,15 +1,15 @@
#!/bin/bash
ssh -i /home/arul/.ssh/id_rsa root@74.208.74.61 <<EOF
if sudo /usr/local/nginx/sbin/nginx -t; then
echo "✅ Nginx config test passed, reloading..."
if sudo /usr/local/nginx/sbin/nginx -s reload; then
echo "🚀 Nginx reloaded successfully!"
else
echo "❌ Nginx reload failed!"
fi
# Test Nginx configuration
sudo nginx -t
if [ $? -eq 0 ]; then
echo "✅ Nginx config test passed, reloading..."
sudo systemctl reload nginx
if [ $? -eq 0 ]; then
echo "🚀 Nginx reloaded successfully!"
else
echo "❌ Nginx reload failed!"
fi
else
echo "❌ Nginx config test failed!"
echo "❌ Nginx config test failed!"
fi
EOF