I may necrobump, but this is actually the first topic coming in search so I wanted to share how I managed to setup tailscale manually based on qnap package (I think)
pkgs.tailscale.com/stable/#static
cd /root
#download
wget https://pkgs.tailscale.com/stable/tailscale_1.78.1_amd64.tgz
#extract
tar xvf tailscale_1.78.1_amd64.tgz
#rename for simplicity
mv tailscale_1.78.1_amd64 tailscale
cd tailscale
ln -s /root/tailscale/tailscaled /usr/sbin/tailscaled
create unit
vim /etc/init.d/tailscale
#!/bin/sh
SERVICE_NAME="tailscale"
PID_FILE="/var/run/tailscale/tailscaled.pid"
LOG_FILE="/var/run/tailscale/tailscaled.log"
STATE_FILE="/var/run/tailscale/tailscaled.state"
SOCKET_FILE="/var/run/tailscale/tailscaled.sock"
PORT="41641"
SERVICE_COMMAND="/usr/sbin/tailscaled \
--state=${STATE_FILE} \
--socket=${SOCKET_FILE} \
--port=$PORT"
start_daemon() {
local ts=$(date --iso-8601=second)
echo "${ts} Starting ${SERVICE_NAME} with: ${SERVICE_COMMAND}" >>${LOG_FILE}
${SERVICE_COMMAND} >>${LOG_FILE} 2>&1 &
if [ -n "${PID_FILE}" ]; then
echo "$!" >"${PID_FILE}"
else
wait_for_status 0
fi
}
stop_daemon() {
if [ -n "${PID_FILE}" -a -r "${PID_FILE}" ]; then
local PID=$(cat "${PID_FILE}")
local ts=$(date --iso-8601=second)
echo "${ts} Stopping ${SERVICE_NAME} service PID=${PID}" >>${LOG_FILE}
kill -TERM $PID >>${LOG_FILE} 2>&1
wait_for_status 1 || kill -KILL $PID >>${LOG_FILE} 2>&1
if [ -f "${PID_FILE}" ]; then
rm -f "${PID_FILE}" >/dev/null
fi
fi
}
daemon_status() {
if [ -n "${PID_FILE}" -a -r "${PID_FILE}" ]; then
if kill -0 $(cat "${PID_FILE}") >/dev/null 2>&1; then
return
fi
rm -f "${PID_FILE}" >/dev/null
fi
return 1
}
wait_for_status() {
# 20 tries
# sleeps for 1 second after each try
local counter=20
while [ ${counter} -gt 0 ]; do
daemon_status
[ $? -eq $1 ] && return
counter=$((counter - 1))
sleep 1
done
return 1
}
ensure_tun_created() {
# Create the necessary file structure for /dev/net/tun
if ([ ! -c /dev/net/tun ]); then
if ([ ! -d /dev/net ]); then
mkdir -m 755 /dev/net
fi
mknod /dev/net/tun c 10 200
chmod 0755 /dev/net/tun
fi
# Load the tun module if not already loaded
if (!(lsmod | grep -q "^tun\s")); then
insmod /lib/modules/tun.ko
fi
}
case $1 in
start)
if daemon_status; then
echo "${SERVICE_NAME} is already running"
exit 0
else
echo "Starting ${SERVICE_NAME} ..."
ensure_tun_created
start_daemon
exit $?
fi
;;
stop)
if daemon_status; then
echo "Stopping ${SERVICE_NAME} ..."
stop_daemon
exit $?
else
echo "${SERVICE_NAME} is not running"
exit 0
fi
;;
status)
if daemon_status; then
echo "${SERVICE_NAME} is running"
exit 0
else
echo "${SERVICE_NAME} is not running"
exit 3
fi
;;
log)
exit 0
;;
*)
echo "command $1 is not implemented"
exit 0
;;
esac
start unit
/etc/init.d/tailscale start
authenticate
./root/tailscale/tailscale