Compare commits
No commits in common. "homeserver-vps" and "vps-only" have entirely different histories.
homeserver
...
vps-only
|
|
@ -27,8 +27,11 @@ 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
|
||||||
|
|
||||||
echo "5. ☁️ Uploading map via SFTP..."
|
# 5. ☁️ (DISABLED) Uploading map via SFTP — no longer needed
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -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_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:
|
||||||
|
|
@ -35,9 +39,11 @@ 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)
|
||||||
|
|
@ -45,6 +51,7 @@ 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):
|
||||||
|
|
@ -52,6 +59,17 @@ 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()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ssh -i /home/arul/.ssh/id_rsa root@74.208.74.61 <<EOF
|
# Test Nginx configuration
|
||||||
if sudo /usr/local/nginx/sbin/nginx -t; then
|
sudo nginx -t
|
||||||
echo "✅ Nginx config test passed, reloading..."
|
if [ $? -eq 0 ]; then
|
||||||
if sudo /usr/local/nginx/sbin/nginx -s reload; then
|
echo "✅ Nginx config test passed, reloading..."
|
||||||
echo "🚀 Nginx reloaded successfully!"
|
sudo systemctl reload nginx
|
||||||
else
|
if [ $? -eq 0 ]; then
|
||||||
echo "❌ Nginx reload failed!"
|
echo "🚀 Nginx reloaded successfully!"
|
||||||
fi
|
else
|
||||||
|
echo "❌ Nginx reload failed!"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "❌ Nginx config test failed!"
|
echo "❌ Nginx config test failed!"
|
||||||
fi
|
fi
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user