93 lines
2.4 KiB
Bash
93 lines
2.4 KiB
Bash
#!/bin/bash
|
||
|
||
# Password Generator Installation Script
|
||
# This script sets up the password generator with i18n support
|
||
|
||
set -e
|
||
|
||
echo "🔐 Password Generator Installation"
|
||
echo "=================================="
|
||
|
||
# Check PHP version
|
||
php_version=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||
required_version="8.1"
|
||
|
||
if [ "$(printf '%s\n' "$required_version" "$php_version" | sort -V | head -n1)" != "$required_version" ]; then
|
||
echo "❌ PHP 8.1+ required (found: $php_version)"
|
||
exit 1
|
||
fi
|
||
|
||
echo "✅ PHP version: $php_version"
|
||
|
||
# Check if composer is installed
|
||
if ! command -v composer &> /dev/null; then
|
||
echo "❌ Composer not found. Please install Composer first:"
|
||
echo " https://getcomposer.org/download/"
|
||
exit 1
|
||
fi
|
||
|
||
echo "✅ Composer found"
|
||
|
||
# Install PHP dependencies
|
||
echo ""
|
||
echo "📦 Installing PHP dependencies..."
|
||
composer install --no-dev --optimize-autoloader
|
||
|
||
# Set up environment file
|
||
if [ ! -f .env ]; then
|
||
echo ""
|
||
echo "⚙️ Setting up environment configuration..."
|
||
cp .env.example .env
|
||
echo "✅ Environment file created (.env)"
|
||
echo " You can edit this file to customize settings"
|
||
else
|
||
echo "✅ Environment file already exists"
|
||
fi
|
||
|
||
# Create logs directory and set permissions
|
||
echo ""
|
||
echo "📁 Setting up directories..."
|
||
mkdir -p logs
|
||
chmod 755 logs
|
||
echo "✅ Logs directory created"
|
||
|
||
# Check if pwgen is available (optional)
|
||
if command -v pwgen &> /dev/null; then
|
||
echo "✅ pwgen found (enhanced compatibility enabled)"
|
||
else
|
||
echo "ℹ️ pwgen not found (will use PHP fallback)"
|
||
fi
|
||
|
||
# Test the installation
|
||
echo ""
|
||
echo "🧪 Testing installation..."
|
||
php -l public/index.php > /dev/null
|
||
if [ $? -eq 0 ]; then
|
||
echo "✅ PHP syntax check passed"
|
||
else
|
||
echo "❌ PHP syntax error found"
|
||
exit 1
|
||
fi
|
||
|
||
# Start the development server
|
||
echo ""
|
||
echo "🚀 Installation completed successfully!"
|
||
echo ""
|
||
echo "To start the development server:"
|
||
echo " php -S localhost:8080 -t public"
|
||
echo ""
|
||
echo "To start with composer:"
|
||
echo " composer start"
|
||
echo ""
|
||
echo "Then visit: http://localhost:8080"
|
||
echo ""
|
||
echo "📚 Features:"
|
||
echo " • REST API for password generation"
|
||
echo " • Multilingual web interface (8 languages)"
|
||
echo " • 5 different password generation algorithms"
|
||
echo " • Security analysis and entropy calculation"
|
||
echo " • Password manager integration examples"
|
||
echo ""
|
||
echo "📖 Documentation: http://localhost:8080/docs"
|
||
echo "🌍 Supported languages: EN, DE, FR, IT, ES, PT, JA, ZH"
|