use better tailscaled.service
Signed-off-by: Xe <me@christine.website>
This commit is contained in:
parent
286641b916
commit
dd50643eaf
25
main.go
25
main.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
_ "embed"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -17,7 +18,10 @@ import (
|
||||||
var (
|
var (
|
||||||
out = flag.String("out", ".", "where to save squashfs images to")
|
out = flag.String("out", ".", "where to save squashfs images to")
|
||||||
tsTarballPath = flag.String("tarball", "./var/tailscale_1.24.2_amd64.tgz", "path to tailscale tarball on disk")
|
tsTarballPath = flag.String("tarball", "./var/tailscale_1.24.2_amd64.tgz", "path to tailscale tarball on disk")
|
||||||
distro = flag.String("distro", "arch", "distro to stamp into system extension")
|
distro = flag.String("distro", "steamos", "distro to stamp into system extension")
|
||||||
|
|
||||||
|
//go:embed tailscaled.service
|
||||||
|
systemdService []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -64,8 +68,6 @@ func main() {
|
||||||
fname = filepath.Join(tmpDir, "usr", "bin", "tailscale")
|
fname = filepath.Join(tmpDir, "usr", "bin", "tailscale")
|
||||||
case "tailscaled":
|
case "tailscaled":
|
||||||
fname = filepath.Join(tmpDir, "usr", "sbin", "tailscaled")
|
fname = filepath.Join(tmpDir, "usr", "sbin", "tailscaled")
|
||||||
case "tailscaled.service":
|
|
||||||
fname = filepath.Join(tmpDir, "usr", "lib", "systemd", "system", "tailscaled.service")
|
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -80,6 +82,8 @@ func main() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fout.Chmod(0755)
|
||||||
|
|
||||||
err = fout.Close()
|
err = fout.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -99,6 +103,21 @@ func main() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fout, err = os.Create(filepath.Join(tmpDir, "usr", "lib", "systemd", "system", "tailscaled.service"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = fout.Write(systemdService)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = fout.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
binPath, err := exec.LookPath("mksquashfs")
|
binPath, err := exec.LookPath("mksquashfs")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Tailscale node agent
|
||||||
|
Documentation=https://tailscale.com/kb/
|
||||||
|
Wants=network-pre.target
|
||||||
|
After=network-pre.target NetworkManager.service systemd-resolved.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/sbin/tailscaled --cleanup
|
||||||
|
ExecStart=/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port 0
|
||||||
|
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
|
Loading…
Reference in New Issue