43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/bin/ash
|
|
set -e
|
|
|
|
# Persistent state lives in the add-on's /data (survives restarts/HAOS updates).
|
|
mkdir -p /data/ssh
|
|
|
|
# --- tailscaled (real TUN inside this container's netns; host never joins tailnet)
|
|
tailscaled \
|
|
--statedir=/data/tailscale \
|
|
--tun=tailscale0 \
|
|
--loginfoleak=false &
|
|
TAILSD=$!
|
|
|
|
# Wait for the socket before trying to bring the node up.
|
|
i=0
|
|
until [ -e /data/tailscale/tailscaled.sock ]; do
|
|
i=$((i+1)); [ "$i" -gt 30 ] && { echo "tailscaled socket never appeared"; exit 1; }
|
|
sleep 1
|
|
done
|
|
|
|
# Auth key is a file in /share (never shown in the add-on options UI).
|
|
if [ -r /share/ssh-bridge/tailscale_authkey ]; then
|
|
AUTHKEY="$(cat /share/ssh-bridge/tailscale_authkey)"
|
|
# shellcheck disable=SC2086
|
|
tailscale up \
|
|
--authkey="$AUTHKEY" \
|
|
--hostname="${tailscale_hostname:-ssh-bridge}" \
|
|
--accept-dns=false \
|
|
${tailscale_extra_args} \
|
|
--reset
|
|
unset AUTHKEY
|
|
else
|
|
echo "WARN: /share/ssh-bridge/tailscale_authkey missing; tailscale node not registered"
|
|
fi
|
|
|
|
# --- sshd host key (generated once, kept in /data)
|
|
if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
|
|
ssh-keygen -q -t ed25519 -N "" -f /data/ssh/ssh_host_ed25519_key
|
|
fi
|
|
|
|
# --- sshd in foreground; supervisor restarts the add-on if it dies
|
|
exec /usr/sbin/sshd -D -f /etc/ssh/sshd_config -e
|