-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweb_simulation.sh
More file actions
executable file
·56 lines (46 loc) · 1.46 KB
/
web_simulation.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# UNIA OS Web Simulation Runner
# This script runs the web-based simulation of UNIA OS
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WEB_DIR="$SCRIPT_DIR/src/boot/web"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE} UNIA OS Web Simulation Runner ${NC}"
echo -e "${BLUE}======================================${NC}"
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
if ! command -v python &> /dev/null; then
echo -e "${RED}Error: Python is not installed.${NC}"
echo -e "${YELLOW}Please install Python before continuing.${NC}"
exit 1
else
PYTHON_CMD="python"
fi
else
PYTHON_CMD="python3"
fi
# Check if the web directory exists
if [ ! -d "$WEB_DIR" ]; then
echo -e "${RED}Error: Web directory not found at: $WEB_DIR${NC}"
exit 1
fi
# Navigate to web directory
cd "$WEB_DIR"
# Get a free port (default to 8000 if not possible)
PORT=8000
if command -v lsof &> /dev/null; then
while lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; do
PORT=$((PORT+1))
done
fi
echo -e "${GREEN}Starting UNIA OS web simulation on port $PORT...${NC}"
echo -e "${YELLOW}Open your browser to http://localhost:$PORT${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop the server${NC}"
# Start the HTTP server
$PYTHON_CMD -m http.server $PORT