Compare commits

...

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

3 changed files with 14 additions and 35 deletions

View File

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

View File

@ -6,10 +6,6 @@ CONTENT_DIR = "/var/www/html/arulbalaji.xyz/content/journal"
OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "redirect-slugs") OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "redirect-slugs")
OUTPUT_FILE = os.path.join(OUTPUT_DIR, "tech-blogs.map") 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): def extract_tags_and_slug(filepath):
print(f"Processing file: {filepath}") print(f"Processing file: {filepath}")
with open(filepath, "r", encoding="utf-8") as f: with open(filepath, "r", encoding="utf-8") as f:
@ -39,11 +35,9 @@ def extract_tags_and_slug(filepath):
print(f"Error parsing {filepath}: {e}") print(f"Error parsing {filepath}: {e}")
return None return None
def generate_map(): def generate_map():
os.makedirs(OUTPUT_DIR, exist_ok=True) os.makedirs(OUTPUT_DIR, exist_ok=True)
entries = [] entries = []
for filename in os.listdir(CONTENT_DIR): for filename in os.listdir(CONTENT_DIR):
if filename.endswith(".md"): if filename.endswith(".md"):
path = os.path.join(CONTENT_DIR, filename) path = os.path.join(CONTENT_DIR, filename)
@ -51,7 +45,6 @@ def generate_map():
if result: if result:
entries.append(f"{result} 1;") entries.append(f"{result} 1;")
# Write file into project folder (for logs/backups)
with open(OUTPUT_FILE, "w", encoding="utf-8") as f: with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
f.write("# Auto-generated by Python\n") f.write("# Auto-generated by Python\n")
for entry in sorted(entries): for entry in sorted(entries):
@ -59,17 +52,6 @@ def generate_map():
print(f"✅ Generated NGINX map at {OUTPUT_FILE} with {len(entries)} entries.") 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__": if __name__ == "__main__":
generate_map() generate_map()

View File

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