From a55d29aab972a6fe205a3b3db10e869bb032e613 Mon Sep 17 00:00:00 2001 From: Adyanth H <33192449+adyanth@users.noreply.github.com> Date: Mon, 18 Jan 2021 17:37:09 +0530 Subject: [PATCH] :tada: Initial commit --- etc/init.d/tailscale | 32 +++++++++++++++++++++++++++++++ etc/init.d/tailscale_enabler | 10 ++++++++++ tailscale_enabler_README.md | 37 ++++++++++++++++++++++++++++++++++++ usr/bin/tailscale | 1 + usr/bin/tailscale_enabler | 20 +++++++++++++++++++ usr/bin/tailscaled | 1 + 6 files changed, 101 insertions(+) create mode 100644 etc/init.d/tailscale create mode 100644 etc/init.d/tailscale_enabler create mode 100644 tailscale_enabler_README.md create mode 120000 usr/bin/tailscale create mode 100644 usr/bin/tailscale_enabler create mode 120000 usr/bin/tailscaled diff --git a/etc/init.d/tailscale b/etc/init.d/tailscale new file mode 100644 index 0000000..2fe6008 --- /dev/null +++ b/etc/init.d/tailscale @@ -0,0 +1,32 @@ +#!/bin/sh /etc/rc.common + +# Copyright 2020 Google LLC. +# SPDX-License-Identifier: Apache-2.0 + +USE_PROCD=1 +START=99 +STOP=1 + +start_service() { + procd_open_instance + procd_set_param command /usr/bin/tailscaled + + # Set the port to listen on for incoming VPN packets. + # Remote nodes will automatically be informed about the new port number, + # but you might want to configure this in order to set external firewall + # settings. + procd_append_param command --port 41641 + + # OpenWRT /var is a symlink to /tmp, so write persistent state elsewhere. + procd_append_param command --state /etc/tailscale/tailscaled.state + + procd_set_param respawn + procd_set_param stdout 1 + procd_set_param stderr 1 + + procd_close_instance +} + +stop_service() { + /usr/sbin/tailscaled --cleanup +} diff --git a/etc/init.d/tailscale_enabler b/etc/init.d/tailscale_enabler new file mode 100644 index 0000000..26a59d1 --- /dev/null +++ b/etc/init.d/tailscale_enabler @@ -0,0 +1,10 @@ +#!/bin/sh /etc/rc.common +USE_PROCD=1 +START=98 +STOP=01 +start_service() { + procd_open_instance + procd_set_param command /usr/bin/tailscale_enabler + procd_close_instance +} + diff --git a/tailscale_enabler_README.md b/tailscale_enabler_README.md new file mode 100644 index 0000000..440ddf4 --- /dev/null +++ b/tailscale_enabler_README.md @@ -0,0 +1,37 @@ +# Tailscale on OpenWRT + +1. Extract the contents of root to your filesystem root using: +``` +tar x -zvf tailscale_enabler.tgz -C / +``` + +2. Install the prerequisites for wget and tailscale using: +``` +opkg update +opkg install libustream-openssl ca-bundle kmod-tun +``` + +3. Run tailscale for the first time: +``` +tailscale_enabler +/etc/init.d/tailscale start +tailscale up --accept-dns=false --advertise-routes=10.0.0.0/24 +``` + +The tailscale_enabler will download the tailscale binaries to /tmp and tailscale will start the tailscale daemon. +The last command uses the tailscale CLI to configure the login and add some settings to prevent dns changes and advertise routes. Use the URL printed to login to tailscale. + +4. Enable tailscale at boot: +``` +/etc/init.d/tailscale_enabler enable +/etc/init.d/tailscale enable +``` + +Verify by looking for two entries here: +``` +ls /etc/rc.d/S*tailscale* +``` + +5. Reboot the router and verify that it shows up online on the [Tailscale Admin portal](https://login.tailscale.com/admin/machines). + +6. To update the version of tailscale, grab the latest version [here](https://pkgs.tailscale.com/stable/#static) of the form `1.2.10_mips` and replace the same in /usr/bin/tailscale_enabler: `version="1.2.10_mips"`. diff --git a/usr/bin/tailscale b/usr/bin/tailscale new file mode 120000 index 0000000..c5f9db1 --- /dev/null +++ b/usr/bin/tailscale @@ -0,0 +1 @@ +/tmp/tailscale \ No newline at end of file diff --git a/usr/bin/tailscale_enabler b/usr/bin/tailscale_enabler new file mode 100644 index 0000000..4fcef29 --- /dev/null +++ b/usr/bin/tailscale_enabler @@ -0,0 +1,20 @@ +#!/bin/sh + +version='1.2.10_mips' + +if [ ! -f /tmp/tailscaled ]; then + echo "Downloading Tailscale ${version} .." + + echo -e "tailscale_${version}/tailscale\ntailscale_${version}/tailscaled" > /tmp/tailscale_${version}_files.txt + + wget -O- https://pkgs.tailscale.com/stable/tailscale_${version}.tgz | tar x -zvf - -C /tmp -T /tmp/tailscale_${version}_files.txt + + mv /tmp/tailscale_$version/* /tmp + rm -rf /tmp/tailscale_${version}* + + echo "Done!" + +else + echo "Tailscale already exists!" + +fi diff --git a/usr/bin/tailscaled b/usr/bin/tailscaled new file mode 120000 index 0000000..7340992 --- /dev/null +++ b/usr/bin/tailscaled @@ -0,0 +1 @@ +/tmp/tailscaled \ No newline at end of file