mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-02-26 20:26:02 -05:00
47 lines
2.0 KiB
Bash
Executable File
47 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Generator for .devcontainer/Dockerfile
|
|
# Combines the root /Dockerfile (with some COPY lines removed) and
|
|
# the dev-only stage in .devcontainer/resources/devcontainer-Dockerfile.
|
|
# Run this script after modifying the resource Dockerfile to refresh
|
|
# the final .devcontainer/Dockerfile used by the devcontainer.
|
|
|
|
echo "Generating .devcontainer/Dockerfile"
|
|
SCRIPT_PATH=$(set -- "$0"; dirname -- "$1")
|
|
SCRIPT_DIR=$(cd "$SCRIPT_PATH" && pwd -P)
|
|
DEVCONTAINER_DIR="${SCRIPT_DIR%/scripts}"
|
|
ROOT_DIR="${DEVCONTAINER_DIR%/.devcontainer}"
|
|
|
|
OUT_FILE="${DEVCONTAINER_DIR}/Dockerfile"
|
|
|
|
echo "Adding base Dockerfile from $ROOT_DIR and merging to devcontainer-Dockerfile"
|
|
{
|
|
|
|
echo "# DO NOT MODIFY THIS FILE DIRECTLY. IT IS AUTO-GENERATED BY .devcontainer/scripts/generate-configs.sh"
|
|
echo ""
|
|
echo "# ---/Dockerfile---"
|
|
|
|
cat "${ROOT_DIR}/Dockerfile"
|
|
|
|
echo ""
|
|
echo "# ---/resources/devcontainer-Dockerfile---"
|
|
echo ""
|
|
cat "${DEVCONTAINER_DIR}/resources/devcontainer-Dockerfile"
|
|
} > "$OUT_FILE"
|
|
|
|
echo "Generated $OUT_FILE using root dir $ROOT_DIR"
|
|
|
|
# Passive Gemini MCP config
|
|
TOKEN=$(grep '^API_TOKEN=' /data/config/app.conf 2>/dev/null | cut -d"'" -f2)
|
|
if [ -n "${TOKEN}" ]; then
|
|
mkdir -p "${ROOT_DIR}/.gemini"
|
|
[ -f "${ROOT_DIR}/.gemini/settings.json" ] || echo "{}" > "${ROOT_DIR}/.gemini/settings.json"
|
|
jq --arg t "$TOKEN" '.mcpServers["netalertx-devcontainer"] = {url: "http://127.0.0.1:20212/mcp/sse", headers: {Authorization: ("Bearer " + $t)}}' "${ROOT_DIR}/.gemini/settings.json" > "${ROOT_DIR}/.gemini/settings.json.tmp" && mv "${ROOT_DIR}/.gemini/settings.json.tmp" "${ROOT_DIR}/.gemini/settings.json"
|
|
|
|
# VS Code MCP config
|
|
mkdir -p "${ROOT_DIR}/.vscode"
|
|
[ -f "${ROOT_DIR}/.vscode/mcp.json" ] || echo "{}" > "${ROOT_DIR}/.vscode/mcp.json"
|
|
jq --arg t "$TOKEN" '.servers["netalertx-devcontainer"] = {type: "sse", url: "http://127.0.0.1:20212/mcp/sse", headers: {Authorization: ("Bearer " + $t)}}' "${ROOT_DIR}/.vscode/mcp.json" > "${ROOT_DIR}/.vscode/mcp.json.tmp" && mv "${ROOT_DIR}/.vscode/mcp.json.tmp" "${ROOT_DIR}/.vscode/mcp.json"
|
|
fi
|
|
|
|
echo "Done." |