#!/bin/bash # Simple Server Setup Script - Run this ON YOUR SERVER after git push # Usage: ./setup-server.sh set -e echo "๐ Bizoni Server Setup Script" echo "============================" # Configuration - UPDATE THESE IF NEEDED BLOG_DIR="/var/www/bizoni/blog" IMG_DIR="/var/www/bizoni/img/blog" BACKUP_DIR="/var/backups/bizoni" echo "๐ Blog directory: $BLOG_DIR" echo "๐ผ๏ธ Image directory: $IMG_DIR" echo "" # Check if directories exist if [ ! -d "$BLOG_DIR" ]; then echo "โ Blog directory not found: $BLOG_DIR" echo "Please update BLOG_DIR in this script" exit 1 fi if [ ! -d "$IMG_DIR" ]; then echo "โ Image directory not found: $IMG_DIR" echo "Please update IMG_DIR in this script" exit 1 fi echo "โ Directories found" echo "" # Create backup echo "๐ฆ Creating backup..." mkdir -p "$BACKUP_DIR" timestamp=$(date +%Y%m%d_%H%M%S) tar -czf "$BACKUP_DIR/blogs_backup_$timestamp.tar.gz" -C "$(dirname "$BLOG_DIR")" "$(basename "$BLOG_DIR")" echo "โ Backup created: $BACKUP_DIR/blogs_backup_$timestamp.tar.gz" echo "" # Count existing blogs total_blogs=$(ls "$BLOG_DIR"/*.html 2>/dev/null | wc -l) numeric_blogs=$(ls "$BLOG_DIR"/[0-9][0-9][0-9][0-9].html 2>/dev/null | wc -l) slug_blogs=$(ls "$BLOG_DIR"/[a-z]*.html 2>/dev/null | wc -l) echo "๐ Current blog status:" echo " Total blogs: $total_blogs" echo " Numeric files: $numeric_blogs" echo " Slug files: $slug_blogs" echo "" # Function to generate slug from title generate_slug() { local title="$1" echo "$title" | tr '[:upper:]' '[:lower:]' | \ sed 's/รก/a/g; s/รค/a/g; s/ฤ/c/g; s/ฤ/d/g; s/รฉ/e/g; s/ฤ/e/g; s/รญ/i/g; s/ฤพ/l/g; s/ล/n/g; s/รณ/o/g; s/รถ/o/g; s/รด/o/g; s/ล/r/g; s/ลก/s/g; s/ลฅ/t/g; s/รบ/u/g; s/ลฏ/u/g; s/รฝ/y/g; s/ลพ/z/g' | \ sed 's/ร/a/g; s/ร/a/g; s/ฤ/c/g; s/ฤ/d/g; s/ร/e/g; s/ฤ/e/g; s/ร/i/g; s/ฤฝ/l/g; s/ล/n/g; s/ร/o/g; s/ร/o/g; s/ร/o/g; s/ล/r/g; s/ล /s/g; s/ลค/t/g; s/ร/u/g; s/ลฎ/u/g; s/ร/y/g; s/ลฝ/z/g' | \ iconv -c -f utf-8 -t ascii//TRANSLIT | \ sed 's/\s\+/-/g' | \ sed 's/[^a-z0-9\-]//g' | \ sed 's/-\+/-/g' | \ sed 's/^\-\|\-$//g' } # Function to extract title from HTML extract_title() { local file="$1" grep -o '