← back to Watches
deploy-luxury.sh
283 lines
#!/bin/bash
###############################################################################
# OMEGA WATCHES - LUXURY EDITION DEPLOYMENT SCRIPT
# Automated deployment with safety checks and rollback capability
###############################################################################
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
GOLD='\033[38;5;220m'
NC='\033[0m' # No Color
# Configuration
PROJECT_DIR="/root/Projects/watches"
BACKUP_DIR="/root/backups"
SERVER_PORT="7600"
PM2_NAME="omega-watches"
###############################################################################
# Functions
###############################################################################
print_header() {
echo -e "${GOLD}"
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ OMEGA WATCHES - LUXURY EDITION DEPLOYMENT ║"
echo "║ Ultra-Premium Experience ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
}
print_step() {
echo -e "${BLUE}▶ $1${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠ $1${NC}"
}
print_error() {
echo -e "${RED}✗ $1${NC}"
}
check_prerequisites() {
print_step "Checking prerequisites..."
# Check Node.js
if ! command -v node &> /dev/null; then
print_error "Node.js not found. Please install Node.js first."
exit 1
fi
print_success "Node.js: $(node --version)"
# Check npm
if ! command -v npm &> /dev/null; then
print_error "npm not found. Please install npm first."
exit 1
fi
print_success "npm: $(npm --version)"
# Check PM2
if ! command -v pm2 &> /dev/null; then
print_warning "PM2 not found. Installing PM2..."
npm install -g pm2
fi
print_success "PM2: $(pm2 --version)"
# Check project directory
if [ ! -d "$PROJECT_DIR" ]; then
print_error "Project directory not found: $PROJECT_DIR"
exit 1
fi
print_success "Project directory exists"
}
create_backup() {
print_step "Creating backup..."
mkdir -p "$BACKUP_DIR"
BACKUP_FILE="$BACKUP_DIR/watches-luxury-$(date +%Y%m%d-%H%M%S).tar.gz"
tar -czf "$BACKUP_FILE" -C /root/Projects watches 2>/dev/null || true
if [ -f "$BACKUP_FILE" ]; then
print_success "Backup created: $BACKUP_FILE"
else
print_warning "Backup creation skipped or failed (continuing anyway)"
fi
}
install_dependencies() {
print_step "Installing dependencies..."
cd "$PROJECT_DIR"
if [ ! -d "node_modules" ]; then
npm install
print_success "Dependencies installed"
else
print_success "Dependencies already installed"
fi
}
build_application() {
print_step "Building luxury application..."
cd "$PROJECT_DIR"
# Clear previous build
rm -rf dist
# Build with vite
npm run build
if [ -d "dist" ]; then
print_success "Build completed successfully"
# Show build size
DIST_SIZE=$(du -sh dist | cut -f1)
print_success "Build size: $DIST_SIZE"
else
print_error "Build failed - dist directory not found"
exit 1
fi
}
check_luxury_mode() {
print_step "Verifying luxury mode configuration..."
if grep -q "enabled: true" "$PROJECT_DIR/src/config/luxury.config.js"; then
print_success "Luxury mode is ENABLED"
else
print_warning "Luxury mode is DISABLED"
read -p "Enable luxury mode? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sed -i 's/enabled: false/enabled: true/g' "$PROJECT_DIR/src/config/luxury.config.js"
print_success "Luxury mode enabled"
fi
fi
}
restart_server() {
print_step "Restarting server..."
# Check if PM2 process exists
if pm2 describe "$PM2_NAME" &> /dev/null; then
pm2 restart "$PM2_NAME"
print_success "Server restarted"
else
print_warning "PM2 process not found. Starting new process..."
cd "$PROJECT_DIR"
pm2 start server.js --name "$PM2_NAME"
print_success "Server started"
fi
# Save PM2 configuration
pm2 save
}
verify_deployment() {
print_step "Verifying deployment..."
# Wait for server to start
sleep 3
# Check if port is open
if lsof -Pi :$SERVER_PORT -sTCP:LISTEN -t >/dev/null ; then
print_success "Server is listening on port $SERVER_PORT"
else
print_error "Server is not listening on port $SERVER_PORT"
exit 1
fi
# Check HTTP response
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$SERVER_PORT/ || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
print_success "HTTP response: $HTTP_CODE (OK)"
else
print_warning "HTTP response: $HTTP_CODE"
fi
# Check PM2 status
if pm2 describe "$PM2_NAME" | grep -q "online"; then
print_success "PM2 status: online"
else
print_error "PM2 status: not online"
pm2 logs "$PM2_NAME" --lines 20
exit 1
fi
}
show_deployment_info() {
echo ""
echo -e "${GOLD}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GOLD}║ DEPLOYMENT COMPLETED SUCCESSFULLY ║${NC}"
echo -e "${GOLD}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${GREEN}🌐 Application URL:${NC}"
echo -e " http://45.61.58.125:$SERVER_PORT"
echo ""
echo -e "${GREEN}📊 PM2 Commands:${NC}"
echo -e " pm2 logs $PM2_NAME - View logs"
echo -e " pm2 monit - Monitor resources"
echo -e " pm2 restart $PM2_NAME - Restart server"
echo ""
echo -e "${GREEN}🎨 Luxury Features:${NC}"
echo -e " ✓ Cinematic hero with particles"
echo -e " ✓ 3D card effects with parallax"
echo -e " ✓ Gesture-based navigation"
echo -e " ✓ Premium animations & effects"
echo -e " ✓ Gold accent design system"
echo ""
echo -e "${GREEN}📁 Files Created:${NC}"
echo -e " • src/components/LuxuryHero.jsx"
echo -e " • src/components/LuxuryWatchCard.jsx"
echo -e " • src/components/ParallaxSection.jsx"
echo -e " • src/components/GestureControls.jsx"
echo -e " • src/components/PremiumLoader.jsx"
echo -e " • src/App.luxury.jsx"
echo -e " • src/config/luxury.config.js"
echo ""
echo -e "${YELLOW}💡 Toggle Luxury Mode:${NC}"
echo -e " Edit: src/config/luxury.config.js"
echo -e " Set: enabled: true/false"
echo ""
}
show_rollback_info() {
echo -e "${YELLOW}⚠ ROLLBACK INSTRUCTIONS:${NC}"
echo ""
echo "If something goes wrong, restore from backup:"
echo ""
echo " pm2 stop $PM2_NAME"
echo " cd /root/Projects"
echo " rm -rf watches"
echo " tar -xzf $BACKUP_DIR/watches-luxury-*.tar.gz"
echo " cd watches"
echo " npm install"
echo " npm run build"
echo " pm2 restart $PM2_NAME"
echo ""
}
###############################################################################
# Main Execution
###############################################################################
main() {
print_header
echo -e "${BLUE}Starting luxury edition deployment...${NC}"
echo ""
check_prerequisites
create_backup
check_luxury_mode
install_dependencies
build_application
restart_server
verify_deployment
show_deployment_info
show_rollback_info
echo -e "${GOLD}✨ Luxury deployment complete! ✨${NC}"
echo ""
}
# Run main function
main "$@"