Files
plm-backend-service/test-env.sh
admin 0efeaff88e feat: PLM backend services - auth, user, project, config services
Sprint 0 backend development complete:
- auth-service: JWT authentication, login/logout, token refresh
- user-service: User CRUD, profile management, RBAC
- project-service: Project lifecycle, member management
- config-service: System configuration, audit logging

Technical stack:
- FastAPI async framework
- SQLAlchemy 2.0 async ORM
- JWT authentication with python-jose
- bcrypt password hashing
- Pydantic v2 validation

API endpoints: 31 total
Code lines: 3,551
2026-03-31 00:08:52 +08:00

129 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# PLM System Environment Test Script
echo "========================================"
echo " PLM System - Environment Test"
echo " Domain: aifly.ren"
echo "========================================"
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
PASS=0
FAIL=0
# Function to check command
check_command() {
if command -v "$1" &> /dev/null; then
echo -e "${GREEN}${NC} $2: $(eval echo $3)"
((PASS++))
return 0
else
echo -e "${RED}${NC} $2: Not found"
((FAIL++))
return 1
fi
}
# Function to check port
check_port() {
if netstat -tuln 2>/dev/null | grep -q ":$1 "; then
echo -e "${GREEN}${NC} Port $1: Listening"
((PASS++))
else
echo -e "${YELLOW}!${NC} Port $1: Not listening (expected)"
fi
}
echo -e "${BLUE}System Information:${NC}"
echo "----------------------------------------"
echo "Hostname: $(hostname)"
echo "OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d= -f2 | tr -d '"')"
echo "Kernel: $(uname -r)"
echo "Architecture: $(uname -m)"
echo ""
echo -e "${BLUE}Disk Space Check:${NC}"
echo "----------------------------------------"
df -h / | awk 'NR==2 {printf "Root partition: %s used, %s available\n", $5, $4}'
df -h /var/lib/docker 2>/dev/null | awk 'NR==2 {printf "Docker partition: %s used, %s available\n", $5, $4}'
echo "Install directory: $(du -sh ~/plm-system 2>/dev/null | awk '{print $1}')"
echo ""
echo -e "${BLUE}Software Versions:${NC}"
echo "----------------------------------------"
check_command "python3" "Python" '\$(python3 --version 2>&1)'
check_command "node" "Node.js" '\$(node --version)'
check_command "npm" "npm" '\$(npm --version)'
check_command "docker" "Docker" '\$(docker --version 2>&1 | cut -d" " -f3 | tr -d ",")'
# Check PostgreSQL (may be in docker or not installed yet)
if command -v psql &> /dev/null; then
check_command "psql" "PostgreSQL" '\$(psql --version | awk "{print \\$3}")'
else
echo -e "${YELLOW}!${NC} PostgreSQL: Not installed (will use Docker)"
fi
# Check Nginx
if command -v nginx &> /dev/null; then
check_command "nginx" "Nginx" '\$(nginx -v 2>&1 | grep -oP "nginx/\\K[0-9.]+" )'
else
echo -e "${YELLOW}!${NC} Nginx: Not installed (config ready)"
fi
echo ""
echo -e "${BLUE}Network Configuration:${NC}"
echo "----------------------------------------"
echo "Domain: aifly.ren"
echo "IP Address: $(hostname -I | awk '{print $1}')"
check_port "80"
check_port "443"
check_port "5432"
check_port "8000"
check_port "6379"
echo ""
echo -e "${BLUE}Directory Structure:${NC}"
echo "----------------------------------------"
for dir in app nginx node postgresql python redis; do
if [ -d "$HOME/plm-system/$dir" ]; then
echo -e "${GREEN}${NC} ~/plm-system/$dir/"
else
echo -e "${RED}${NC} ~/plm-system/$dir/ (missing)"
fi
done
echo ""
echo -e "${BLUE}Configuration Files:${NC}"
echo "----------------------------------------"
for file in "nginx/nginx.conf" "nginx/conf.d/aifly.ren.conf" "app/main.py" "app/.env.example" "python/requirements.txt" "node/package.json" "docker-compose.yml" "install.sh"; do
if [ -f "$HOME/plm-system/$file" ]; then
echo -e "${GREEN}${NC} $file"
else
echo -e "${RED}${NC} $file (missing)"
fi
done
echo ""
echo "========================================"
echo -e " Test Summary: ${GREEN}$PASS passed${NC}, ${RED}$FAIL failed${NC}"
echo "========================================"
echo ""
if [ $FAIL -eq 0 ]; then
echo -e "${GREEN}All checks passed!${NC}"
echo "Run the following to complete installation:"
echo " sudo ~/plm-system/install.sh"
exit 0
else
echo -e "${YELLOW}Some checks failed.${NC}"
echo "Run install script with sudo to install missing components:"
echo " sudo ~/plm-system/install.sh"
exit 1
fi