更新文案描述

This commit is contained in:
CallMeR
2026-08-14 17:42:30 +08:00
parent a7bf1b06eb
commit abccbcad01
8 changed files with 144 additions and 126 deletions
+28 -20
View File
@@ -4,29 +4,37 @@
# Optimize NIC offload parameters for local TS server.
#
ETHTOOL_PATH=$(command -v ethtool)
if [ -z "${IFACE:-}" ]; then
echo "Error: IFACE is not set." >&2
exit 1
fi
if [ -z "${AdministrativeState:-}" ]; then
echo "Error: AdministrativeState is not set for $IFACE." >&2
exit 1
fi
if [ "$AdministrativeState" != "configured" ]; then
echo "Skipping network device $IFACE: administrative state is $AdministrativeState."
exit 0
fi
if [ ! -e "/sys/class/net/$IFACE/device" ]; then
echo "Skipping network device $IFACE: no hardware device is associated."
exit 0
fi
ETHTOOL_PATH=$(command -v ethtool 2>/dev/null)
if [ -z "$ETHTOOL_PATH" ]; then
echo "Error: ethtool command not found. Please install ethtool."
exit 1
echo "Error: ethtool command not found in PATH. Please install ethtool." >&2
exit 127
fi
NETDEV=$(ip route show default | awk '{for (i=1; i<=NF; i++) {if ($i == "dev") {print $(i+1); exit;}}}')
if [ -z "$NETDEV" ]; then
echo "Error: Could not determine default network device using 'ip route show default'."
exit 1
fi
echo "Configuring network device $NETDEV using $ETHTOOL_PATH for Tailscale optimizations..."
"$ETHTOOL_PATH" -K "$NETDEV" rx-udp-gro-forwarding on rx-gro-list off
if [ "$?" -eq 0 ]; then
echo "Configuration successful for $NETDEV."
exit 0
if "$ETHTOOL_PATH" -K "$IFACE" rx-udp-gro-forwarding on rx-gro-list off; then
echo "Configured network device $IFACE using $ETHTOOL_PATH successfully."
else
echo "Error: ethtool configuration failed. Check permissions or device status."
exit 1
exit_status=$?
echo "Error: $ETHTOOL_PATH failed to configure network device $IFACE (exit status $exit_status)." >&2
exit "$exit_status"
fi
@@ -1,16 +0,0 @@
[Unit]
Description=Tailscale NIC Offload Optimization
ConditionVirtualization=!container
After=network-online.target
Wants=network-online.target
Before=tailscaled.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/tailscale-nic-optim
RemainAfterExit=yes
StandardOutput=journal
[Install]
WantedBy=multi-user.target