🚀 Add quick-setup.sh script with better input handling
- Create simplified setup script with immediate feedback - Fix input handling with proper terminal redirection (</dev/tty) - Add progress indicators and clear step-by-step process - Streamlined configuration with sensible defaults - Better error handling and user experience
This commit is contained in:
parent
ae371e2415
commit
ce5cc4c098
2 changed files with 177 additions and 11 deletions
165
docker/quick-setup.sh
Executable file
165
docker/quick-setup.sh
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Ideas Generator 2025 - Quick Setup Script
|
||||
# Simplified version with better feedback
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m'
|
||||
|
||||
print_step() {
|
||||
echo ""
|
||||
echo -e "${CYAN}━━━ $1 ━━━${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
ask_with_default() {
|
||||
local question="$1"
|
||||
local default="$2"
|
||||
local is_secret="$3"
|
||||
|
||||
if [ "$is_secret" = "secret" ]; then
|
||||
echo -e "${BLUE}$question${NC}"
|
||||
echo -e "Default: ${YELLOW}[hidden]${NC}"
|
||||
printf "Enter value (or press Enter for default): "
|
||||
read -s response
|
||||
echo ""
|
||||
else
|
||||
echo -e "${BLUE}$question${NC}"
|
||||
if [ -n "$default" ]; then
|
||||
echo -e "Default: ${YELLOW}$default${NC}"
|
||||
fi
|
||||
printf "Enter value (or press Enter for default): "
|
||||
read response
|
||||
fi
|
||||
|
||||
if [ -z "$response" ] && [ -n "$default" ]; then
|
||||
response="$default"
|
||||
fi
|
||||
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
generate_password() {
|
||||
openssl rand -base64 32 2>/dev/null || date +%s | sha256sum | base64 | head -c 32
|
||||
}
|
||||
|
||||
generate_jwt() {
|
||||
openssl rand -base64 64 2>/dev/null || date +%s | sha256sum | base64 | head -c 64
|
||||
}
|
||||
|
||||
# Determine Docker Compose command
|
||||
if command -v docker-compose &> /dev/null; then
|
||||
COMPOSE="docker-compose"
|
||||
else
|
||||
COMPOSE="docker compose"
|
||||
fi
|
||||
|
||||
clear
|
||||
echo -e "${GREEN}🚀 Ideas Generator 2025 - Quick Docker Setup${NC}"
|
||||
echo ""
|
||||
echo "This will set up your deployment with sensible defaults."
|
||||
echo "You can customize later by editing the .env file."
|
||||
echo ""
|
||||
read -p "Press Enter to continue or Ctrl+C to exit..."
|
||||
|
||||
# Basic Configuration
|
||||
print_step "🌐 Basic Configuration"
|
||||
|
||||
DOMAIN=$(ask_with_default "Domain name for deployment?" "localhost")
|
||||
HTTP_PORT=$(ask_with_default "HTTP port?" "80")
|
||||
|
||||
# Database Configuration
|
||||
print_step "🗄️ Database Configuration"
|
||||
|
||||
DB_NAME=$(ask_with_default "Database name?" "ideas_gen_prod")
|
||||
DB_USER=$(ask_with_default "Database user?" "ideas_admin")
|
||||
DB_PASSWORD=$(ask_with_default "Database password?" "$(generate_password)" "secret")
|
||||
|
||||
# Security Configuration
|
||||
print_step "🔐 Security Configuration"
|
||||
|
||||
JWT_SECRET=$(ask_with_default "JWT Secret?" "$(generate_jwt)" "secret")
|
||||
|
||||
# OpenAI Configuration
|
||||
print_step "🤖 OpenAI Configuration"
|
||||
|
||||
while [ -z "$OPENAI_API_KEY" ]; do
|
||||
OPENAI_API_KEY=$(ask_with_default "OpenAI API Key (required)?" "" "secret")
|
||||
if [ -z "$OPENAI_API_KEY" ]; then
|
||||
echo -e "${RED}OpenAI API Key is required!${NC}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Azure AD Configuration
|
||||
print_step "🏢 Azure AD Configuration"
|
||||
|
||||
AZURE_TENANT=$(ask_with_default "Azure Tenant ID?" "e519c2e6-bc6d-4fdf-8d9c-923c2f002385")
|
||||
AZURE_CLIENT=$(ask_with_default "Azure Client ID?" "9079054c-9620-4757-a256-23413042f1ef")
|
||||
|
||||
# Generate configuration
|
||||
print_step "📝 Generating Configuration"
|
||||
|
||||
echo "Creating .env file..."
|
||||
|
||||
cat > .env << EOF
|
||||
# Ideas Generator 2025 - Configuration
|
||||
# Generated: $(date)
|
||||
|
||||
DOMAIN_NAME=$DOMAIN
|
||||
HTTP_PORT=$HTTP_PORT
|
||||
HTTPS_PORT=443
|
||||
|
||||
DATABASE_NAME=$DB_NAME
|
||||
DATABASE_USER=$DB_USER
|
||||
DATABASE_PASSWORD=$DB_PASSWORD
|
||||
|
||||
JWT_SECRET=$JWT_SECRET
|
||||
|
||||
AZURE_TENANT_ID=$AZURE_TENANT
|
||||
AZURE_CLIENT_ID=$AZURE_CLIENT
|
||||
|
||||
OPENAI_API_KEY=$OPENAI_API_KEY
|
||||
|
||||
FRONTEND_URL=http://$DOMAIN:$HTTP_PORT
|
||||
BACKEND_URL=http://$DOMAIN:$HTTP_PORT/api
|
||||
CORS_ORIGIN=http://$DOMAIN:$HTTP_PORT,http://localhost:$HTTP_PORT
|
||||
|
||||
SSL_CERT_PATH=./certs
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Configuration saved to .env${NC}"
|
||||
|
||||
# Start deployment
|
||||
print_step "🚀 Starting Deployment"
|
||||
|
||||
echo "Building and starting containers..."
|
||||
echo "This may take a few minutes for the first build."
|
||||
echo ""
|
||||
|
||||
$COMPOSE up -d --build
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ Deployment Complete!${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Your Ideas Generator 2025 is now running at:${NC}"
|
||||
echo -e "${YELLOW}http://$DOMAIN:$HTTP_PORT${NC}"
|
||||
echo ""
|
||||
echo -e "${BLUE}Useful commands:${NC}"
|
||||
echo -e " View status: ${CYAN}$COMPOSE ps${NC}"
|
||||
echo -e " View logs: ${CYAN}$COMPOSE logs -f${NC}"
|
||||
echo -e " Stop: ${CYAN}$COMPOSE down${NC}"
|
||||
echo -e " Restart: ${CYAN}$COMPOSE restart${NC}"
|
||||
echo ""
|
||||
|
||||
# Show status
|
||||
$COMPOSE ps
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}🎉 Setup complete!${NC}"
|
||||
|
|
@ -52,13 +52,13 @@ ask_question() {
|
|||
if [ -n "$default" ]; then
|
||||
if [ "$is_password" = "password" ]; then
|
||||
echo -e "${BLUE}$question${NC} ${YELLOW}[default: ****]${NC}"
|
||||
echo -n "Enter value (or press Enter for default): "
|
||||
read -s response
|
||||
printf "Enter value (or press Enter for default): "
|
||||
read -s response </dev/tty
|
||||
echo ""
|
||||
else
|
||||
echo -e "${BLUE}$question${NC} ${YELLOW}[default: $default]${NC}"
|
||||
echo -n "Enter value (or press Enter for default): "
|
||||
read response
|
||||
printf "Enter value (or press Enter for default): "
|
||||
read response </dev/tty
|
||||
fi
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
|
|
@ -68,8 +68,8 @@ ask_question() {
|
|||
if [ "$is_password" = "password" ]; then
|
||||
echo -e "${BLUE}$question${NC} ${RED}(required)${NC}"
|
||||
while [ -z "$response" ]; do
|
||||
echo -n "Enter value: "
|
||||
read -s response
|
||||
printf "Enter value: "
|
||||
read -s response </dev/tty
|
||||
echo ""
|
||||
if [ -z "$response" ]; then
|
||||
echo -e "${RED}This field is required. Please enter a value.${NC}"
|
||||
|
|
@ -78,8 +78,8 @@ ask_question() {
|
|||
else
|
||||
echo -e "${BLUE}$question${NC} ${RED}(required)${NC}"
|
||||
while [ -z "$response" ]; do
|
||||
echo -n "Enter value: "
|
||||
read response
|
||||
printf "Enter value: "
|
||||
read response </dev/tty
|
||||
if [ -z "$response" ]; then
|
||||
echo -e "${RED}This field is required. Please enter a value.${NC}"
|
||||
fi
|
||||
|
|
@ -115,7 +115,8 @@ main() {
|
|||
echo ""
|
||||
echo "This wizard will collect all necessary configuration and generate your deployment files."
|
||||
echo ""
|
||||
read -p "Press Enter to continue..."
|
||||
echo "Press Enter to continue..."
|
||||
read </dev/tty
|
||||
|
||||
# Section 1: Basic Configuration
|
||||
print_section "${GEAR} Basic Configuration"
|
||||
|
|
@ -292,8 +293,8 @@ EOF
|
|||
echo ""
|
||||
|
||||
# Ask if user wants to start deployment now
|
||||
echo -n -e "${BLUE}Would you like to start the deployment now? (y/N): ${NC}"
|
||||
read start_now
|
||||
echo -e "${BLUE}Would you like to start the deployment now? (y/N): ${NC}"
|
||||
read start_now </dev/tty
|
||||
|
||||
if [[ $start_now =~ ^[Yy]$ ]]; then
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue