fester/install-fester.sh

196 lines
4.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
echo "🧠 Fester Bootstrap Installer Starting..."
BASE_DIR="${BASE_DIR:-/usr/share/cockpit/fester}"
echo "📁 Creating directory structure at $BASE_DIR"
mkdir -p "$BASE_DIR"/{backend,ui,analysis,cli,cockpit,fester,docs,config,integrations}
mkdir -p "$BASE_DIR/backend"/{api,executor,scheduler,analysis,cache,graph,events,metrics,targets,policy,pipeline,nodes,storage,integrations}
mkdir -p "$BASE_DIR/ui"
mkdir -p "$BASE_DIR/docs"
# ------------------------------------------------------------
# CONFIG
# ------------------------------------------------------------
cat > "$BASE_DIR/config.yaml" <<'EOF'
cluster:
name: fester-cluster
scheduler: weighted
default_target: native
cache:
backend: minio
tmpfs_acceleration: true
btrfs_snapshot: optional
observability:
prometheus: true
grafana: true
execution:
distcc: true
libvirt: true
lxc: true
EOF
# ------------------------------------------------------------
# CHEATSHEET
# ------------------------------------------------------------
cat > "$BASE_DIR/docs/CHEATSHEET.md" <<'EOF'
# 🧠 Fester Cheatsheet
## Build
fester build ./project.yaml
## Nodes
fester node list
fester node set-policy <node> preferred
## Debug
/api/autopsy/<id>
/api/replay/<id>
## UI
Cockpit Module: Fester
Live DAG: /ui/live_dag.html
EOF
# ------------------------------------------------------------
# LICENSE
# ------------------------------------------------------------
cat > "$BASE_DIR/LICENSE" <<'EOF'
AGPLv3 - See https://www.gnu.org/licenses/
This system is provided AS IS with no warranty.
EOF
# ------------------------------------------------------------
# SIMPLE UI ENTRY POINT
# ------------------------------------------------------------
cat > "$BASE_DIR/ui/live_dag.html" <<'EOF'
<!DOCTYPE html>
<html>
<head>
<title>Fester Live DAG</title>
<style>
body { background:#0e0f12; color:#ddd; font-family:monospace; }
.node { padding:6px; margin:4px; background:#222; display:inline-block; }
</style>
</head>
<body>
<div id="graph"></div>
<script>
const ws = new WebSocket("ws://localhost:8080/ws");
ws.onmessage = (msg) => {
const e = JSON.parse(msg.data);
const g = document.getElementById("graph");
const d = document.createElement("div");
d.className="node";
d.innerText = JSON.stringify(e);
g.appendChild(d);
};
</script>
</body>
</html>
EOF
# ------------------------------------------------------------
# PROMETHEUS CONFIG
# ------------------------------------------------------------
cat > "$BASE_DIR/add-to-prometheus-config.yml" <<'EOF'
scrape_configs:
- job_name: 'fester'
static_configs:
- targets: ['localhost:9100']
EOF
# ------------------------------------------------------------
# GRAFANA CONFIG
# ------------------------------------------------------------
cat > "$BASE_DIR/add-to-grafana-config.json" <<'EOF'
{
"dashboard": {
"title": "Fester Cluster Overview"
}
}
EOF
# ------------------------------------------------------------
# COCKPIT MODULE ENTRY
# ------------------------------------------------------------
cat > "$BASE_DIR/manifest.json" <<'EOF'
{
"version": 1,
"name": "fester",
"label": "Fester Cluster Control",
"entrypoint": "index.html"
}
EOF
# ------------------------------------------------------------
# CLI BOOTSTRAP
# ------------------------------------------------------------
cat > "$BASE_DIR/cli/fester.py" <<'EOF'
#!/usr/bin/env python3
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("cmd")
args = parser.parse_args()
print("Fester CLI:", args.cmd)
if __name__ == "__main__":
main()
EOF
chmod +x "$BASE_DIR/cli/fester.py"
# ------------------------------------------------------------
# BASIC INDEX
# ------------------------------------------------------------
cat > "$BASE_DIR/index.html" <<'EOF'
<html>
<body>
<h1>Fester Control Plane</h1>
<a href="/ui/live_dag.html">Live DAG</a>
</body>
</html>
EOF
# ------------------------------------------------------------
# INITIAL CONFIG WIZARD
# ------------------------------------------------------------
echo "⚙️ Initial Configuration"
read -p "Cluster name [fester-cluster]: " CLUSTER_NAME
CLUSTER_NAME=${CLUSTER_NAME:-fester-cluster}
read -p "Enable libvirt? (y/n) [y]: " LIBVIRT
LIBVIRT=${LIBVIRT:-y}
read -p "Enable LXC? (y/n) [y]: " LXC
LXC=${LXC:-y}
read -p "Enable distcc? (y/n) [y]: " DISTCC
DISTCC=${DISTCC:-y}
cat > "$BASE_DIR/config.runtime.yaml" <<EOF
cluster:
name: $CLUSTER_NAME
integrations:
libvirt: $LIBVIRT
lxc: $LXC
distcc: $DISTCC
EOF
echo "✅ Fester installed successfully at $BASE_DIR"
echo "🚀 Open Cockpit and select Fester module"