#!/usr/bin/env bash # Ski Predictor - One-time bootstrap script # # Usage: ./setup.sh # # This script sets up the environment, downloads historical data, # and trains the ML models. After running it, start the unified # daemon with: # # source .venv/bin/activate # export TELEGRAM_BOT_TOKEN='your_token' # uvicorn app.main:app --host 0.0.0.0 --port 8000 set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" VENV="$SCRIPT_DIR/.venv" PYTHON="$VENV/bin/python" DATA_DIR="$SCRIPT_DIR/data" ENV_FILE="$SCRIPT_DIR/.env" # --------------------------------------------------------------- # Colors # --------------------------------------------------------------- GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' info() { echo -e "${GREEN}[INFO]${NC} $1"; } warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } # --------------------------------------------------------------- # 1. Create venv + install deps # --------------------------------------------------------------- if [ ! -d "$VENV" ]; then info "Creating virtualenv..." python3 -m venv "$VENV" fi info "Installing dependencies..." "$VENV/bin/pip" install -q -r "$SCRIPT_DIR/requirements.txt" # --------------------------------------------------------------- # 2. Create data directories # --------------------------------------------------------------- mkdir -p "$DATA_DIR/raw" "$DATA_DIR/processed" "$SCRIPT_DIR/ml/models" # --------------------------------------------------------------- # 3. Load environment from .env when present # --------------------------------------------------------------- if [ -f "$ENV_FILE" ]; then info "Loading environment from $ENV_FILE" set -a # shellcheck disable=SC1090 . "$ENV_FILE" set +a fi # --------------------------------------------------------------- # 4. Download historical station data + weather + train models # --------------------------------------------------------------- info "Building full dataset (station history + weather + feature engineering + training)..." "$PYTHON" -m scripts.build_full_dataset # --------------------------------------------------------------- # 5. Download historical webcam images + crowd detection # --------------------------------------------------------------- info "Collecting historical webcam snapshots and crowd analysis..." "$PYTHON" -m scripts.collect_historical_webcams # --------------------------------------------------------------- # Summary # --------------------------------------------------------------- echo "" info "=== Setup complete ===" echo " Project: $SCRIPT_DIR" echo " Python: $PYTHON" echo " Data: $DATA_DIR" echo "" info "To start the unified daemon:" echo " source .venv/bin/activate" echo " export TELEGRAM_BOT_TOKEN='your_token'" echo " uvicorn app.main:app --host 0.0.0.0 --port 8000" echo ""