How to Create an Init Script for Tailscaled in Linux

Siva
2 min readApr 26, 2023

If you are using a Linux distribution that does not use Systemd, you may need to create an init script to manage Tailscaled, the network daemon for the Tailscale VPN.

Here are the steps to create an init script for Tailscaled:

Step 1:

Determine the location of the Tailscaled binary The Tailscaled binary is typically installed in /usr/bin/tailscaled. Use the which command to determine the location of the tailscaled binary:

which tailscaled

If tailscaled is not in your PATH, you may need to provide the full path to the binary in your init script.

Step 2:

Create the init script Create a new file in the /etc/init.d directory with a name that reflects the purpose of the script. In this case, tailscaled would be a good name:

sudo nano /etc/init.d/tailscaled

Add the following script to the tailscaled file:

#!/bin/sh
### BEGIN INIT INFO
# Provides: tailscaled
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tailscaled daemon
# Description: tailscaled daemon
### END INIT INFO

DAEMON=/sbin/tailscaled
PIDFILE=/var/run/tailscaled.pid
USER=tailscale
GROUP=tailscale
test -x $DAEMON || exit 0
case "$1" in
start)
echo "Starting Tailscaled"…

--

--