Skip to content

Commit 84fe182

Browse files
committed
Installer Enhancements
1 parent 0f5406a commit 84fe182

File tree

2 files changed

+229
-44
lines changed

2 files changed

+229
-44
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,34 @@
4848

4949
## 🚀 Quick Start
5050

51-
### One-Command Installation
51+
### Smart Installation with System Requirements Checking
52+
53+
**🤖 The setup script automatically validates your system meets the requirements for your chosen deployment mode:**
54+
5255
```bash
53-
# Option 1: Interactive setup (recommended)
56+
# 🎯 Interactive setup with automatic system validation (recommended)
5457
curl -fsSL https://raw.githubusercontent.com/rendiffdev/ffprobe-api/main/setup.sh | bash
5558

56-
# Option 2: Ultra-quick install
57-
curl -fsSL https://raw.githubusercontent.com/rendiffdev/ffprobe-api/main/install.sh | bash
59+
# ⚡ Non-interactive modes with automatic requirements checking:
60+
curl -fsSL setup.sh | bash -s -- --quick # 3GB RAM, 8GB disk
61+
curl -fsSL setup.sh | bash -s -- --minimal # 2GB RAM, 6GB disk
62+
curl -fsSL setup.sh | bash -s -- --production # 8GB RAM, 20GB disk
63+
curl -fsSL setup.sh | bash -s -- --development # 4GB RAM, 15GB disk
5864

59-
# Option 3: Clone and run
65+
# 🔧 Manual setup (no requirements checking)
6066
git clone https://github.com/rendiffdev/ffprobe-api.git
6167
cd ffprobe-api
6268
make quick
6369
```
6470

71+
**✨ What the smart installer checks:**
72+
- 📊 RAM: Deployment-specific minimum (2-8GB)
73+
- 💾 Disk space: Mode-specific requirements (6-20GB)
74+
- 🖥️ CPU cores: Sufficient processing power (1-4 cores)
75+
- 🔌 Network ports: Required ports available
76+
- 🐳 Docker: Installation and container capabilities
77+
- 🌐 Internet: Connection for downloading images
78+
6579
Your API is now running at **http://localhost:8080**
6680

6781
### 🧠 Test GenAI Analysis (The Core USP)

setup.sh

Lines changed: 210 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ INSTALL_DIR="${HOME}/ffprobe-api"
2222
DATA_DIR="${HOME}/ffprobe-api-data"
2323
COMPOSE_VERSION="latest"
2424
MIN_DOCKER_VERSION="24.0.0"
25+
# Default minimum requirements - will be updated based on deployment mode
2526
MIN_RAM_GB=4
2627
MIN_DISK_GB=10
28+
MIN_CPU_CORES=2
2729

2830
# Deployment modes
2931
DEPLOYMENT_MODES=("quick" "production" "development" "custom")
@@ -100,6 +102,49 @@ spinner() {
100102
printf " \b\b\b\b"
101103
}
102104

105+
# Set deployment-specific requirements
106+
set_deployment_requirements() {
107+
local mode=$1
108+
109+
case $mode in
110+
quick)
111+
MIN_RAM_GB=3
112+
MIN_DISK_GB=8
113+
MIN_CPU_CORES=2
114+
REQUIRED_PORTS=(8080 5432 6379 11434)
115+
log_info "Quick Start mode requirements: ${MIN_RAM_GB}GB RAM, ${MIN_DISK_GB}GB disk, ${MIN_CPU_CORES} CPU cores"
116+
;;
117+
production)
118+
MIN_RAM_GB=8
119+
MIN_DISK_GB=20
120+
MIN_CPU_CORES=4
121+
REQUIRED_PORTS=(8080 5432 6379 11434 80 443 3000 9090)
122+
log_info "Production mode requirements: ${MIN_RAM_GB}GB RAM, ${MIN_DISK_GB}GB disk, ${MIN_CPU_CORES} CPU cores"
123+
;;
124+
development)
125+
MIN_RAM_GB=4
126+
MIN_DISK_GB=15
127+
MIN_CPU_CORES=2
128+
REQUIRED_PORTS=(8080 5432 6379 11434 2345)
129+
log_info "Development mode requirements: ${MIN_RAM_GB}GB RAM, ${MIN_DISK_GB}GB disk, ${MIN_CPU_CORES} CPU cores"
130+
;;
131+
minimal)
132+
MIN_RAM_GB=2
133+
MIN_DISK_GB=6
134+
MIN_CPU_CORES=1
135+
REQUIRED_PORTS=(8080 5432 6379 11434)
136+
log_info "Minimal mode requirements: ${MIN_RAM_GB}GB RAM, ${MIN_DISK_GB}GB disk, ${MIN_CPU_CORES} CPU cores"
137+
;;
138+
*)
139+
# Default/unknown mode
140+
MIN_RAM_GB=4
141+
MIN_DISK_GB=10
142+
MIN_CPU_CORES=2
143+
REQUIRED_PORTS=(8080 5432 6379 11434)
144+
;;
145+
esac
146+
}
147+
103148
# OS Detection
104149
detect_os() {
105150
case "$(uname -s)" in
@@ -119,12 +164,18 @@ detect_os() {
119164
log_info "Detected OS: ${CYAN}$OS${NC} (${ARCH})"
120165
}
121166

122-
# Check system requirements
167+
# Check system requirements based on deployment mode
123168
check_requirements() {
124-
log_step "Checking System Requirements"
169+
local mode=${1:-"quick"}
170+
171+
# Set requirements based on deployment mode
172+
set_deployment_requirements "$mode"
173+
174+
log_step "Checking System Requirements for $mode Mode"
125175

126176
local checks_passed=0
127177
local checks_total=5
178+
local warnings=0
128179

129180
# Check RAM
130181
echo -n " Checking RAM... "
@@ -167,38 +218,120 @@ check_requirements() {
167218
# Check ports
168219
echo -n " Checking required ports... "
169220
local ports_available=true
170-
for port in 8080 5432 6379 11434; do
221+
local port_conflicts=()
222+
for port in "${REQUIRED_PORTS[@]}"; do
171223
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
172-
echo -e "${YELLOW}${NC} Port $port is in use"
224+
port_conflicts+=("$port")
173225
ports_available=false
174226
fi
175227
done
176228
if $ports_available; then
177-
echo -e "${GREEN}${NC} All ports available"
229+
echo -e "${GREEN}${NC} All required ports available (${REQUIRED_PORTS[*]})"
178230
((checks_passed++))
231+
else
232+
echo -e "${YELLOW}${NC} Ports in use: ${port_conflicts[*]}"
233+
((warnings++))
179234
fi
180235
show_progress $((checks_passed)) $checks_total
181236

182237
# Check CPU cores
183238
echo -n " Checking CPU cores... "
184239
local cpu_cores=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
185-
if [ $cpu_cores -ge 2 ]; then
186-
echo -e "${GREEN}${NC} ${cpu_cores} cores available"
240+
if [ $cpu_cores -ge $MIN_CPU_CORES ]; then
241+
echo -e "${GREEN}${NC} ${cpu_cores} cores available (need $MIN_CPU_CORES)"
187242
((checks_passed++))
188243
else
189-
echo -e "${YELLOW}${NC} Only ${cpu_cores} core(s) available"
244+
echo -e "${YELLOW}${NC} Only ${cpu_cores} core(s) available (need $MIN_CPU_CORES)"
245+
((warnings++))
190246
fi
191247
show_progress $checks_total $checks_total
192248

193-
if [ $checks_passed -lt 3 ]; then
194-
log_error "System requirements not met. Continue anyway? (y/N)"
249+
# Enhanced requirements evaluation
250+
echo
251+
if [ $checks_passed -eq $checks_total ]; then
252+
log_success "✅ All system requirements met for $mode mode ($checks_passed/$checks_total)"
253+
elif [ $checks_passed -ge 3 ]; then
254+
if [ $warnings -gt 0 ]; then
255+
log_warning "⚠️ System requirements mostly met with $warnings warning(s) ($checks_passed/$checks_total)"
256+
echo " This may impact performance but should still work."
257+
else
258+
log_success "System requirements check passed ($checks_passed/$checks_total)"
259+
fi
260+
else
261+
log_error "❌ Critical system requirements not met for $mode mode!"
262+
echo
263+
echo " Requirements Summary:"
264+
echo " • RAM: ${MIN_RAM_GB}GB minimum"
265+
echo " • Disk: ${MIN_DISK_GB}GB free space"
266+
echo " • CPU: ${MIN_CPU_CORES}+ cores"
267+
echo " • Ports: ${REQUIRED_PORTS[*]}"
268+
echo " • Internet connection"
269+
echo
270+
271+
if [ "$mode" = "production" ]; then
272+
echo " 💡 Consider switching to 'quick' or 'development' mode for lower requirements."
273+
echo
274+
echo " Continue with production mode anyway? (y/N)"
275+
else
276+
echo " Continue anyway? (y/N)"
277+
fi
278+
195279
read -r response
196280
if [[ ! "$response" =~ ^[Yy]$ ]]; then
281+
echo
282+
log_info "Installation cancelled. You can try:"
283+
echo " • Free up system resources"
284+
echo " • Use 'quick' mode: curl -fsSL setup.sh | bash -s -- --quick"
285+
echo " • Use minimal setup with lower requirements"
197286
exit 1
198287
fi
288+
289+
log_warning "⚠️ Proceeding with insufficient resources - performance may be degraded"
290+
fi
291+
}
292+
293+
# Validate Docker can run the required containers
294+
validate_docker_capabilities() {
295+
local mode=$1
296+
297+
log_step "Validating Docker Capabilities for $mode Mode"
298+
299+
if ! command -v docker &> /dev/null; then
300+
log_error "Docker not installed - cannot validate capabilities"
301+
return 1
302+
fi
303+
304+
if ! docker info &> /dev/null; then
305+
log_error "Docker daemon not running - cannot validate capabilities"
306+
return 1
307+
fi
308+
309+
# Check Docker memory limit
310+
echo -n " Checking Docker memory limit... "
311+
local docker_memory=$(docker system info --format '{{.MemTotal}}' 2>/dev/null || echo 0)
312+
local docker_memory_gb=$((docker_memory / 1024 / 1024 / 1024))
313+
314+
if [ $docker_memory_gb -ge $MIN_RAM_GB ]; then
315+
echo -e "${GREEN}${NC} ${docker_memory_gb}GB available to Docker"
316+
else
317+
echo -e "${YELLOW}${NC} Only ${docker_memory_gb}GB available to Docker (need ${MIN_RAM_GB}GB)"
318+
if [ "$mode" = "production" ]; then
319+
log_warning "Docker memory limit too low for production mode"
320+
echo " 💡 Increase Docker Desktop memory allocation in settings"
321+
fi
322+
fi
323+
324+
# Test basic container functionality
325+
echo -n " Testing container functionality... "
326+
if docker run --rm hello-world &> /dev/null; then
327+
echo -e "${GREEN}${NC} Docker can run containers"
199328
else
200-
log_success "System requirements check passed ($checks_passed/$checks_total)"
329+
echo -e "${RED}${NC} Docker cannot run containers"
330+
log_error "Docker installation appears to be broken"
331+
return 1
201332
fi
333+
334+
log_success "Docker validation complete"
202335
}
203336

204337
# Install Docker if not present
@@ -261,12 +394,13 @@ setup_wizard() {
261394
log_step "Configuration Wizard"
262395

263396
echo -e "\n${CYAN}Choose deployment mode:${NC}"
264-
echo " 1) ${GREEN}Quick Start${NC} - Minimal config, get running in 2 minutes"
265-
echo " 2) ${YELLOW}Production${NC} - Full features, security, monitoring"
266-
echo " 3) ${BLUE}Development${NC} - Hot reload, debug tools"
267-
echo " 4) ${MAGENTA}Custom${NC} - Configure everything"
397+
echo " 1) ${GREEN}Quick Start${NC} - Minimal config, get running in 2 minutes (3GB RAM, 8GB disk)"
398+
echo " 2) ${CYAN}Minimal${NC} - Ultra-lightweight for testing (2GB RAM, 6GB disk)"
399+
echo " 3) ${YELLOW}Production${NC} - Full features, security, monitoring (8GB RAM, 20GB disk)"
400+
echo " 4) ${BLUE}Development${NC} - Hot reload, debug tools (4GB RAM, 15GB disk)"
401+
echo " 5) ${MAGENTA}Custom${NC} - Configure everything"
268402

269-
read -p "Select mode [1-4] (default: 1): " mode_choice
403+
read -p "Select mode [1-5] (default: 1): " mode_choice
270404
mode_choice=${mode_choice:-1}
271405

272406
case $mode_choice in
@@ -275,14 +409,18 @@ setup_wizard() {
275409
log_info "Quick Start mode selected"
276410
;;
277411
2)
412+
DEPLOYMENT_MODE="minimal"
413+
log_info "Minimal mode selected"
414+
;;
415+
3)
278416
DEPLOYMENT_MODE="production"
279417
log_info "Production mode selected"
280418
;;
281-
3)
419+
4)
282420
DEPLOYMENT_MODE="development"
283421
log_info "Development mode selected"
284422
;;
285-
4)
423+
5)
286424
DEPLOYMENT_MODE="custom"
287425
log_info "Custom mode selected"
288426
;;
@@ -397,8 +535,8 @@ prepare_compose() {
397535
log_step "Preparing Docker Compose Configuration"
398536

399537
case $DEPLOYMENT_MODE in
400-
quick)
401-
# Minimal setup for quick start
538+
quick|minimal)
539+
# Lightweight setup for quick start and minimal deployments
402540
cat > "$INSTALL_DIR/docker-compose.yml" << 'EOF'
403541
version: '3.8'
404542
@@ -827,14 +965,19 @@ main() {
827965
# Detect OS
828966
detect_os
829967

830-
# Check system requirements
831-
check_requirements
968+
# Run setup wizard (unless non-interactive mode)
969+
if [ "$NON_INTERACTIVE" != "true" ]; then
970+
setup_wizard
971+
fi
972+
973+
# Check system requirements based on selected deployment mode
974+
check_requirements "$DEPLOYMENT_MODE"
832975

833976
# Install Docker if needed
834977
install_docker
835978

836-
# Run setup wizard
837-
setup_wizard
979+
# Validate Docker can handle the deployment mode
980+
validate_docker_capabilities "$DEPLOYMENT_MODE"
838981

839982
# Clone or update repository
840983
log_step "Setting up FFprobe API"
@@ -876,21 +1019,49 @@ main() {
8761019
}
8771020

8781021
# Handle arguments for non-interactive mode
879-
if [ "$1" = "--quick" ] || [ "$1" = "-q" ]; then
880-
DEPLOYMENT_MODE="quick"
881-
NON_INTERACTIVE=true
882-
elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
883-
echo "FFprobe API Automated Setup"
884-
echo ""
885-
echo "Usage: $0 [options]"
886-
echo ""
887-
echo "Options:"
888-
echo " -q, --quick Quick installation with defaults"
889-
echo " -h, --help Show this help message"
890-
echo ""
891-
echo "Without options, runs interactive setup wizard"
892-
exit 0
893-
fi
1022+
case "$1" in
1023+
"--quick" | "-q")
1024+
DEPLOYMENT_MODE="quick"
1025+
NON_INTERACTIVE=true
1026+
log_info "Non-interactive quick mode selected"
1027+
;;
1028+
"--minimal" | "-m")
1029+
DEPLOYMENT_MODE="minimal"
1030+
NON_INTERACTIVE=true
1031+
log_info "Non-interactive minimal mode selected"
1032+
;;
1033+
"--production" | "-p")
1034+
DEPLOYMENT_MODE="production"
1035+
NON_INTERACTIVE=true
1036+
log_info "Non-interactive production mode selected"
1037+
;;
1038+
"--development" | "-d")
1039+
DEPLOYMENT_MODE="development"
1040+
NON_INTERACTIVE=true
1041+
log_info "Non-interactive development mode selected"
1042+
;;
1043+
"--help" | "-h")
1044+
echo "FFprobe API Automated Setup"
1045+
echo ""
1046+
echo "Usage: $0 [options]"
1047+
echo ""
1048+
echo "Deployment Options:"
1049+
echo " -q, --quick Quick installation (3GB RAM, 8GB disk)"
1050+
echo " -m, --minimal Minimal installation (2GB RAM, 6GB disk)"
1051+
echo " -p, --production Production installation (8GB RAM, 20GB disk)"
1052+
echo " -d, --development Development installation (4GB RAM, 15GB disk)"
1053+
echo ""
1054+
echo "Other Options:"
1055+
echo " -h, --help Show this help message"
1056+
echo ""
1057+
echo "Without options, runs interactive setup wizard"
1058+
echo ""
1059+
echo "System Requirements Check:"
1060+
echo "The script will automatically check if your system meets the"
1061+
echo "minimum requirements for the selected deployment mode."
1062+
exit 0
1063+
;;
1064+
esac
8941065

8951066
# Run main installation
8961067
main

0 commit comments

Comments
 (0)