Skip to content

Commit

Permalink
code enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
lmagyar committed Oct 23, 2023
1 parent 1a06aaf commit adb30dd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
15 changes: 9 additions & 6 deletions tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ do
sleep 2
done

bashio::log.info "Tailscale is running"

# Warn about key expiration
if keyexpiry=$(/opt/tailscale status --self=true --peers=false --json | jq -rce '.Self.KeyExpiry'); then
bashio::log.warning "The connection's key will expire on: ${keyexpiry}"
bashio::log.warning "Consider disabling key expiry to avoid losing connection to your Home Assistant device."
bashio::log.warning "Please check your configuration based on the add-on's documentation under \"Configuration\""
fi

bashio::log.info "Tailscale is running"

# Notify about colliding subnet routes if non-userspace-networking is enabled
if bashio::config.false "userspace_networking"; then
# Warn about colliding subnet routes if non-userspace networking and accepting routes are enabled
if bashio::config.false "userspace_networking" && \
(! bashio::config.has_value "accept_routes" || \
bashio::config.true "accept_routes");
then
readarray -t colliding_routes < <( \
comm -1 -2 \
<(subnet-routes local) \
Expand All @@ -117,12 +120,12 @@ if bashio::config.false "userspace_networking"; then
done
fi

# Warn about userspace networking
# Notify about userspace networking
if ! bashio::config.has_value "userspace_networking" || \
bashio::config.true "userspace_networking";
then
bashio::log.notice "The add-on uses userspace networking mode."
bashio::log.notice "If you need to access other clients on your tailnet from your Home Assistant instance,"
bashio::log.notice "disable userspace networking mode, that will create a \"tailscale0\" network interface on your host."
bashio::log.notice "Please check your configuration based on the add-on's Documentation under \"Option: userspace_networking\""
bashio::log.notice "Please check your configuration based on the add-on's documentation under \"Option: userspace_networking\""
fi
2 changes: 1 addition & 1 deletion tailscale/rootfs/etc/s6-overlay/s6-rc.d/proxy/run
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if bashio::config.true 'proxy'; then
bashio::exit.nok
fi
bashio::log.info "Tailscale Proxy is enabled:"
bashio::log.info " Your Home Assistant instance is available within your Tailnet VPN at"
bashio::log.info " Your Home Assistant instance is available within your tailnet VPN at"
bashio::log.info " https://${domain}"

fi
2 changes: 1 addition & 1 deletion tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if bashio::debug ; then
exec /opt/tailscaled "${options[@]}"
else
bashio::log.notice \
"Tailscale logs will be suppressed after 200 lines, set add-on's "\
"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 \
Expand Down
2 changes: 1 addition & 1 deletion tailscale/rootfs/etc/s6-overlay/s6-rc.d/web/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ==============================================================================
# Home Assistant Community Add-on: Tailscale
# Runs tailscale web interface
# =============================================================================
# ==============================================================================
declare -a options

bashio::log.info 'Starting Tailscale web...'
Expand Down
13 changes: 9 additions & 4 deletions tailscale/rootfs/etc/s6-overlay/scripts/stage2_hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
# S6 Overlay stage2 hook to customize services
# ==============================================================================

# Disable protect-subnets service when userspace-networking is enabled
# Disable mss-clamping service when userspace-networking is enabled
# Disable protect-subnets service when userspace-networking is enabled or accepting routes is disabled
if ! bashio::config.has_value "userspace_networking" || \
bashio::config.true "userspace_networking";
bashio::config.true "userspace_networking" || \
bashio::config.false "accept_routes";
then
rm /etc/s6-overlay/s6-rc.d/user/contents.d/protect-subnets
rm /etc/s6-overlay/s6-rc.d/post-tailscaled/dependencies.d/protect-subnets
fi

# Disable mss-clamping service when userspace-networking is enabled
if ! bashio::config.has_value "userspace_networking" || \
bashio::config.true "userspace_networking";
then
rm /etc/s6-overlay/s6-rc.d/user/contents.d/mss-clamping
fi

# Disable taildrop service when it is has been explicitly disabled
# Disable taildrop service when it has been explicitly disabled
if bashio::config.false 'taildrop'; then
rm /etc/s6-overlay/s6-rc.d/user/contents.d/taildrop
fi

0 comments on commit adb30dd

Please sign in to comment.