diff --git a/override.conf b/override.conf new file mode 100644 index 0000000..6b0d2a1 --- /dev/null +++ b/override.conf @@ -0,0 +1,2 @@ +[Service] +ExtensionDirectories=/var/lib/extensions/tailscale \ No newline at end of file diff --git a/readme.md b/readme.md index 7a50f64..24631d3 100644 --- a/readme.md +++ b/readme.md @@ -13,10 +13,9 @@ connect through the standard SSH server instead. Suggestions for how to fix this are welcomed. 1. Clone this repo to your Deck. -2. Copy the `tailscaled.service` file to `/etc/systemd/system/`. -3. Run `sudo bash tailscale.sh` to install Tailscale (or update the existing +2. Run `sudo bash tailscale.sh` to install Tailscale (or update the existing installation). -4. Run `sudo tailscale up --qr --operator=deck --ssh` to have Tailscale generate +3. Run `sudo tailscale up --qr --operator=deck --ssh` to have Tailscale generate a login QR code. Scan the code with your phone and authenticate with Tailscale to bring your Deck onto your network. diff --git a/tailscale.sh b/tailscale.sh index f8b025f..d86d66e 100644 --- a/tailscale.sh +++ b/tailscale.sh @@ -53,13 +53,27 @@ mkdir -p /var/lib/extensions rm -rf /var/lib/extensions/tailscale cp -rf tailscale /var/lib/extensions/ +# copy the systemd files into place +cp -rf $tar_dir/systemd/tailscaled.service /etc/systemd/system + +# copy in the defaults file if it doesn't already exist +if ! test -f /etc/default/tailscaled; then + cp -rf $tar_dir/systemd/tailscaled.defaults /etc/default/tailscaled +fi + # return to our original directory (silently) and clean up popd > /dev/null rm -rf "${dir}" +# copy in our overrides file if it doesn't already exist +if ! test -f /etc/systemd/system/tailscaled.service.d/override.conf; then + mkdir -p /etc/systemd/system/tailscaled.service.d + cp -rf override.conf /etc/systemd/system/tailscaled.service.d/override.conf +fi + echo "done." -echo -n "Starting services..." +echo "Starting services..." if systemctl is-enabled --quiet systemd-sysext && systemctl is-active --quiet systemd-sysext; then echo "systemd-sysext is already enabled and active" @@ -71,12 +85,10 @@ systemd-sysext refresh > /dev/null 2>&1 systemctl daemon-reload > /dev/null if systemctl is-enabled --quiet tailscaled && systemctl is-active --quiet tailscaled; then - echo "tailscaled is already enabled and active" + echo "tailscaled is already enabled and active; restarting it..." + systemctl restart tailscaled else systemctl enable tailscaled --now fi -echo "done." - - -echo "If updating, reboot or run the following to finish the process: sudo systemctl restart tailscaled" +echo "Tailscale installed and ready." diff --git a/tailscaled.service b/tailscaled.service deleted file mode 100644 index 3f29e88..0000000 --- a/tailscaled.service +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=Tailscale node agent -Documentation=https://tailscale.com/kb/ -Wants=network-pre.target -After=network-pre.target NetworkManager.service systemd-resolved.service - -[Service] -ExtensionDirectories=/var/lib/extensions/tailscale - -ExecStartPre=/usr/sbin/tailscaled --cleanup -ExecStart=/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock -ExecStopPost=/usr/sbin/tailscaled --cleanup - -Restart=on-failure - -RuntimeDirectory=tailscale -RuntimeDirectoryMode=0755 -StateDirectory=tailscale -StateDirectoryMode=0700 -CacheDirectory=tailscale -CacheDirectoryMode=0750 -Type=notify - -[Install] -WantedBy=multi-user.target \ No newline at end of file