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 (
|
||||
"archive/tar"
|
||||
"compress/gzip"
|
||||
_ "embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -17,7 +18,10 @@ import (
|
|||
var (
|
||||
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")
|
||||
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() {
|
||||
|
@ -64,8 +68,6 @@ func main() {
|
|||
fname = filepath.Join(tmpDir, "usr", "bin", "tailscale")
|
||||
case "tailscaled":
|
||||
fname = filepath.Join(tmpDir, "usr", "sbin", "tailscaled")
|
||||
case "tailscaled.service":
|
||||
fname = filepath.Join(tmpDir, "usr", "lib", "systemd", "system", "tailscaled.service")
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
@ -80,6 +82,8 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fout.Chmod(0755)
|
||||
|
||||
err = fout.Close()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -99,6 +103,21 @@ func main() {
|
|||
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")
|
||||
if err != nil {
|
||||
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