diff --git a/kvmapp/system/init.d/S98tailscaled b/kvmapp/system/init.d/S98tailscaled index 3c34d64..e745f8a 100755 --- a/kvmapp/system/init.d/S98tailscaled +++ b/kvmapp/system/init.d/S98tailscaled @@ -21,18 +21,25 @@ PKG_URL_LATEST="https://pkgs.tailscale.com/stable/tailscale_latest_riscv64.tgz" exit 1 VERSION=$(/usr/sbin/$DAEMON --version|sed -n '1p'|xargs echo -n) -[ -x /usr/bin/tailscale ] || echo "/usr/bin/tailscale not found, your installation of tailscale may be broken" +[ -x /usr/bin/tailscale ] || + (echo "/usr/bin/tailscale not found, your installation of tailscale may be broken" && exit 1) -# just for those need forwarding -[ ! -f /etc/sysctl.d/99-tailscale.conf ] && - mkdir -p /etc/sysctl.d/ && - echo "missing /etc/sysctl.d/99-tailscale.conf, try make it below:" && - (tee /etc/sysctl.d/99-tailscale.conf </dev/null 2>&1 + sysctl -w net.ipv6.conf.all.forwarding=0 >/dev/null 2>&1 + echo "Cleanup completed. IPv4/IPv6 forwarding disabled." + + # Trigger IPv6 address renewal on all interfaces + for iface in $(ls /sys/class/net/ | grep -v lo); do + echo 0 > /proc/sys/net/ipv6/conf/$iface/forwarding 2>/dev/null + sysctl -w net.ipv6.conf.$iface.accept_ra=2 >/dev/null 2>&1 + done + + echo "If you need exit node features, please configure manually." +fi case "$1" in start) @@ -40,10 +47,14 @@ case "$1" in value=$(cat /etc/kvm/GOMEMLIMIT) export GOMEMLIMIT="${value}MiB" else - export GOMEMLIMIT=1024MiB + export GOMEMLIMIT=512MiB fi - + echo "GOMEMLIMIT set to ${GOMEMLIMIT}" + + # Ensure directories exist + mkdir -p /var/lib/tailscale /var/run/tailscale + printf "Starting $DAEMON[$VERSION]: " start-stop-daemon -S -bmq -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- \ --state=/var/lib/tailscale/tailscaled.state \ @@ -51,67 +62,25 @@ case "$1" in --port=${PORT} \ $FLAGS if [ $? = 0 ]; then - echo "OK" - tailscale set --accept-dns=false - # example to make your nanoKVM an exit node - # tailscale set --advertise-exit-node --advertise-routes=192.168.0.0/16 - else - echo "FAIL" - fi + sleep 5 + echo "OK" + tailscale set --accept-dns=false + else + echo "FAIL" + fi ;; stop) printf "Stopping $DAEMON: " start-stop-daemon -K -p "$PIDFILE" [ $? = 0 ] && (echo "OK"; rm -f "$PIDFILE") || echo "FAIL" printf "cleaning tailscaled: " - /usr/sbin/$DAEMON --cleanup &>/dev/null + /usr/sbin/$DAEMON --cleanup >/dev/null 2>&1 [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart|reload) $0 stop $0 start ;; - doc) - cat <