mirror of
https://github.com/Fluent-networks/tailscale-mikrotik.git
synced 2025-06-21 16:39:05 +02:00
30 lines
536 B
Bash
30 lines
536 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Prepare run dir
|
||
|
if [ ! -d "/var/run/sshd" ]; then
|
||
|
mkdir -p /var/run/sshd
|
||
|
fi
|
||
|
|
||
|
set -m
|
||
|
|
||
|
# Install routes
|
||
|
IFS=',' read -ra SUBNETS <<< "${ADVERTISE_ROUTES}"
|
||
|
for s in "${SUBNETS[@]}"; do
|
||
|
ip route add "$s" via "${CONTAINER_GATEWAY}"
|
||
|
done
|
||
|
|
||
|
# Start tailscaled and bring tailscale up
|
||
|
/usr/local/bin/tailscaled --tun=userspace-networking &
|
||
|
until /usr/local/bin/tailscale up \
|
||
|
--authkey=${AUTH_KEY} \
|
||
|
--advertise-routes="${ADVERTISE_ROUTES}"
|
||
|
do
|
||
|
sleep 0.1
|
||
|
done
|
||
|
echo Tailscale started
|
||
|
|
||
|
# Start SSH
|
||
|
/usr/sbin/sshd -D
|
||
|
|
||
|
fg %1
|