Fluent-networks.tailscale-m.../tailscale.sh
Frank Edwards 82d1df3402 0.1.17
Tailscale v1.42.0
Support Headscale control server
Add container mount point
2023-06-18 13:58:03 +10:00

44 lines
924 B
Bash
Executable file

#!/bin/bash
set -m
# Enable IP forwarding
echo 'net.ipv4.ip_forward = 1' | tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | tee -a /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
# Prepare run dirs
if [ ! -d "/var/run/sshd" ]; then
mkdir -p /var/run/sshd
fi
# Set root password
echo "root:${PASSWORD}" | chpasswd
# Install routes
IFS=',' read -ra SUBNETS <<< "${ADVERTISE_ROUTES}"
for s in "${SUBNETS[@]}"; do
ip route add "$s" via "${CONTAINER_GATEWAY}"
done
# Set login server for tailscale
if [[ -z "$LOGIN_SERVER" ]]; then
LOGIN_SERVER=https://controlplane.tailscale.com
fi
# Start tailscaled and bring tailscale up
/usr/local/bin/tailscaled &
until /usr/local/bin/tailscale up \
--reset --authkey=${AUTH_KEY} \
--login-server ${LOGIN_SERVER} \
--advertise-routes="${ADVERTISE_ROUTES}" \
${TAILSCALE_ARGS}
do
sleep 0.1
done
echo Tailscale started
# Start SSH
/usr/sbin/sshd -D
fg %1