The Tailscale Online Target is a systemd network-online.target
for Tailscale.
This makes it possible to add systemd dependencies on the Tailscale network.
This is based off of the post Mount share only if connected to Tailscale from the Tailscale Forum.
I’ve ported over the script to use Nushell and made it possible to add dependencies on specific devices being available on the Tailscale network.
These are the steps to install Tailscale, Nushell, and the Tailscale Online Target. These instructions are intended for Debian and Fedora Atomic systems.
-
Install just by following the instructions in the installation section.
-
Clone the repository.
git clone https://github.com/jwillikers/tailscale-online-target.git
-
Change to the repository’s directory.
cd tailscale-online-target
-
Install everything by running
just install
.just install
-
Bring Tailscale online. I use an exit node to route all traffic through Tailscale. Modify or omit the
--exit-node
flag as necessary.sudo tailscale up --exit-node=fd7a:115c:a1e0:ab12:4843:cd96:625f:e80c
-
Start the desired system timers. Here I start the global timer as well as a timer for a specific instance.
- System
-
sudo systemctl enable --now tailscale-dispatcher.timer tailscale-dispatcher@meerkat.timer
- User
-
systemctl --user enable --now tailscale-dispatcher.timer tailscale-dispatcher@meerkat.timer
-
Add a dependency on the specific
tailscale-online.target
as necessary for any systemd units.
Adding a dependency for filesystems is a bit more complicated than a regular systemd unit. The instructions here describe how to do add a dependency on the Tailscale Online Target for a filesystem, such as an NFS mount.
- fstab
-
In
/etc/fstab
, use thex-systemd.requires
mount option to specify the dependency as in the following example./etc/fstabnfs.jwillikers.io:/container-volumes /var/home/core/container-volumes nfs defaults,_netdev,context="system_u:object_r:container_file_t:s0",noatime,nodev,noexec,nofail,nosuid,soft,user,x-systemd.automount,x-systemd.idle-timeout=5min,x-systemd.mount-timeout=30s,x-systemd.requires=tailscale-online@rockpro64.target 0 0
- mount units
-
Add the dependency manually to systemd mount and automount units.
sudo systemctl edit var-home-core-Media.mount
/etc/systemd/system/var-home-core-Media.mount.d/override.conf[Unit] After=tailscale-online@rockpro64.target Requires=tailscale-online@rockpro64.target
sudo systemctl edit var-home-core-Media.automount
/etc/systemd/system/var-home-core-Media.automount.d/override.conf[Unit] After=tailscale-online@rockpro64.target Requires=tailscale-online@rockpro64.target
The project’s Code of Conduct is available in the Code of Conduct file.