Initial V2 commit 3

This commit is contained in:
Hamza-Ayed
2026-04-22 22:45:47 +03:00
parent 9cd7c7a4df
commit 3269a836a2
3 changed files with 92 additions and 40 deletions

View File

@@ -1,63 +1,67 @@
#!/bin/bash
###############################################
# Intaleq V2 — Server Setup Script
# Run this ONCE on the server after uploading
# Intaleq V2 — Server Setup Script (CloudPanel Optimized)
###############################################
set -e
echo "=== Intaleq V2 Setup ==="
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# 1. Install dependencies
echo "[1/6] Installing Composer dependencies..."
echo -e "${GREEN}=== Intaleq V2 Setup ===${NC}"
# 1. Detect User
CURRENT_USER=$(whoami)
echo -e "Detected user: ${YELLOW}$CURRENT_USER${NC}"
# 2. Install dependencies
echo -e "[1/6] ${GREEN}Installing Composer dependencies...${NC}"
composer install --no-dev --optimize-autoloader
# 2. Copy environment file
# 3. Copy environment file
if [ ! -f .env ]; then
echo "[2/6] Creating .env from template..."
echo -e "[2/6] ${YELLOW}Creating .env from template...${NC}"
cp .env.example .env
echo "⚠️ IMPORTANT: Edit .env with your actual credentials!"
echo -e "${RED}⚠️ IMPORTANT: Edit .env with your actual credentials!${NC}"
else
echo "[2/6] .env already exists, skipping..."
echo -e "[2/6] .env already exists, skipping..."
fi
# 3. Generate app key
echo "[3/6] Generating application key..."
# 4. Generate app key
echo -e "[3/6] ${GREEN}Generating application key...${NC}"
php artisan key:generate
# 4. Cache config for performance
echo "[4/6] Caching configuration..."
# 5. Cache config for performance
echo -e "[4/6] ${GREEN}Caching configuration...${NC}"
php artisan config:cache
php artisan route:cache
php artisan view:cache
# 5. Set permissions
echo "[5/6] Setting permissions..."
# 6. Set permissions
echo -e "[5/6] ${GREEN}Setting permissions...${NC}"
# For CloudPanel, the web user is usually the SSH user
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
# 6. Run migrations (add indexes and api columns)
echo "[6/6] Running database migrations..."
echo "⚠️ This will add api_key/api_secret columns and missing indexes."
echo "⚠️ It will NOT delete or modify existing data."
read -p "Continue? (y/n): " confirm
if [ "$confirm" = "y" ]; then
php artisan migrate
echo "✅ Migrations complete!"
# Attempt to set ownership if running as root or sudo
if [ "$EUID" -eq 0 ]; then
chown -R www-data:www-data storage bootstrap/cache
else
echo "⏭️ Migrations skipped. Run 'php artisan migrate' manually."
echo -e "${YELLOW}Skipping chown as non-root user. Ensure storage is writable.${NC}"
fi
# 7. Run migrations
echo -e "[6/6] ${GREEN}Running database migrations...${NC}"
# Use --force for production
php artisan migrate --force
echo ""
echo "=== Setup Complete ==="
echo -e "${GREEN}=== Setup Complete ===${NC}"
echo ""
echo "Next steps:"
echo "1. Edit .env with real DB credentials, JWT secret, etc."
echo "2. Configure Nginx to point to public/ directory"
echo "3. Run: php artisan config:cache"
echo "Next steps for CloudPanel:"
echo "1. In CloudPanel, set the 'Root Directory' to: ${YELLOW}/public${NC}"
echo "2. Update the VHost Nginx configuration (see nginx-vhost.conf)"
echo "3. Ensure PHP version is 8.2 or 8.3"
echo "4. Test: curl https://your-domain/v2/auth/passenger/login"
echo ""
echo "Nginx config example:"
echo " location /v2 {"
echo " try_files \$uri \$uri/ /index.php?\$query_string;"
echo " }"