mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-27 06:02:51 +08:00
69 lines
1.7 KiB
Bash
Executable File
69 lines
1.7 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright 2020 Google LLC.
|
|
# Copyright (C) 2021 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
USE_PROCD=1
|
|
START=80
|
|
|
|
export TS_NO_LOGS_NO_SUPPORT=true
|
|
|
|
start_service() {
|
|
local service_enabled
|
|
local state_file
|
|
local port
|
|
local std_out
|
|
|
|
config_load tailscale
|
|
config_get_bool service_enabled "settings" service_enabled 0
|
|
[ "$service_enabled" -eq 1 ] || return 0
|
|
|
|
config_get_bool std_out "settings" log_stdout 1
|
|
config_get port "settings" port 41641
|
|
config_get state_file "settings" state_file /etc/tailscale/tailscaled.state
|
|
local fw_mode="auto"
|
|
if [ -x /usr/sbin/nft ] && command -v fw4 >/dev/null 2>&1; then
|
|
fw_mode="nftables"
|
|
elif [ -x /usr/sbin/iptables ]; then
|
|
fw_mode="iptables"
|
|
fi
|
|
|
|
/usr/sbin/tailscaled --cleanup
|
|
|
|
procd_open_instance
|
|
procd_set_param command /bin/sh -c 'exec /usr/sbin/tailscaled "$@" 2>&1' --
|
|
|
|
# Set backend firewall mode automatically based on active OpenWrt firewall
|
|
procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode"
|
|
|
|
# Disable logging to log.tailscale.com
|
|
procd_append_param env TS_NO_LOGS_NO_SUPPORT=true
|
|
|
|
# Set the port to listen on for incoming VPN packets.
|
|
# Remote nodes will automatically be informed about the new port number,
|
|
# but you might want to configure this in order to set external firewall
|
|
# settings.
|
|
procd_append_param command --port "$port"
|
|
procd_append_param command --state "$state_file"
|
|
|
|
procd_set_param respawn
|
|
procd_set_param stdout "$std_out"
|
|
procd_set_param stderr 0
|
|
|
|
procd_close_instance
|
|
}
|
|
|
|
stop_service() {
|
|
/usr/sbin/tailscaled --cleanup
|
|
killall -9 tailscaled 2>/dev/null || true
|
|
}
|
|
|
|
reload_service() {
|
|
restart
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_reload_trigger "tailscale"
|
|
}
|