-
Notifications
You must be signed in to change notification settings - Fork 74
/
run
executable file
·45 lines (38 loc) · 1.39 KB
/
run
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
40
41
42
43
44
45
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Tailscale
# Runs tailscale
# ==============================================================================
declare -a options
declare udp_port
bashio::log.info 'Starting Tailscale...'
options+=(--state=/data/tailscaled.state)
options+=(--statedir=/data/state)
# Opt out of client log upload to log.tailscale.io
if ! bashio::debug ; then
options+=(--no-logs-no-support)
fi
# Use configured UDP port
udp_port=$(bashio::addon.port "41641/udp")
if bashio::var.has_value "${udp_port}"; then
options+=(--port=${udp_port})
fi
# Use userspace networking by default when not set, or when explicitly enabled
if ! bashio::config.has_value "userspace_networking" || \
bashio::config.true "userspace_networking";
then
options+=(--tun=userspace-networking)
fi
# Run Tailscale
if bashio::debug ; then
exec /opt/tailscaled "${options[@]}"
else
bashio::log.notice \
"Tailscale logs will be suppressed after 200 lines, set add-on's" \
"configuration option 'log_level' to 'debug' to see further logs"
/opt/tailscaled "${options[@]}" 2>&1 \
| stdbuf -i0 -oL -eL \
sed -n -e '1,200p' \
-e "201c[further tailscaled logs suppressed, set add-on's configuration option 'log_level' to 'debug' to see further tailscaled logs]"
fi