59 lines
1.9 KiB
Bash
Executable File
59 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# KnowledgeCenter Web Server Installation Script
|
|
# This script sets up the necessary environment for the Flask web server.
|
|
|
|
set -e # Exit on any error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Script directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
echo -e "${BLUE}🔧 Setting up KnowledgeCenter Web Server Environment${NC}"
|
|
echo "=================================================="
|
|
|
|
# Check if uv is installed
|
|
if ! command -v uv &> /dev/null; then
|
|
echo -e "${YELLOW}⚠️ uv is not installed. Installing uv...${NC}"
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
source $HOME/.cargo/env
|
|
echo -e "${GREEN}✅ uv installed${NC}"
|
|
fi
|
|
|
|
echo -e "${GREEN}✅ uv found${NC}"
|
|
|
|
# Initialize uv project if not already done
|
|
if [ ! -f "pyproject.toml" ]; then
|
|
echo -e "${YELLOW}⚠️ No pyproject.toml found. Initializing uv project...${NC}"
|
|
uv init --no-readme --python 3.13
|
|
echo -e "${GREEN}✅ uv project initialized${NC}"
|
|
fi
|
|
|
|
# Sync dependencies
|
|
echo -e "${YELLOW}📦 Installing dependencies with uv...${NC}"
|
|
uv sync
|
|
uv pip install -e .
|
|
if [ -d "$HOME/code/git.ourworld.tf/herocode/herolib_python/herolib" ]; then
|
|
echo -e "${GREEN}✅ Found local herolib, installing...${NC}"
|
|
uv pip install -e "$HOME/code/git.ourworld.tf/herocode/herolib_python"
|
|
else
|
|
echo -e "${YELLOW}📦 Local herolib not found, installing from git...${NC}"
|
|
uv pip install herolib@git+https://git.ourworld.tf/herocode/herolib_python.git --force-reinstall --no-cache-dir
|
|
fi
|
|
echo -e "${GREEN}✅ Dependencies installed${NC}"
|
|
|
|
# Create necessary directories
|
|
mkdir -p static/css static/js static/images
|
|
mkdir -p templates
|
|
mkdir -p md
|
|
|
|
echo -e "${GREEN}✅ Directory structure verified${NC}"
|
|
|
|
echo -e "${GREEN}🎉 Installation complete! You can now run start_server.sh${NC}" |