mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-23 09:21:41 +00:00
control/controlclient, version/distro, wgengine: recognize OpenWrt
And help out with missing packages. Thanks to @willangley for tips. Updates #724
This commit is contained in:
parent
ec95e901e6
commit
5d8b88be88
@ -26,8 +26,11 @@ func init() {
|
|||||||
func osVersionLinux() string {
|
func osVersionLinux() string {
|
||||||
dist := distro.Get()
|
dist := distro.Get()
|
||||||
propFile := "/etc/os-release"
|
propFile := "/etc/os-release"
|
||||||
if dist == distro.Synology {
|
switch dist {
|
||||||
|
case distro.Synology:
|
||||||
propFile = "/etc.defaults/VERSION"
|
propFile = "/etc.defaults/VERSION"
|
||||||
|
case distro.OpenWrt:
|
||||||
|
propFile = "/etc/openwrt_release"
|
||||||
}
|
}
|
||||||
|
|
||||||
m := map[string]string{}
|
m := map[string]string{}
|
||||||
@ -36,7 +39,7 @@ func osVersionLinux() string {
|
|||||||
if eq == -1 {
|
if eq == -1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
k, v := string(line[:eq]), strings.Trim(string(line[eq+1:]), `"`)
|
k, v := string(line[:eq]), strings.Trim(string(line[eq+1:]), `"'`)
|
||||||
m[k] = v
|
m[k] = v
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -78,8 +81,11 @@ func osVersionLinux() string {
|
|||||||
return fmt.Sprintf("%s%s", v, attr)
|
return fmt.Sprintf("%s%s", v, attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dist == distro.Synology {
|
switch dist {
|
||||||
|
case distro.Synology:
|
||||||
return fmt.Sprintf("Synology %s%s", m["productversion"], attr)
|
return fmt.Sprintf("Synology %s%s", m["productversion"], attr)
|
||||||
|
case distro.OpenWrt:
|
||||||
|
return fmt.Sprintf("OpenWrt %s%s", m["DISTRIB_RELEASE"], attr)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Other%s", attr)
|
return fmt.Sprintf("Other%s", attr)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ const (
|
|||||||
Debian = Distro("debian")
|
Debian = Distro("debian")
|
||||||
Arch = Distro("arch")
|
Arch = Distro("arch")
|
||||||
Synology = Distro("synology")
|
Synology = Distro("synology")
|
||||||
|
OpenWrt = Distro("openwrt")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get returns the current distro, or the empty string if unknown.
|
// Get returns the current distro, or the empty string if unknown.
|
||||||
@ -36,5 +37,8 @@ func linuxDistro() Distro {
|
|||||||
if _, err := os.Stat("/etc/arch-release"); err == nil {
|
if _, err := os.Stat("/etc/arch-release"); err == nil {
|
||||||
return Arch
|
return Arch
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat("/etc/openwrt_version"); err == nil {
|
||||||
|
return OpenWrt
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -1272,5 +1272,16 @@ func diagnoseLinuxTUNFailure(logf logger.Logf) {
|
|||||||
if !bytes.Contains(findOut, kernel) {
|
if !bytes.Contains(findOut, kernel) {
|
||||||
logf("kernel/drivers/net/tun.ko found on disk, but not for current kernel; are you in middle of a system update and haven't rebooted? found: %s", findOut)
|
logf("kernel/drivers/net/tun.ko found on disk, but not for current kernel; are you in middle of a system update and haven't rebooted? found: %s", findOut)
|
||||||
}
|
}
|
||||||
|
case distro.OpenWrt:
|
||||||
|
out, err := exec.Command("opkg", "list-installed").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
logf("error querying OpenWrt installed packages: %s", out)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, pkg := range []string{"kmod-tun", "ca-bundle"} {
|
||||||
|
if !bytes.Contains(out, []byte(pkg+" - ")) {
|
||||||
|
logf("Missing required package %s; run: opkg install %s", pkg, pkg)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user