Skip to content

Instantly share code, notes, and snippets.

@lilac
Last active August 17, 2024 01:35
Show Gist options
  • Save lilac/5f1f75fa3dd17e33a135d65f082a9508 to your computer and use it in GitHub Desktop.
Save lilac/5f1f75fa3dd17e33a135d65f082a9508 to your computer and use it in GitHub Desktop.
Run tailscale on WDMyCloud

Install Tailscale

  1. Install go if it's not there.
  2. Install tailscale commands.
    go install tailscale.com/cmd/[email protected]
    go install tailscale.com/cmd/[email protected]
    

Install service

Since this linux is an old version, it still use sysv scripts for service management. To run tailscaled as a daemon (service), follow the procedure below.

  1. Copy the script to /etc/rc0.d/K20tailscaled. The script is mainly borrowed from this gist.
  2. Adjust the script as appropriate.
  3. Reboot the system via reboot.
  4. Check the service is started.
    1. By listing all services with service --status-all.
    2. Or check the status of this specific service with service tailscaled status. If it's alright, you should get the following output.
    [ ok ] tailscaled is running.

Start

After the daemon service is started, we can start tailscale using command like this.

tailscale up --auth-key ${TS_KEY} --advertise-routes=192.168.0.0/16
#!/bin/sh
### BEGIN INIT INFO
# Provides: tailscale
# Required-Start: $local_fs $all $network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Tailscale daemon
# Description: Runs the tailscale daemon.
### END INIT INFO
# Adjusted from https://gist.github.com/charles-l/a9d974ccafe4d9000ae5cb2a522617bc
# Source function library.
. /lib/lsb/init-functions
PIDFILE=/var/run/tailscale.pid
LOGFILE=/var/log/tailscale.log
TAILSCALED=/usr/sbin/tailscaled
fail_unless_root() {
if [ "$(id -u)" != '0' ]; then
log_failure_msg "must be run as root"
exit 1
fi
}
case "$1" in
start)
fail_unless_root
$TAILSCALED --cleanup
start-stop-daemon --start --background --no-close \
--exec $TAILSCALED \
--pidfile "$PIDFILE" \
--make-pidfile \
-- \
--state=/var/lib/tailscale/tailscaled.state \
--socket=/run/tailscale/tailscaled.sock >> $LOGFILE 2>&1
status=$?
log_end_msg $status
;;
stop)
fail_unless_root
start-stop-daemon --stop --pidfile "$PIDFILE" \
--retry 10
status=$?
log_end_msg $status
;;
status)
status_of_proc -p "$PIDFILE" "$TAILSCALED" "tailscaled"
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1 ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment