diff --git a/README.md b/README.md index bf49f32..cc93f31 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Install scripts for getting [Tailscale](https://tailscale.com) running on Kobo e ## Supported devices - *Kobo Libra 2* +- *Koba Libra Colour*/*Koba Libra Color* Currently only the Libra 2 is supported as it is the only device I have access to. If you have another device and would like to contribute, please open a PR! @@ -26,4 +27,4 @@ which can cause issues on Kobo devices. If you find that DNS breaks after a whil ## Acknowledgements [Dylan Staley for initial work and scripts on the Kobo Sage](https://dstaley.com/posts/tailscale-on-kobo-sage) -[jmacindoe for documenting kernel module compilation on Kobo readers](https://github.com/jmacindoe/kobo-kernel-modules) \ No newline at end of file +[jmacindoe for documenting kernel module compilation on Kobo readers](https://github.com/jmacindoe/kobo-kernel-modules) diff --git a/libra-color/README.md b/libra-color/README.md new file mode 100644 index 0000000..8c79969 --- /dev/null +++ b/libra-color/README.md @@ -0,0 +1,13 @@ +# Kobo Libra Color + +## Modules +Tailscale requires the TUN/TAP device driver to be loaded to function. +This is included in the Libra Color kernel though + +# iptables +Tailscale requires the `iptables` binary and shared libraries to be present on the device to function. +These are not included in the stock Kobo Libra Color image so this repo provides it as +pre-built binaries/libraries in the `binaries` directory. + +This was pulled from the [July 5th 2017 build of Raspbian](http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-07-05) +which also bundles the source code. This was done to match the glibc version used in the Libra Color image. diff --git a/libra-color/binaries/iptables/lib/libip4tc.so.0.1.0 b/libra-color/binaries/iptables/lib/libip4tc.so.0.1.0 new file mode 100755 index 0000000..726d0b6 Binary files /dev/null and b/libra-color/binaries/iptables/lib/libip4tc.so.0.1.0 differ diff --git a/libra-color/binaries/iptables/lib/libip6tc.so.0.1.0 b/libra-color/binaries/iptables/lib/libip6tc.so.0.1.0 new file mode 100755 index 0000000..c8b84f9 Binary files /dev/null and b/libra-color/binaries/iptables/lib/libip6tc.so.0.1.0 differ diff --git a/libra-color/binaries/iptables/lib/libxtables.so.10.0.0 b/libra-color/binaries/iptables/lib/libxtables.so.10.0.0 new file mode 100755 index 0000000..7072bf2 Binary files /dev/null and b/libra-color/binaries/iptables/lib/libxtables.so.10.0.0 differ diff --git a/libra-color/binaries/iptables/sbin/xtables-multi b/libra-color/binaries/iptables/sbin/xtables-multi new file mode 100755 index 0000000..8e29b55 Binary files /dev/null and b/libra-color/binaries/iptables/sbin/xtables-multi differ diff --git a/libra-color/install-tailscale.sh b/libra-color/install-tailscale.sh new file mode 100755 index 0000000..6389a96 --- /dev/null +++ b/libra-color/install-tailscale.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +set -e + +# Set what version of tailscale you would like to install here. +# You can find the latest version at https://pkgs.tailscale.com/stable/#static +export TAILSCALE_VERSION=1.68.2 + +echo +echo "Installing tailscale ${TAILSCALE_VERSION} for Kobo Libra Color!" +uname -a +echo + +echo "Installing iptables into /sbin and /lib ..." +cp binaries/iptables/sbin/* /sbin +cp binaries/iptables/lib/* /lib + +ln -sf /sbin/xtables-multi /sbin/iptables +ln -sf /lib/libxtables.so.10.0.0 /lib/libxtables.so.10 +ln -sf /lib/libip4tc.so.0.1.0 /lib/libip4tc.so.0 +ln -sf /lib/libip6tc.so.0.1.0 /lib/libip6tc.so.0 + +echo "Downloading tailscale_${TAILSCALE_VERSION}_arm.tgz from pkgs.tailscale.com ..." +wget https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_arm.tgz +tar -xvf tailscale_${TAILSCALE_VERSION}_arm.tgz + +echo "Installing tailscale binaries into /mnt/onboard/tailscale and symlinking them into /usr/bin ..." +mkdir -p /mnt/onboard/tailscale +mv tailscale_${TAILSCALE_VERSION}_arm/tailscale /mnt/onboard/tailscale +mv tailscale_${TAILSCALE_VERSION}_arm/tailscaled /mnt/onboard/tailscale + +# Symlink tailscale binaries to /usr/bin +ln -sf /mnt/onboard/tailscale/tailscale /usr/bin/tailscale +ln -sf /mnt/onboard/tailscale/tailscaled /usr/bin/tailscaled + +echo "Cleaning up tarball ..." +rm -rf tailscale_${TAILSCALE_VERSION}_arm +rm -rf tailscale_${TAILSCALE_VERSION}_arm.tgz + +echo "Installing tailscale boot and load scripts into /usr/local/tailscale ..." +mkdir -p /usr/local/tailscale +cp scripts/* /usr/local/tailscale + +echo "Installing tailscale udev rule into /etc/udev/rules.d ..." +cp rules/* /etc/udev/rules.d + +echo +echo "Installation complete! Attempting to boot tailscale daemon ..." +/usr/local/tailscale/boot.sh +echo + +echo "If no errors were reported, tailscale should be installed!" +echo "You can now configure tailscale by running 'tailscale up' and following the instructions." +echo "The tailscale binaries are located in /mnt/onboard/tailscale." +echo diff --git a/libra-color/rules/98-tailscale.rules b/libra-color/rules/98-tailscale.rules new file mode 100644 index 0000000..7dfb916 --- /dev/null +++ b/libra-color/rules/98-tailscale.rules @@ -0,0 +1,3 @@ +KERNEL=="loop0", RUN+="/bin/sh -c '/usr/local/tailscale/boot.sh'" +KERNEL=="wlan*", ACTION=="add", RUN+="/bin/sh -c '/usr/local/tailscale/on-wlan-up.sh'" +KERNEL=="wlan*", ACTION=="remove", RUN+="/bin/sh -c '/usr/local/tailscale/on-wlan-down.sh'" \ No newline at end of file diff --git a/libra-color/scripts/boot.sh b/libra-color/scripts/boot.sh new file mode 100755 index 0000000..12931d1 --- /dev/null +++ b/libra-color/scripts/boot.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Start by renicing ourselves to a neutral value, to avoid any mishap... +renice 0 -p $$ + +# Launch in the background, with a clean env, after a setsid call to make very very sure udev won't kill us ;). +env -i -- setsid /usr/local/tailscale/on-boot.sh & + +# Done :) +exit 0 \ No newline at end of file diff --git a/libra-color/scripts/on-boot.sh b/libra-color/scripts/on-boot.sh new file mode 100755 index 0000000..4f26f98 --- /dev/null +++ b/libra-color/scripts/on-boot.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# Make sure to load the TUN kernel module and create the /dev/net/tun device +if [ ! -c /dev/net/tun ]; then + mkdir -p /dev/net + mknod /dev/net/tun c 10 200 +fi + +# Make absolutely sure that iptables is in the PATH +export PATH=/usr/sbin:/usr/bin:$PATH + +# Make sure /mnt/onboard is mounted +timeout 5 sh -c "while ! grep -q /mnt/onboard /proc/mounts; do sleep 0.1; done" +if [[ $? -eq 143 ]]; then + exit 1 +fi + +case "$(pidof tailscaled | wc -w)" in +0) tailscaled --statedir=/mnt/onboard/tailscale &> /tailscaled.log & + ;; +esac + +exit 0 diff --git a/libra-color/scripts/on-wlan-down.sh b/libra-color/scripts/on-wlan-down.sh new file mode 100755 index 0000000..bffdade --- /dev/null +++ b/libra-color/scripts/on-wlan-down.sh @@ -0,0 +1,2 @@ +#!/bin/sh +tailscale down \ No newline at end of file diff --git a/libra-color/scripts/on-wlan-up.sh b/libra-color/scripts/on-wlan-up.sh new file mode 100755 index 0000000..e27b4c8 --- /dev/null +++ b/libra-color/scripts/on-wlan-up.sh @@ -0,0 +1,2 @@ +#!/bin/sh +tailscale up \ No newline at end of file diff --git a/libra-color/uninstall-tailscale.sh b/libra-color/uninstall-tailscale.sh new file mode 100644 index 0000000..165601c --- /dev/null +++ b/libra-color/uninstall-tailscale.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +echo "Uninstalling tailscale..." + +pid=$(pgrep tailscaled) +if [ -n "$pid" ]; then + echo "Terminating tailscale daemon with PID $pid ..." + kill -15 "$pid" + + # Wait a little bit for the daemon to terminate cleanly. + sleep 3 + + echo "Tailscale daemon terminated successfully." +fi + +echo "Removing iptables binaries from /sbin and /lib ..." +rm -f /sbin/xtables-multi /sbin/iptables +rm -f /lib/libxtables.so.10 /lib/libip4tc.so.0 /lib/libip6tc.so.0 + +echo "Removing tailscale binaries from /mnt/onboard/tailscale and /usr/bin ..." +rm -rf /mnt/onboard/tailscale +rm -f /usr/bin/tailscale /usr/bin/tailscaled + +echo "Removing tailscale boot and load scripts from /usr/local/tailscale ..." +rm -rf /usr/local/tailscale + +echo "Removing tailscale udev rule from /etc/udev/rules.d ..." +rm -f /etc/udev/rules.d/99-tailscale.rules + +echo "Uninstallation complete!"