mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-26 14:27:17 +01:00
linux_configuration: track ~/.local/bin wrapper scripts in repo, symlink instead of generating
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Moves 7 loose ~/.local/bin scripts into linux_configuration/scripts/ and tracks the flutter/dart git-env wrapper; fix_flutter_git_env.sh and unreal_mcp_repo.sh now symlink to the tracked files instead of writing heredocs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yhTkYV6ZeuAbQYvykFGFc Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f8a7aded7b
commit
8be1fac8f9
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"title": "Track hand-placed ~/.local/bin scripts in linux_configuration/scripts",
|
||||||
|
"objective": "Every hand-placed script in ~/.local/bin (fix-execstack-launch.sh, nvidia-pmon-logger.sh, usage-report-catchup.sh, krita, blender-mcp-host, blender-mcp-serve, unreal-mcp-server) becomes a tracked file under linux_configuration/scripts/, and ~/.local/bin keeps a symlink with the original name so every caller (systemd user units, ~/.claude.json MCP config) still works. install_unreal_mcp.sh symlinks the launcher instead of generating it with a heredoc.",
|
||||||
|
"acceptance_criteria": [
|
||||||
|
"readlink -f ~/.local/bin/<name> resolves to linux_configuration/scripts/<file> for all seven names (krita -> krita-scaled.sh)",
|
||||||
|
"bash -n passes for every tracked script; git ls-files -s shows mode 100755",
|
||||||
|
"install_launcher creates ~/.local/bin/unreal-mcp-server as a symlink to the tracked wrapper, idempotently, and chowns the link (not the target) under sudo"
|
||||||
|
],
|
||||||
|
"out_of_scope": [
|
||||||
|
"Editing systemd units, crontab or MCP configs (symlinks keep their paths valid)",
|
||||||
|
"Changing the moved scripts' behaviour"
|
||||||
|
],
|
||||||
|
"verifier": "readlink -f + bash -n loop over ~/.local/bin entries; install_launcher run against a temp USER_HOME; pre-commit hooks on the staged files"
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"intent": "Hand-placed ~/.local/bin scripts are version-controlled in linux_configuration/scripts/ while every existing ~/.local/bin path keeps working through a symlink.",
|
||||||
|
"scope": [
|
||||||
|
"linux_configuration/scripts/{fix-execstack-launch.sh,nvidia-pmon-logger.sh,usage-report-catchup.sh,krita-scaled.sh,blender-mcp-host,blender-mcp-serve,unreal-mcp-server}, linux_configuration/features/lib/unreal_mcp_repo.sh, linux_configuration/features/install_unreal_mcp.sh",
|
||||||
|
"Non-goal: no behaviour change to the moved scripts; callers are not edited"
|
||||||
|
],
|
||||||
|
"changes": [
|
||||||
|
"Six scripts copied byte-for-byte (cmp-verified, mode preserved); ~/.local/bin/krita is now named krita-scaled.sh in the repo",
|
||||||
|
"unreal-mcp-server is tracked; it reads UNREAL_MCP_PYTHON_DIR (default ~/.local/share/unreal-mcp/unreal-mcp/Python) because a static file cannot bake in --install-dir",
|
||||||
|
"install_launcher replaces the heredoc with ln -sfn to the tracked wrapper, chown -h under sudo, and logs a warning to export UNREAL_MCP_PYTHON_DIR when --install-dir is non-default"
|
||||||
|
],
|
||||||
|
"verification": [
|
||||||
|
{
|
||||||
|
"command": "for n in ...; do readlink -f ~/.local/bin/$n; bash -n ~/.local/bin/$n; done",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "all seven names resolve into linux_configuration/scripts and parse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "source lib/unreal_mcp_repo.sh with USER_HOME=<tmpdir>; install_launcher twice over a stale regular file",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "regular file replaced by symlink to scripts/unreal-mcp-server; second run idempotent; non-default install dir warning logged"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "pre-commit run <shellcheck|no-inline-python|no-polling-antipatterns|shell-coverage-ratchet|file-length-cap> --files <staged>",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "all passed"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"risks": [
|
||||||
|
"A non-default --install-dir now needs UNREAL_MCP_PYTHON_DIR exported where the MCP client launches the server",
|
||||||
|
"Moving or renaming the repo checkout breaks the ~/.local/bin symlinks"
|
||||||
|
],
|
||||||
|
"rollback": [
|
||||||
|
"git revert the commit, then cp the scripts from the previous ~/.local/bin state (git show <hash>:linux_configuration/scripts/<file>) over the symlinks",
|
||||||
|
"Check systemctl --user status nvidia-pmon.service usage-report-catchup.timer afterwards"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
# Install Unreal MCP and connect it to VS Code (via Continue MCP) on Arch Linux
|
# Install Unreal MCP and connect it to VS Code (via Continue MCP) on Arch Linux
|
||||||
# - Installs deps: git, jq, uv, python
|
# - Installs deps: git, jq, uv, python
|
||||||
# - Clones https://github.com/chongdashu/unreal-mcp
|
# - Clones https://github.com/chongdashu/unreal-mcp
|
||||||
# - Creates a launcher: ~/.local/bin/unreal-mcp-server
|
# - Symlinks ~/.local/bin/unreal-mcp-server to the tracked scripts/unreal-mcp-server
|
||||||
# - Configures VS Code Continue MCP: ~/.continue/config.json
|
# - Configures VS Code Continue MCP: ~/.continue/config.json
|
||||||
# - Optional: copies UnrealMCP plugin into a specified .uproject's Plugins/
|
# - Optional: copies UnrealMCP plugin into a specified .uproject's Plugins/
|
||||||
|
|
||||||
|
|||||||
@ -37,17 +37,18 @@ setup_repo() {
|
|||||||
# ---------- Launcher ----------
|
# ---------- Launcher ----------
|
||||||
install_launcher() {
|
install_launcher() {
|
||||||
local bin_dir="$USER_HOME/.local/bin"
|
local bin_dir="$USER_HOME/.local/bin"
|
||||||
local python_dir="$REPO_DIR/Python"
|
|
||||||
local launcher="$bin_dir/unreal-mcp-server"
|
local launcher="$bin_dir/unreal-mcp-server"
|
||||||
|
# The wrapper is tracked in the repo; ~/.local/bin only holds a symlink.
|
||||||
|
local target
|
||||||
|
target="$(readlink -f "$SCRIPT_DIR/../scripts/unreal-mcp-server")"
|
||||||
|
[[ -x $target ]] || fail "Tracked launcher missing: $target"
|
||||||
mkdir -p "$bin_dir"
|
mkdir -p "$bin_dir"
|
||||||
cat > "$launcher" << EOF
|
ln -sfn "$target" "$launcher"
|
||||||
#!/bin/bash
|
if [[ $EUID -eq 0 ]]; then chown -h "$ACTUAL_USER:$ACTUAL_USER" "$launcher"; fi
|
||||||
set -euo pipefail
|
if [[ $INSTALL_ROOT != "$INSTALL_ROOT_DEFAULT" ]]; then
|
||||||
exec uv --directory "$python_dir" run unreal_mcp_server.py "\${1:-}" < /dev/null
|
log "WARNING: non-default --install-dir; export UNREAL_MCP_PYTHON_DIR=$REPO_DIR/Python for the launcher"
|
||||||
EOF
|
fi
|
||||||
chmod +x "$launcher"
|
log "Installed launcher: $launcher -> $target"
|
||||||
if [[ $EUID -eq 0 ]]; then chown "$ACTUAL_USER:$ACTUAL_USER" "$launcher"; fi
|
|
||||||
log "Installed launcher: $launcher"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------- VS Code: Continue MCP config ----------
|
# ---------- VS Code: Continue MCP config ----------
|
||||||
|
|||||||
@ -41,8 +41,11 @@ set -euo pipefail
|
|||||||
SCRIPT_NAME="$(basename "$0")"
|
SCRIPT_NAME="$(basename "$0")"
|
||||||
readonly SCRIPT_NAME
|
readonly SCRIPT_NAME
|
||||||
readonly BIN_DIR="${HOME}/.local/bin"
|
readonly BIN_DIR="${HOME}/.local/bin"
|
||||||
readonly LIB_DIR="${HOME}/.local/share/flutter-git-env"
|
SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
|
||||||
readonly WRAPPER="${LIB_DIR}/wrapper.sh"
|
readonly SCRIPT_DIR
|
||||||
|
WRAPPER="$(readlink -f "${SCRIPT_DIR}/../scripts/flutter-git-env-wrapper.sh")"
|
||||||
|
readonly WRAPPER
|
||||||
|
readonly LEGACY_DIR="${HOME}/.local/share/flutter-git-env"
|
||||||
# Every SDK entry point that shells out to git to identify itself.
|
# Every SDK entry point that shells out to git to identify itself.
|
||||||
readonly TOOLS=(flutter dart)
|
readonly TOOLS=(flutter dart)
|
||||||
|
|
||||||
@ -53,50 +56,12 @@ fail() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
write_wrapper() {
|
# The wrapper is tracked in the repo; ~/.local/bin only holds symlinks to it.
|
||||||
mkdir -p "$LIB_DIR" "$BIN_DIR"
|
# A copy left by an older install (LEGACY_DIR) is generated, so it is removed.
|
||||||
cat > "$WRAPPER" <<'WRAPPER_EOF'
|
check_wrapper() {
|
||||||
#!/bin/bash
|
[[ -x $WRAPPER ]] || fail "tracked wrapper missing: $WRAPPER"
|
||||||
|
mkdir -p "$BIN_DIR"
|
||||||
# Strip the git-hook environment, then hand off to the real SDK binary.
|
rm -rf "$LEGACY_DIR"
|
||||||
# Installed by linux_configuration/fixes/fix_flutter_git_env.sh
|
|
||||||
# -- see that script for why this exists. Invoked through a symlink named
|
|
||||||
# after the tool it fronts (flutter, dart).
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
tool="$(basename "$0")"
|
|
||||||
real="/usr/bin/${tool}"
|
|
||||||
|
|
||||||
[[ -x $real ]] || {
|
|
||||||
echo "flutter-git-env: $real is missing or not executable" >&2
|
|
||||||
exit 127
|
|
||||||
}
|
|
||||||
|
|
||||||
# Drop our own directory so a PATH lookup inside the real tool cannot find
|
|
||||||
# this wrapper again. The Flutter entry point does exactly such a lookup.
|
|
||||||
clean_path=""
|
|
||||||
IFS=':' read -r -a path_parts <<< "$PATH"
|
|
||||||
for part in "${path_parts[@]}"; do
|
|
||||||
[[ $part == "$HOME/.local/bin" ]] && continue
|
|
||||||
clean_path="${clean_path:+$clean_path:}$part"
|
|
||||||
done
|
|
||||||
|
|
||||||
# GIT_DIR is the one that actually bites; the rest are exported by git in the
|
|
||||||
# same breath and would mislead the SDK the same way.
|
|
||||||
exec env \
|
|
||||||
-u GIT_DIR \
|
|
||||||
-u GIT_WORK_TREE \
|
|
||||||
-u GIT_INDEX_FILE \
|
|
||||||
-u GIT_COMMON_DIR \
|
|
||||||
-u GIT_OBJECT_DIRECTORY \
|
|
||||||
-u GIT_ALTERNATE_OBJECT_DIRECTORIES \
|
|
||||||
-u GIT_NAMESPACE \
|
|
||||||
-u GIT_PREFIX \
|
|
||||||
PATH="$clean_path" \
|
|
||||||
"$real" "$@"
|
|
||||||
WRAPPER_EOF
|
|
||||||
chmod +x "$WRAPPER"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
link_tools() {
|
link_tools() {
|
||||||
@ -152,7 +117,7 @@ uninstall() {
|
|||||||
log "removed $link"
|
log "removed $link"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -rf "$LIB_DIR"
|
rm -rf "$LEGACY_DIR"
|
||||||
log "uninstalled"
|
log "uninstalled"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +138,7 @@ main() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
command -v flutter >/dev/null 2>&1 || fail "flutter is not on PATH"
|
command -v flutter >/dev/null 2>&1 || fail "flutter is not on PATH"
|
||||||
write_wrapper
|
check_wrapper
|
||||||
link_tools
|
link_tools
|
||||||
check_path
|
check_path
|
||||||
verify
|
verify
|
||||||
|
|||||||
174
linux_configuration/scripts/blender-mcp-host
Executable file
174
linux_configuration/scripts/blender-mcp-host
Executable file
@ -0,0 +1,174 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Start Blender as a headless MCP host for blender-mcp.
|
||||||
|
#
|
||||||
|
# The blender-mcp addon refuses to run under `blender --background`: its
|
||||||
|
# command queue is pumped by bpy.app.timers, which never tick in background
|
||||||
|
# mode, so requests would be accepted and then never execute. The addon's own
|
||||||
|
# error message names the fix -- give Blender a display. Xvfb provides one
|
||||||
|
# without putting a window on a real output (i3 focus stealing is an explicit
|
||||||
|
# hazard here), and a real EEVEE render works fine against it.
|
||||||
|
#
|
||||||
|
# Known limitation: get_viewport_screenshot returns success but writes an
|
||||||
|
# all-black PNG under Xvfb -- there is no GL viewport to capture. Use
|
||||||
|
# bpy.ops.render.render(write_still=True) via execute_code instead; that is
|
||||||
|
# verified working and is what the artgate 3D route needs anyway.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_NAME="$(basename "$0")"
|
||||||
|
readonly SCRIPT_NAME
|
||||||
|
readonly ADDON_PATH="/home/kuhy/src/mcp-servers/servers/blender-mcp/addon.py"
|
||||||
|
readonly START_SCRIPT="/home/kuhy/.local/share/blender-mcp-host/start_addon.py"
|
||||||
|
readonly LOG_FILE="${XDG_STATE_HOME:-$HOME/.local/state}/blender-mcp-host.log"
|
||||||
|
|
||||||
|
PORT="${BLENDER_PORT:-9876}"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $SCRIPT_NAME [start|stop|status|restart]"
|
||||||
|
echo " start Launch headless Blender hosting the MCP socket (default)"
|
||||||
|
echo " stop Terminate the hosted Blender instance"
|
||||||
|
echo " status Report whether the socket is being served"
|
||||||
|
echo " restart stop, then start"
|
||||||
|
echo
|
||||||
|
echo "Env: BLENDER_PORT (default 9876)"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_requirements() {
|
||||||
|
local missing=0
|
||||||
|
for tool in blender xvfb-run; do
|
||||||
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||||
|
echo "Error: required tool '$tool' not found in PATH" >&2
|
||||||
|
missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -f "$ADDON_PATH" ]]; then
|
||||||
|
echo "Error: addon not found at $ADDON_PATH" >&2
|
||||||
|
missing=1
|
||||||
|
fi
|
||||||
|
[[ $missing -eq 0 ]] || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# True when something is listening on the MCP port.
|
||||||
|
port_is_served() {
|
||||||
|
ss -ltn 2>/dev/null | grep -q ":${PORT}\b"
|
||||||
|
}
|
||||||
|
|
||||||
|
# PID of the Blender process holding the port, empty if none.
|
||||||
|
host_pid() {
|
||||||
|
host_pids | head -1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Every process belonging to a host instance: the Blender that serves the
|
||||||
|
# socket plus the xvfb-run wrapper that owns its display. Stopping only the
|
||||||
|
# Blender pid leaves the wrapper behind, which then keeps a stale instance
|
||||||
|
# alive and makes the next `start` a silent no-op.
|
||||||
|
host_pids() {
|
||||||
|
pgrep -f "blender .*--python ${START_SCRIPT}" || true
|
||||||
|
pgrep -f "xvfb-run .*--python ${START_SCRIPT}" || true
|
||||||
|
}
|
||||||
|
|
||||||
|
do_start() {
|
||||||
|
if port_is_served; then
|
||||||
|
echo "Already serving on port ${PORT} (pid $(host_pid))"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$START_SCRIPT")" "$(dirname "$LOG_FILE")"
|
||||||
|
|
||||||
|
# The addon's register() auto-starts the server, so this script only needs
|
||||||
|
# to load it and then block -- Blender must stay alive to pump the timers.
|
||||||
|
cat > "$START_SCRIPT" <<'PY'
|
||||||
|
"""Load the blender-mcp addon; Blender's event loop then serves the socket."""
|
||||||
|
import importlib.util
|
||||||
|
import sys
|
||||||
|
|
||||||
|
_SPEC = importlib.util.spec_from_file_location(
|
||||||
|
"blendermcp_addon", "/home/kuhy/src/mcp-servers/servers/blender-mcp/addon.py")
|
||||||
|
_MOD = importlib.util.module_from_spec(_SPEC)
|
||||||
|
sys.modules["blendermcp_addon"] = _MOD
|
||||||
|
_SPEC.loader.exec_module(_MOD)
|
||||||
|
_MOD.register()
|
||||||
|
print("blender-mcp-host: addon registered, serving", flush=True)
|
||||||
|
PY
|
||||||
|
|
||||||
|
echo "Starting headless Blender on port ${PORT}..."
|
||||||
|
BLENDER_PORT="$PORT" nohup xvfb-run -a \
|
||||||
|
blender --factory-startup --python "$START_SCRIPT" \
|
||||||
|
>> "$LOG_FILE" 2>&1 &
|
||||||
|
disown
|
||||||
|
|
||||||
|
# Wait for the socket rather than sleeping a fixed guess.
|
||||||
|
local waited=0
|
||||||
|
while [[ $waited -lt 30 ]]; do
|
||||||
|
if port_is_served; then
|
||||||
|
echo "Serving on port ${PORT} (pid $(host_pid))"
|
||||||
|
echo "Log: $LOG_FILE"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
command sleep 1
|
||||||
|
waited=$((waited + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Error: port ${PORT} not served after ${waited}s; see $LOG_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
do_stop() {
|
||||||
|
local pids=()
|
||||||
|
mapfile -t pids < <(host_pids)
|
||||||
|
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||||
|
echo "Not running"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
kill "${pids[@]}" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Confirm the port is actually released rather than trusting the signal;
|
||||||
|
# a half-dead instance would make the next start a no-op.
|
||||||
|
local waited=0 remaining=()
|
||||||
|
while [[ $waited -lt 10 ]]; do
|
||||||
|
mapfile -t remaining < <(host_pids)
|
||||||
|
if ! port_is_served && [[ ${#remaining[@]} -eq 0 ]]; then
|
||||||
|
echo "Stopped Blender host (${pids[*]})"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
command sleep 1
|
||||||
|
waited=$((waited + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
mapfile -t remaining < <(host_pids)
|
||||||
|
[[ ${#remaining[@]} -gt 0 ]] && kill -9 "${remaining[@]}" 2>/dev/null || true
|
||||||
|
command sleep 1
|
||||||
|
if port_is_served; then
|
||||||
|
echo "Error: port ${PORT} still served after SIGKILL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Stopped Blender host (forced)"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_status() {
|
||||||
|
if port_is_served; then
|
||||||
|
echo "serving port=${PORT} pid=$(host_pid)"
|
||||||
|
else
|
||||||
|
echo "stopped port=${PORT}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
validate_requirements
|
||||||
|
case "${1:-start}" in
|
||||||
|
start) do_start ;;
|
||||||
|
stop) do_stop ;;
|
||||||
|
status) do_status ;;
|
||||||
|
restart) do_stop; command sleep 1; do_start ;;
|
||||||
|
-h|--help|help) usage ;;
|
||||||
|
*) echo "Unknown command: $1" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
24
linux_configuration/scripts/blender-mcp-serve
Executable file
24
linux_configuration/scripts/blender-mcp-serve
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# MCP entrypoint: guarantee a Blender host exists, then serve the MCP protocol.
|
||||||
|
#
|
||||||
|
# Registered as the `blender` MCP server's command. The blender-mcp server
|
||||||
|
# itself only *connects* to Blender's socket -- it cannot start Blender. If
|
||||||
|
# nothing hosts port 9876 (e.g. after a reboot) the server comes up and every
|
||||||
|
# tool call fails with a connection error, which reads like a broken MCP
|
||||||
|
# rather than a missing host. Starting the host here makes that failure
|
||||||
|
# impossible instead of relying on someone remembering to run a command.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly HOST_SCRIPT="/home/kuhy/.local/bin/blender-mcp-host"
|
||||||
|
readonly SERVER_DIR="/home/kuhy/src/mcp-servers/servers/blender-mcp"
|
||||||
|
readonly UV="/home/kuhy/.local/bin/uv"
|
||||||
|
|
||||||
|
# stdout is the MCP JSON-RPC channel -- any stray byte written there corrupts
|
||||||
|
# the protocol, so all host-startup chatter goes to stderr.
|
||||||
|
"$HOST_SCRIPT" start >&2
|
||||||
|
|
||||||
|
exec "$UV" run --directory "$SERVER_DIR" blender-mcp
|
||||||
44
linux_configuration/scripts/fix-execstack-launch.sh
Executable file
44
linux_configuration/scripts/fix-execstack-launch.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Fix executable stack flags on Source Engine .so files before launching.
|
||||||
|
# Usage: Set as Steam Launch Options:
|
||||||
|
# ~/.local/bin/fix-execstack-launch.sh %command%
|
||||||
|
#
|
||||||
|
# Works for any Source Engine game that fails on modern kernels (6.x+)
|
||||||
|
# due to shared libraries requiring executable stack (RWE flag).
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
echo "Usage: $0 <command> [args...]"
|
||||||
|
echo "Set as Steam launch option: ~/.local/bin/fix-execstack-launch.sh %command%"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Steam wraps %command% as: reaper SteamLaunch ... -- /path/to/game/hl2.sh -game ...
|
||||||
|
# Find the game directory by looking for a path inside steamapps/common/ in the args.
|
||||||
|
GAME_DIR=""
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ "$arg" == */steamapps/common/* ]]; then
|
||||||
|
resolved="$(readlink -f "$arg" 2>/dev/null)"
|
||||||
|
if [[ -n "$resolved" ]]; then
|
||||||
|
# Walk up to find the game root (directory directly under steamapps/common/)
|
||||||
|
candidate="$resolved"
|
||||||
|
while [[ "$candidate" == */steamapps/common/*/* ]]; do
|
||||||
|
candidate="$(dirname "$candidate")"
|
||||||
|
done
|
||||||
|
GAME_DIR="$candidate"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "$GAME_DIR" || ! -d "$GAME_DIR" ]]; then
|
||||||
|
echo "[fix-execstack] Warning: Could not detect game directory, skipping patch."
|
||||||
|
else
|
||||||
|
# Fast path: directly patch known Source Engine offenders without scanning.
|
||||||
|
# patchelf --clear-execstack is a no-op if the flag is already cleared.
|
||||||
|
for sofile in "$GAME_DIR"/bin/engine.so "$GAME_DIR"/bin/video_bink.so; do
|
||||||
|
[[ -f "$sofile" ]] && patchelf --clear-execstack "$sofile" 2>/dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Launch the game
|
||||||
|
exec "$@"
|
||||||
39
linux_configuration/scripts/flutter-git-env-wrapper.sh
Executable file
39
linux_configuration/scripts/flutter-git-env-wrapper.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Strip the git-hook environment, then hand off to the real SDK binary.
|
||||||
|
# Linked into ~/.local/bin by linux_configuration/fixes/fix_flutter_git_env.sh
|
||||||
|
# -- see that script for why this exists. Invoked through a symlink named
|
||||||
|
# after the tool it fronts (flutter, dart).
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
tool="$(basename "$0")"
|
||||||
|
real="/usr/bin/${tool}"
|
||||||
|
|
||||||
|
[[ -x $real ]] || {
|
||||||
|
echo "flutter-git-env: $real is missing or not executable" >&2
|
||||||
|
exit 127
|
||||||
|
}
|
||||||
|
|
||||||
|
# Drop our own directory so a PATH lookup inside the real tool cannot find
|
||||||
|
# this wrapper again. The Flutter entry point does exactly such a lookup.
|
||||||
|
clean_path=""
|
||||||
|
IFS=':' read -r -a path_parts <<<"$PATH"
|
||||||
|
for part in "${path_parts[@]}"; do
|
||||||
|
[[ $part == "$HOME/.local/bin" ]] && continue
|
||||||
|
clean_path="${clean_path:+$clean_path:}$part"
|
||||||
|
done
|
||||||
|
|
||||||
|
# GIT_DIR is the one that actually bites; the rest are exported by git in the
|
||||||
|
# same breath and would mislead the SDK the same way.
|
||||||
|
exec env \
|
||||||
|
-u GIT_DIR \
|
||||||
|
-u GIT_WORK_TREE \
|
||||||
|
-u GIT_INDEX_FILE \
|
||||||
|
-u GIT_COMMON_DIR \
|
||||||
|
-u GIT_OBJECT_DIRECTORY \
|
||||||
|
-u GIT_ALTERNATE_OBJECT_DIRECTORIES \
|
||||||
|
-u GIT_NAMESPACE \
|
||||||
|
-u GIT_PREFIX \
|
||||||
|
PATH="$clean_path" \
|
||||||
|
"$real" "$@"
|
||||||
8
linux_configuration/scripts/krita-scaled.sh
Executable file
8
linux_configuration/scripts/krita-scaled.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Scaled Krita launcher (shadows /usr/bin/krita on PATH).
|
||||||
|
# QT_SCALE_FACTOR=2 -> whole GUI at 2x (crisp, image res & tablet unaffected)
|
||||||
|
# XCURSOR_SIZE=32 -> ~2.5x on-screen cursor (visual only, no stroke change)
|
||||||
|
# Tune the two numbers to taste. exec keeps the same PID/args.
|
||||||
|
#
|
||||||
|
exec env QT_SCALE_FACTOR=2 XCURSOR_SIZE=32 /usr/bin/krita "$@"
|
||||||
38
linux_configuration/scripts/nvidia-pmon-logger.sh
Executable file
38
linux_configuration/scripts/nvidia-pmon-logger.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
LOG_DIR="$HOME/.local/share/gpu-log"
|
||||||
|
ERR_LOG="$LOG_DIR/pmon-errors.log"
|
||||||
|
mkdir -p "$LOG_DIR"
|
||||||
|
|
||||||
|
if ! command -v nvidia-smi >/dev/null 2>&1; then
|
||||||
|
echo "nvidia-pmon-logger: nvidia-smi not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wake every 60s to (a) check that the pmon child is still alive and (b) rotate
|
||||||
|
# the log on day-rollover. This used to spin in a `read -r -t 20` loop, but
|
||||||
|
# under systemd stdin is /dev/null, so `read` returned instantly on EOF. That
|
||||||
|
# turned the loop into a hot fork-storm calling `date +%Y%m%d` thousands of
|
||||||
|
# times per second (~22% of one core, ~122 CPU-hours/day).
|
||||||
|
#
|
||||||
|
# Use the bash printf %(...)T builtin (zero forks) for the date check, and a
|
||||||
|
# real sleep (one fork/min, ~1440/day — negligible) for the wait.
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
printf -v day '%(%Y%m%d)T' -1
|
||||||
|
out_file="$LOG_DIR/pmon-${day}.log"
|
||||||
|
|
||||||
|
nvidia-smi pmon -d 10 -o DT >>"$out_file" 2>>"$ERR_LOG" &
|
||||||
|
pmon_pid=$!
|
||||||
|
|
||||||
|
while kill -0 "$pmon_pid" >/dev/null 2>&1; do
|
||||||
|
printf -v today '%(%Y%m%d)T' -1
|
||||||
|
if [[ $today != "$day" ]]; then
|
||||||
|
kill "$pmon_pid" >/dev/null 2>&1 || true
|
||||||
|
wait "$pmon_pid" 2>/dev/null || true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
|
done
|
||||||
8
linux_configuration/scripts/unreal-mcp-server
Executable file
8
linux_configuration/scripts/unreal-mcp-server
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Launch the unreal-mcp Python server over stdio.
|
||||||
|
# ~/.local/bin/unreal-mcp-server is a symlink here, installed by
|
||||||
|
# features/install_unreal_mcp.sh. Set UNREAL_MCP_PYTHON_DIR when the repo was
|
||||||
|
# installed with --install-dir somewhere other than the default.
|
||||||
|
set -euo pipefail
|
||||||
|
python_dir="${UNREAL_MCP_PYTHON_DIR:-${HOME}/.local/share/unreal-mcp/unreal-mcp/Python}"
|
||||||
|
exec uv --directory "${python_dir}" run unreal_mcp_server.py "${1:-}" </dev/null
|
||||||
34
linux_configuration/scripts/usage-report-catchup.sh
Executable file
34
linux_configuration/scripts/usage-report-catchup.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO="/home/kuhy/src/testsAndMisc"
|
||||||
|
RUN_SCRIPT="$REPO/run.sh"
|
||||||
|
OUT_DIR="$HOME/.local/share/usage-reports"
|
||||||
|
ATOP_DIR="/var/log/atop"
|
||||||
|
|
||||||
|
mkdir -p "$OUT_DIR"
|
||||||
|
|
||||||
|
if [[ ! -x "$RUN_SCRIPT" ]]; then
|
||||||
|
echo "usage-report-catchup: missing executable $RUN_SCRIPT" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
TODAY="$(date +%Y%m%d)"
|
||||||
|
for atop_file in "$ATOP_DIR"/atop_*; do
|
||||||
|
date_part="${atop_file##*_}"
|
||||||
|
if [[ ! "$date_part" =~ ^[0-9]{8}$ ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
out_file="$OUT_DIR/usage-report-${date_part}.md"
|
||||||
|
tmp_file="$out_file.tmp"
|
||||||
|
|
||||||
|
if [[ "$date_part" == "$TODAY" || ! -s "$out_file" ]]; then
|
||||||
|
if "$RUN_SCRIPT" --date "$date_part" >"$tmp_file"; then
|
||||||
|
mv -f "$tmp_file" "$out_file"
|
||||||
|
else
|
||||||
|
rm -f "$tmp_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
Loading…
Reference in New Issue
Block a user