# === mdns-termux - .bashrc additions === # Append these lines to your ~/.bashrc # Ensure ~/.local/bin is on PATH export PATH="$HOME/.local/bin:$PATH" # Your Tailscale tailnet (change to yours). Used as fallback for resolve/sshr. export TAILSCALE_DOMAIN="tailXXXXXX.ts.net" # --- mDNS publisher (this device as movil.local on the LAN) --- alias mdns-status='pgrep -af mdns-publish || echo "mDNS publisher is not running"' alias mdns-restart='pkill -f mdns-publish; sleep 1; nohup python ~/.local/bin/mdns-publish.py >>~/.cache/mdns.log 2>&1 & disown && echo "mDNS restarted"' alias mdns-stop='pkill -f mdns-publish && echo "mDNS stopped"' # --- Generic host resolver (resolve: mDNS -> Tailscale -> cache) --- # Works in any command: ping $(resolve lenovo) / curl "http://$(resolve hp62a)" alias r='resolve' pingr() { ping -c 3 "$(resolve "$1")"; } curlr() { local h="$1"; shift; curl "$@" "http://$(resolve "$h")"; } # HostKeyAlias reuses the known_hosts entry for the Tailscale FQDN so SSH-by-IP # does not fail host-key verification. sshr() { local h="$1"; shift local canonical="$h" # Add your own short-name -> canonical mappings here: case "$h" in dell) canonical="dell-latitude3400";; lenovo) canonical="lenovo-ideapad";; esac ssh -o "HostKeyAlias=${canonical}.${TAILSCALE_DOMAIN}" \ "YOUR_USER@$(resolve "$h")" "$@" } # --- Auto-start publisher on shell login (optional) --- # Uncomment if you want movil.local advertised whenever you open a Termux shell. # Failures land in ~/.cache/mdns.log — do NOT redirect to /dev/null. # # mkdir -p ~/.cache # pgrep -f "mdns-publish" >/dev/null 2>&1 || \ # nohup python ~/.local/bin/mdns-publish.py >>~/.cache/mdns.log 2>&1 & disown