mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 08:53:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,43 @@
|
||||
config tailscale 'settings'
|
||||
# Set whether Tailcale is enabled or not
|
||||
option enabled '0'
|
||||
# Set the port to listen on for incoming Tailscale packets (default 41641)
|
||||
option port '41641'
|
||||
# Path to config file
|
||||
option config_path '/etc/tailscale'
|
||||
# Default to using nftables - change below to 'iptables' if still using iptables
|
||||
option fw_mode 'iptables'
|
||||
# Enable stdout log
|
||||
option log_stdout '1'
|
||||
# Enable stderr log
|
||||
option log_stderr '1'
|
||||
# Accept subnet routes that other nodes advertise
|
||||
#option accept_routes '1'
|
||||
# Provide a hostname to use for the device instead of the one provided by the OS
|
||||
#option hostname ''
|
||||
# Accept DNS configuration from the admin console. (default accept)
|
||||
option accept_dns '1'
|
||||
# Offer to be an exit node for outbound internet traffic from the Tailscale network
|
||||
#option advertise_exit_node '1'
|
||||
# Provide a Tailscale IP or machine name to use as an exit node
|
||||
#option exit_node ''
|
||||
# Expose physical subnet routes to your entire Tailscale network (e.g. 10.0.0.0/24)
|
||||
#list advertise_routes ''
|
||||
# Set to '1' to disable subnet route masquerading
|
||||
#option disable_snat_subnet_routes '1'
|
||||
# To connect subnets within your tailnet (e.g. 192.168.1.0/24)
|
||||
# Documentation https://tailscale.com/kb/1214/site-to-site
|
||||
#list subnet_routes ''
|
||||
# Set firewall zone (ts_ac_lan: Tailscale access LAN, ts_ac_wan: Tailscale access WAN:, lan_ac_ts: LAN access Tailscale, wan_ac_ts: WAN access Tailscale)
|
||||
# Documentation https://openwrt.org/docs/guide-user/services/vpn/tailscale/start
|
||||
#list access 'ts_ac_lan'
|
||||
#list access 'ts_ac_wan'
|
||||
#list access 'lan_ac_ts'
|
||||
#list access 'wan_ac_ts'
|
||||
# Set extra flags for enabling settings upon the initiation of Tailscale
|
||||
# Documentation https://tailscale.com/kb/1241/tailscale-up
|
||||
#list flags ''
|
||||
# Provide the base URL of a custom server instead of https://controlplane.tailscale.com
|
||||
#option login_server ''
|
||||
# Set auth Key of custom server
|
||||
#option authkey ''
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
tailscale_enable="$(uci get tailscale.settings.enabled)"
|
||||
|
||||
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
|
||||
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0
|
||||
[ "$tailscale_enable" -eq "1" ] || exit 0
|
||||
/etc/init.d/tailscale start > /tmp/tailscale.log 2>&1 &
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
PROG=/usr/sbin/tailscale_helper
|
||||
PROGD=/usr/sbin/tailscaled
|
||||
CONFIG_PATH=/var/lib/tailscale
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "tailscale"
|
||||
procd_add_interface_trigger "interface.*.up" wan /etc/init.d/tailscale reload
|
||||
}
|
||||
|
||||
section_enabled() {
|
||||
config_get_bool enabled "$1" 'enabled' 0
|
||||
[ $enabled -gt 0 ]
|
||||
}
|
||||
|
||||
tailscale_helper() {
|
||||
local cfg="$1"
|
||||
local accept_routes hostname accept_dns advertise_exit_node exit_node advertise_routes disable_snat_subnet_routes subnet_routes access flags login_server authkey std_out std_err
|
||||
|
||||
config_get_bool accept_routes $cfg 'accept_routes'
|
||||
config_get hostname $cfg 'hostname'
|
||||
config_get_bool accept_dns $cfg 'accept_dns'
|
||||
config_get_bool advertise_exit_node $cfg 'advertise_exit_node'
|
||||
config_get exit_node $cfg 'exit_node'
|
||||
config_get advertise_routes $cfg 'advertise_routes'
|
||||
config_get_bool disable_snat_subnet_routes $cfg 'disable_snat_subnet_routes'
|
||||
config_get subnet_routes $cfg 'subnet_routes'
|
||||
config_get access $cfg 'access'
|
||||
config_get flags $cfg 'flags'
|
||||
config_get login_server $cfg 'login_server'
|
||||
config_get authkey $cfg 'authkey'
|
||||
config_get_bool std_out $cfg 'log_stdout'
|
||||
config_get_bool std_err $cfg 'log_stderr'
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG
|
||||
|
||||
[ "$accept_routes" = "1" ] && procd_append_param command --accept-routes=true
|
||||
[ -n "$hostname" ] && procd_append_param command --hostname="$hostname"
|
||||
[ "$accept_dns" = "0" ] && procd_append_param command --accept-dns=false
|
||||
[ "$advertise_exit_node" = "1" ] && procd_append_param command --advertise-exit-node
|
||||
[ -n "$exit_node" ] && {
|
||||
procd_append_param command --exit-node="$exit_node"
|
||||
procd_append_param command --exit-node-allow-lan-access=true
|
||||
}
|
||||
[ -n "$advertise_routes" ] && procd_append_param command --advertise-routes="$(echo $advertise_routes | tr ' ' ',')"
|
||||
[ "$disable_snat_subnet_routes" = "1" ] && procd_append_param command --snat-subnet-routes=false
|
||||
[ -n "$flags" ] && procd_append_param command $flags
|
||||
[ -n "$login_server" ] && procd_append_param command --login-server="$login_server"
|
||||
[ -n "$authkey" ] && procd_append_param command --authkey="$authkey"
|
||||
|
||||
procd_set_param env \
|
||||
ACCEPT_DNS="$accept_dns" \
|
||||
EXIT_NODE="$exit_node" \
|
||||
SUBNET_ROUTES="$subnet_routes" \
|
||||
ACCESS="$access"
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout "$std_out"
|
||||
procd_set_param stderr "$std_err"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local port config_path fw_mode std_out std_err state_file
|
||||
|
||||
if ! section_enabled "$cfg"; then
|
||||
echo "disabled in /etc/config/tailscale"
|
||||
return 1
|
||||
fi
|
||||
|
||||
config_get port $cfg 'port'
|
||||
config_get config_path $cfg 'config_path'
|
||||
config_get fw_mode $cfg 'fw_mode'
|
||||
config_get_bool std_out $cfg 'log_stdout'
|
||||
config_get_bool std_err $cfg 'log_stderr'
|
||||
|
||||
[ -d $config_path ] || mkdir -p $config_path
|
||||
[ -d $CONFIG_PATH ] || mkdir -p $CONFIG_PATH
|
||||
state_file="$config_path/tailscaled.state"
|
||||
|
||||
/usr/sbin/tailscaled --cleanup
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $PROGD
|
||||
|
||||
[ -n "$port" ] && procd_append_param command --port "$port"
|
||||
[ -n "$state_file" ] && procd_append_param command --state "$state_file"
|
||||
|
||||
procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode"
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout "$std_out"
|
||||
procd_set_param stderr "$std_err"
|
||||
procd_close_instance
|
||||
|
||||
tailscale_helper "$cfg"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load 'tailscale'
|
||||
config_foreach start_instance 'tailscale'
|
||||
}
|
||||
|
||||
stop_instance() {
|
||||
local cfg="$1"
|
||||
|
||||
# Remove dnsmasq settings
|
||||
MagicDNSSuffix=$(tailscale status --json | awk -F'"' '/"MagicDNSSuffix"/ {last=$(NF-1)} END {print last}')
|
||||
for suffix in $(uci show dhcp | grep -E "address=.*/${MagicDNSSuffix}/" | sed "s/'//g"); do
|
||||
uci -q del_list $suffix
|
||||
done
|
||||
|
||||
# Remove network settings
|
||||
uci -q delete network.tailscale
|
||||
uci -q delete network.ts_lan
|
||||
for route in $(uci show network | grep 'network.ts_subnet[0-9]\+=route' | grep -o 'network.ts_subnet[0-9]\+'); do
|
||||
uci -q delete $route
|
||||
done
|
||||
|
||||
# Remove firewall settings
|
||||
index=$(uci show firewall | grep "firewall.@forwarding\[[0-9]\+\]\.src='lan'" -B 1 -A 1 | grep "firewall.@forwarding\[[0-9]\+\]\.dest='wan'" | grep -o '[0-9]\+')
|
||||
uci -q delete firewall.@forwarding[$index].enabled
|
||||
uci -q delete firewall.tszone
|
||||
uci -q delete firewall.ts_ac_lan
|
||||
uci -q delete firewall.ts_ac_wan
|
||||
uci -q delete firewall.lan_ac_ts
|
||||
uci -q delete firewall.wan_ac_ts
|
||||
|
||||
# Commit configuration changes and reload service
|
||||
[ -n "$(uci changes dhcp)" ] && uci commit dhcp && /etc/init.d/dnsmasq reload
|
||||
[ -n "$(uci changes network)" ] && uci commit network && /etc/init.d/network reload
|
||||
[ -n "$(uci changes firewall)" ] && uci commit firewall && /etc/init.d/firewall reload
|
||||
|
||||
/usr/sbin/tailscaled --cleanup
|
||||
|
||||
# Remove existing link or folder
|
||||
rm -rf "$CONFIG_PATH"
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
config_load 'tailscale'
|
||||
config_foreach stop_instance 'tailscale'
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@tailscale[-1]
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
Reference in new issue
Block a user