mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
3529 invalid comments in 528 files, grandfathered in while the linter only saw the working-tree diff. Removal ran through the linter's own collectors, so detection and deletion cannot drift: a comment whose opener line is blank before it and whose closer line is blank after it loses all its lines, anything else loses only the comment region, and a line left holding a bare delimiter goes with it. Five files keep their comments behind a nocheck marker instead. Four are upstream configs whose inline docs are upstream's own (mautrix, systemd journald, nextcloud-oidc-login, MediaWiki). In littlejs the commented-out entries ARE the deactivation mechanism for an example tile, so deleting them would delete configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
62 lines
2.5 KiB
Bash
Executable File
62 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source "${SCRIPT_DIR}/../../../../meta/env/load.sh"
|
|
[[ "${INFINITO_IS_WSL2}" == "true" ]] || exit 0
|
|
|
|
UPSTREAM_CONF="/etc/dnsmasq.d/00-wsl2-upstream.conf"
|
|
STUB_CONF="/etc/systemd/resolved.conf.d/disable-stub.conf"
|
|
WSL_CONF="/etc/wsl.conf"
|
|
RESOLV_CONF="/etc/resolv.conf"
|
|
|
|
UPSTREAM_DNS=$(grep -m1 "^nameserver" "${RESOLV_CONF}" 2>/dev/null | awk '{print $2}' || true)
|
|
if [[ -z "${UPSTREAM_DNS}" ]]; then
|
|
UPSTREAM_DNS=$(ip route show default 2>/dev/null | awk '/default via/{print $3; exit}' || true)
|
|
fi
|
|
if [[ -z "${UPSTREAM_DNS}" ]]; then
|
|
UPSTREAM_DNS="8.8.8.8" # nocheck: hardcoded-dns-resolver
|
|
fi
|
|
|
|
echo ">>> WSL2 DNS setup — upstream gateway: ${UPSTREAM_DNS}"
|
|
|
|
if [[ ! -f "${STUB_CONF}" ]]; then
|
|
echo ">>> Disabling systemd-resolved stub listener"
|
|
sudo mkdir -p "$(dirname "${STUB_CONF}")"
|
|
printf '[Resolve]\nDNSStubListener=no\n' | sudo tee "${STUB_CONF}" >/dev/null
|
|
sudo systemctl restart systemd-resolved
|
|
fi
|
|
|
|
echo ">>> Writing dnsmasq upstream forwarder: ${UPSTREAM_CONF}"
|
|
printf 'server=%s\n' "${UPSTREAM_DNS}" | sudo tee "${UPSTREAM_CONF}" >/dev/null
|
|
|
|
if ! grep -qs "generateResolvConf\s*=\s*false" "${WSL_CONF}" 2>/dev/null; then
|
|
echo ">>> Disabling WSL auto-generation of /etc/resolv.conf"
|
|
if grep -qs "^\[network\]" "${WSL_CONF}" 2>/dev/null; then
|
|
sudo sed -i '/^\[network\]/a generateResolvConf = false' "${WSL_CONF}"
|
|
else
|
|
printf '\n[network]\ngenerateResolvConf = false\n' | sudo tee -a "${WSL_CONF}" >/dev/null
|
|
fi
|
|
fi
|
|
|
|
echo ">>> Pointing /etc/resolv.conf at 127.0.0.1 (dnsmasq)"
|
|
sudo rm -f "${RESOLV_CONF}"
|
|
printf 'nameserver 127.0.0.1\n' | sudo tee "${RESOLV_CONF}" >/dev/null
|
|
|
|
echo ">>> Restarting dnsmasq"
|
|
sudo systemctl enable dnsmasq --quiet 2>/dev/null || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error
|
|
sudo systemctl restart dnsmasq
|
|
|
|
BINFMT_CONF="/etc/binfmt.d/WSLInterop.conf"
|
|
if [[ ! -f "${BINFMT_CONF}" ]]; then
|
|
echo ">>> Registering WSL interop binfmt handler"
|
|
printf ':WSLInterop:M::MZ::/init:PF\n' | sudo tee "${BINFMT_CONF}" >/dev/null
|
|
sudo systemctl restart systemd-binfmt
|
|
fi
|
|
if ! grep -qs "WSLInterop" /proc/sys/fs/binfmt_misc/WSLInterop 2>/dev/null; then
|
|
printf ':WSLInterop:M::MZ::/init:PF\n' | sudo tee /proc/sys/fs/binfmt_misc/register >/dev/null 2>&1 || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error
|
|
fi
|
|
|
|
echo ">>> WSL2 DNS pre-configuration complete"
|