Skip to content

Commit

Permalink
🎉 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adyanth committed Jan 18, 2021
0 parents commit a55d29a
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
32 changes: 32 additions & 0 deletions etc/init.d/tailscale
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions etc/init.d/tailscale_enabler
Original file line number Diff line number Diff line change
@@ -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
}

37 changes: 37 additions & 0 deletions tailscale_enabler_README.md
Original file line number Diff line number Diff line change
@@ -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"`.
1 change: 1 addition & 0 deletions usr/bin/tailscale
20 changes: 20 additions & 0 deletions usr/bin/tailscale_enabler
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions usr/bin/tailscaled

0 comments on commit a55d29a

Please sign in to comment.