summaryrefslogtreecommitdiff
path: root/SXXtailscale.template
blob: f3fa2376a75418cb64bc6d268fa3c4c0cf56006e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/builtin/sbin:/usr/builtin/bin:/usr/local/sbin:/usr/local/bin:/opt/sbin:/opt/bin"

TAILSCALED="/usr/local/sbin/tailscaled"
PIDFILE="/var/run/tailscaled.pid"

# Extra flags you might want to pass to tailscaled.
FLAGS="--tun=userspace-networking"

LOGGER_TAG=tailscale
COMMAND="$TAILSCALED \
    --statedir=/usr/local/lib/tailscale/ \
    --state=/usr/local/lib/tailscale/tailscaled.state \
    --socket=/var/run/tailscale/tailscaled.sock $FLAGS \
    2>&1 \
    | logger -t $LOGGER_TAG"

mkdir -p /var/run/tailscale/ /usr/local/lib/tailscale
mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 777 /dev/net/tun

start-stop-daemon \
    --start --background \
    --exec sh \
    --make-pidfile \
    --pidfile "$PIDFILE" \
    -- -c "$COMMAND"

# sleep 5
if ! grep -q 'net.ipv4.ip_forward' /etc/sysctl.conf ; then
    echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
fi
if ! grep -q 'net.ipv6.conf.all.forwarding' /etc/sysctl.conf ; then
    echo 'net.ipv6.conf.all.forwarding = 1' >> /etc/sysctl.conf
fi

sysctl -p /etc/sysctl.conf