#!/bin/bash # Installation verification script for Secure Proxy set -e # Colors GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' echo -e "${BLUE}╔════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}║ Secure Proxy - Installation Verification ║${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════╝${NC}" echo "" # Check Node.js echo -n "Checking Node.js... " if command -v node &> /dev/null; then NODE_VERSION=$(node -v) echo -e "${GREEN}✓${NC} $NODE_VERSION" else echo -e "${RED}✗${NC} Node.js not installed" exit 1 fi # Check npm echo -n "Checking npm... " if command -v npm &> /dev/null; then NPM_VERSION=$(npm -v) echo -e "${GREEN}✓${NC} $NPM_VERSION" else echo -e "${RED}✗${NC} npm not installed" exit 1 fi # Check project structure echo "" echo -e "${BLUE}Project Structure:${NC}" check_file() { if [ -f "$1" ]; then echo -e " ${GREEN}✓${NC} $1" else echo -e " ${RED}✗${NC} $1 (missing)" fi } check_dir() { if [ -d "$1" ]; then echo -e " ${GREEN}✓${NC} $1/" else echo -e " ${RED}✗${NC} $1/ (missing)" fi } echo "Core files:" check_file "src/server.js" check_file "src/config.js" check_file "src/db.js" echo "Middleware:" check_file "src/middleware/oidcMiddleware.js" check_file "src/middleware/security.js" check_file "src/middleware/proxyMiddleware.js" echo "Routes:" check_file "src/routes/authRoutes.js" check_file "src/routes/adminRoutes.js" check_file "src/routes/dashboardRoutes.js" echo "Controllers:" check_file "src/controllers/authController.js" check_file "src/controllers/serviceController.js" check_file "src/controllers/adminController.js" echo "Frontend:" check_file "public/admin.html" echo "Configuration:" check_file "package.json" check_file ".env" echo "Scripts:" check_file "scripts/initDb.js" check_file "scripts/seedDb.js" echo "Documentation:" check_file "README.md" check_file "DEVELOPMENT-MODE.md" check_file "QUICKSTART.md" check_file "INSTALLATION.md" # Check directories echo "" echo "Directories:" check_dir "src" check_dir "src/middleware" check_dir "src/routes" check_dir "src/controllers" check_dir "src/services" check_dir "src/utils" check_dir "public" check_dir "scripts" # Check dependencies echo "" echo -e "${BLUE}Dependencies:${NC}" if [ -d "node_modules" ]; then echo -e " ${GREEN}✓${NC} node_modules/ exists" # Check key packages for pkg in express sqlite3 openid-client http-proxy; do if [ -d "node_modules/$pkg" ]; then echo -e " ${GREEN}✓${NC} $pkg" else echo -e " ${RED}✗${NC} $pkg (missing)" fi done else echo -e " ${YELLOW}⚠${NC} node_modules/ not found - run: npm install" fi # Check database echo "" echo -e "${BLUE}Database:${NC}" if [ -f "db/services.db" ]; then echo -e " ${GREEN}✓${NC} db/services.db exists" # Check database tables if command -v sqlite3 &> /dev/null; then TABLES=$(sqlite3 db/services.db ".tables") if echo "$TABLES" | grep -q "services"; then echo -e " ${GREEN}✓${NC} services table" else echo -e " ${RED}✗${NC} services table (missing)" fi if echo "$TABLES" | grep -q "audit_logs"; then echo -e " ${GREEN}✓${NC} audit_logs table" else echo -e " ${RED}✗${NC} audit_logs table (missing)" fi if echo "$TABLES" | grep -q "access_logs"; then echo -e " ${GREEN}✓${NC} access_logs table" else echo -e " ${RED}✗${NC} access_logs table (missing)" fi fi else echo -e " ${YELLOW}⚠${NC} db/services.db not found - run: npm run init-db" fi # Configuration check echo "" echo -e "${BLUE}Configuration:${NC}" if [ -f ".env" ]; then echo -e " ${GREEN}✓${NC} .env file exists" # Check key settings if grep -q "PORT=" .env; then PORT=$(grep "PORT=" .env | cut -d'=' -f2 | tr -d ' ') echo -e " ${GREEN}✓${NC} PORT=$PORT" fi if grep -q "NODE_ENV=" .env; then ENV=$(grep "NODE_ENV=" .env | cut -d'=' -f2 | tr -d ' ') echo -e " ${GREEN}✓${NC} NODE_ENV=$ENV" fi # Check OIDC status if grep -q "^OIDC_ISSUER=" .env; then echo -e " ${GREEN}✓${NC} OIDC configured (production mode)" else echo -e " ${YELLOW}⚠${NC} OIDC not configured (development mode)" fi else echo -e " ${RED}✗${NC} .env file not found" fi # Ready status echo "" echo -e "${BLUE}╔════════════════════════════════════════════════════╗${NC}" if [ -f "db/services.db" ] && [ -d "node_modules" ] && [ -f ".env" ]; then echo -e "${GREEN}✓ Installation complete and ready to run!${NC}" echo "" echo "Next steps:" echo " 1. Start the server: ${BLUE}npm run dev${NC}" echo " 2. Open in browser: ${BLUE}http://localhost:3000/admin${NC}" echo " 3. Read the guide: ${BLUE}DEVELOPMENT-MODE.md${NC}" echo "" echo -e "${BLUE}╚════════════════════════════════════════════════════╝${NC}" else echo -e "${YELLOW}⚠ Setup incomplete. Run the following:${NC}" if [ ! -d "node_modules" ]; then echo " ${BLUE}npm install${NC}" fi if [ ! -f "db/services.db" ]; then echo " ${BLUE}npm run init-db${NC}" fi echo "" echo -e "${BLUE}╚════════════════════════════════════════════════════╝${NC}" fi