T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/backups/lavocat.quebec/backup-20250730-021618/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/backups/lavocat.quebec/backup-20250730-021618/auto-deploy.sh
#!/bin/bash

# Auto-Deployment Script for lavocat.quebec
# This script does everything: extract, install, build, deploy

set -e  # Exit on any error

echo "🚀 Auto-Deployment Script for Lavocat Quebec"
echo "============================================="

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Configuration
DOMAIN="lavocat.quebec"
DEPLOY_DIR="/home/gositeme/domains/lavocat.quebec/public_html"
BACKUP_DIR="/home/gositeme/backups/lavocat.quebec"
LOG_DIR="/home/gositeme/logs/lavocat-quebec"
USER="gositeme"

# Function to print colored output
print_status() {
    echo -e "${BLUE}[INFO]${NC} $1"
}

print_success() {
    echo -e "${GREEN}[SUCCESS]${NC} $1"
}

print_warning() {
    echo -e "${YELLOW}[WARNING]${NC} $1"
}

print_error() {
    echo -e "${RED}[ERROR]${NC} $1"
}

# Check if running as correct user
if [[ $USER != "gositeme" ]]; then
   print_error "This script should be run as gositeme user"
   exit 1
fi

# Check if Node.js is installed
if ! command -v node &> /dev/null; then
    print_error "Node.js is not installed. Please install Node.js first."
    exit 1
fi

# Check Node.js version
NODE_VERSION=$(node --version)
print_status "Node.js version: $NODE_VERSION"

# Find the deployment zip file
ZIP_FILE=$(find . -name "lavocat-quebec-deployment-*.zip" | head -1)

if [ -z "$ZIP_FILE" ]; then
    print_error "No deployment zip file found!"
    print_status "Please upload the zip file to this directory first."
    exit 1
fi

print_success "Found deployment file: $ZIP_FILE"

# Create backup of current deployment
print_status "Creating backup of current deployment..."
if [ -d "$DEPLOY_DIR" ] && [ "$(ls -A $DEPLOY_DIR)" ]; then
    BACKUP_NAME="backup-$(date +%Y%m%d-%H%M%S)"
    mkdir -p "$BACKUP_DIR"
    cp -r "$DEPLOY_DIR" "$BACKUP_DIR/$BACKUP_NAME"
    print_success "Backup created: $BACKUP_DIR/$BACKUP_NAME"
else
    print_warning "No existing deployment found, skipping backup"
fi

# Create deployment directory
print_status "Creating deployment directory..."
mkdir -p "$DEPLOY_DIR"
cd "$DEPLOY_DIR"

# Extract the zip file
print_status "Extracting deployment package..."
unzip -o "$ZIP_FILE" -d .

# Make scripts executable
print_status "Making scripts executable..."
chmod +x scripts/*.sh
chmod +x *.sh

# Install dependencies
print_status "Installing production dependencies..."
npm ci --only=production

# Generate Prisma client
print_status "Generating Prisma client..."
npx prisma generate

# Run database migrations
print_status "Running database migrations..."
npx prisma migrate deploy

# Build the application
print_status "Building the application..."
npm run build:production

# Create necessary directories
print_status "Creating necessary directories..."
mkdir -p "$BACKUP_DIR"
mkdir -p "$LOG_DIR"
mkdir -p "$DEPLOY_DIR/public/uploads"

# Stop any existing service
print_status "Stopping existing service..."
pkill -f "server-production.js" || true
sleep 2

# Start the application
print_status "Starting the application..."
./start-production.sh &

# Wait for service to start
sleep 5

# Check if service is running
if pgrep -f "server-production.js" > /dev/null; then
    print_success "Service is running successfully!"
    print_status "Process ID: $(pgrep -f 'server-production.js')"
else
    print_error "Service failed to start!"
    print_status "Check logs in: $LOG_DIR"
    exit 1
fi

# Test the application
print_status "Testing application..."
sleep 3

# Check if the application is responding
if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 | grep -q "200\|302"; then
    print_success "Application is responding correctly!"
else
    print_warning "Application might not be fully ready yet. Check logs."
fi

print_success "🎉 Auto-deployment completed successfully!"
print_status "Your application is now running at: https://lavocat.quebec"
print_status ""
print_status "📋 Management commands:"
print_status "  Start: ./start-production.sh"
print_status "  Stop: ./stop-production.sh"
print_status "  Restart: ./restart-production.sh"
print_status "  View logs: tail -f $LOG_DIR/combined.log"
print_status "  Backup DB: npm run backup:database"
print_status ""
print_status "📁 Directories:"
print_status "  Application: $DEPLOY_DIR"
print_status "  Logs: $LOG_DIR"
print_status "  Backups: $BACKUP_DIR"
print_status ""
print_status "🔍 To check if everything is working:"
print_status "  curl -I https://lavocat.quebec"
print_status "  tail -f $LOG_DIR/combined.log" 

CasperSecurity Mini