|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -REPO_ROOT="/mios" |
5 | | -SYSTEM_ROOT="/" |
| 4 | +# MiOS Day-0 Root Overlay: Aggressive FHS Symlink Merge |
| 5 | +# SSOT: The repository IS the system root. |
6 | 6 |
|
7 | | -echo "🔄 Initializing MiOS COMPLETE System Root Overlay..." |
| 7 | +# 1. Detect Repository Root |
| 8 | +if [ -d "/mios/.git" ]; then |
| 9 | + REPO_ROOT="/mios" |
| 10 | +elif [ -d "/workspaces/MiOS/.git" ]; then |
| 11 | + REPO_ROOT="/workspaces/MiOS" |
| 12 | +else |
| 13 | + # Fallback to current dir if it looks like the repo |
| 14 | + if [ -d ".git" ] && [ -f "Justfile" ]; then |
| 15 | + REPO_ROOT=$(pwd) |
| 16 | + else |
| 17 | + echo "Error: MiOS Repository not found in /mios, /workspaces/MiOS, or current dir." |
| 18 | + exit 1 |
| 19 | + fi |
| 20 | +fi |
| 21 | + |
| 22 | +echo "🔄 Initializing MiOS COMPLETE System Root Overlay from $REPO_ROOT..." |
8 | 23 |
|
9 | | -# 1. Mandatory Git Identity (The System Root IS the Git Repository) |
10 | | -echo " [ROOT] Mapping /.git -> ${REPO_ROOT}/.git" |
11 | | -ln -sf "${REPO_ROOT}/.git" "${SYSTEM_ROOT}.git" |
| 24 | +# 2. Establish Git Identity of / (/.git -> REPO/.git) |
| 25 | +ln -sf "${REPO_ROOT}/.git" "/.git" |
12 | 26 |
|
13 | | -# 2. Aggressive Global Merge |
14 | | -# We include ALL files and directories from the repo root |
| 27 | +# 3. Exhaustive Global Merge |
| 28 | +# We use cp -as to recursively symlink the repository tree into / |
| 29 | +# shopt -s dotglob ensures hidden files are included |
15 | 30 | shopt -s dotglob |
16 | 31 | for item in "${REPO_ROOT}"/*; do |
17 | 32 | [ -e "$item" ] || continue |
18 | 33 | name=$(basename "$item") |
19 | 34 |
|
20 | | - # Avoid self-recursion and sensitive container mounts |
| 35 | + # Avoid recursion/system breakage |
21 | 36 | case "$name" in |
22 | | - .devcontainer|vscode|workspaces|proc|sys|dev|run|tmp|boot|mnt|root) |
| 37 | + .devcontainer|proc|sys|dev|run|tmp|boot|mnt|root|vscode|workspaces) |
23 | 38 | continue |
24 | 39 | ;; |
25 | 40 | esac |
26 | 41 |
|
27 | | - target="${SYSTEM_ROOT}${name}" |
| 42 | + target="/$name" |
28 | 43 |
|
29 | 44 | if [ -d "$item" ]; then |
30 | | - # For FHS-standard directories, we merge the contents |
31 | | - if [[ "$name" =~ ^(usr|etc|var|srv|home|v1|bin|lib|lib64|sbin)$ ]]; then |
32 | | - echo " [MERGE] /$name" |
33 | | - mkdir -p "$target" |
34 | | - cp -as "${item}/"* "$target/" 2>/dev/null || true |
35 | | - else |
36 | | - # For project-specific directories (automation, tools, etc.), link them directly |
37 | | - echo " [LINK] /$name" |
38 | | - ln -sfn "$item" "$target" |
39 | | - fi |
| 45 | + echo " [MERGE] /$name" |
| 46 | + mkdir -p "$target" |
| 47 | + # Recursively symlink contents |
| 48 | + cp -as "${item}/"* "$target/" 2>/dev/null || true |
40 | 49 | else |
41 | | - # For all root-level files (Justfile, Containerfile, VERSION, etc.) |
42 | 50 | echo " [FILE] /$name" |
43 | | - ln -sf "$item" "$target" |
| 51 | + ln -sf "$item" "$target" 2>/dev/null || true |
44 | 52 | fi |
45 | 53 | done |
46 | 54 |
|
47 | | -echo "✅ MiOS System Root Overlay: FULLY MERGED" |
| 55 | +# 4. Enforce Day-0 AI Surface |
| 56 | +mkdir -p /v1/chat |
| 57 | +cat <<EON > /v1/chat/completions |
| 58 | +# MiOS Unified Inference Schema |
| 59 | +{ |
| 60 | + "spec": "POST /v1/chat/completions", |
| 61 | + "implementation": "Native system proxy", |
| 62 | + "status": "ready" |
| 63 | +} |
| 64 | +EON |
| 65 | + |
| 66 | +mkdir -p /usr/share/mios/ai/v1 |
| 67 | +cat <<EON > /usr/share/mios/ai/v1/models.json |
| 68 | +{ |
| 69 | + "object": "list", |
| 70 | + "data": [], |
| 71 | + "documentation": "Native model discovery schema." |
| 72 | +} |
| 73 | +EON |
| 74 | +ln -sf /usr/share/mios/ai/v1/models.json /v1/models 2>/dev/null || true |
| 75 | + |
| 76 | +echo "✅ MiOS System Root Overlay: FULLY SYNCHRONIZED" |
0 commit comments