MCPcopy Create free account
hub / github.com/tailscale/tailscale / getUpdateFunction

Method getUpdateFunction

clientupdate/clientupdate.go:178–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176type updateFunction func() error
177
178func (up *Updater) getUpdateFunction() (fn updateFunction, canAutoUpdate bool) {
179 hi := hostinfo.New()
180 // We don't know how to update custom tsnet binaries, it's up to the user.
181 if hi.Package == "tsnet" {
182 return nil, false
183 }
184
185 switch runtime.GOOS {
186 case "windows":
187 return up.updateWindows, true
188 case "linux":
189 switch distro.Get() {
190 case distro.NixOS:
191 // NixOS packages are immutable and managed with a system-wide
192 // configuration.
193 return up.updateNixos, false
194 case distro.Synology:
195 // Synology updates use our own pkgs.tailscale.com instead of the
196 // Synology Package Center. We should eventually get to a regular
197 // release cadence with Synology Package Center and use their
198 // auto-update mechanism.
199 return up.updateSynology, false
200 case distro.Debian: // includes Ubuntu
201 return up.updateDebLike, true
202 case distro.Arch:
203 if up.archPackageInstalled() {
204 // Arch update func just prints a message about how to update,
205 // it doesn't support auto-updates.
206 return up.updateArchLike, false
207 }
208 return up.updateLinuxBinary, true
209 case distro.Alpine:
210 return up.updateAlpineLike, true
211 case distro.Unraid:
212 return up.updateUnraid, true
213 case distro.QNAP:
214 return up.updateQNAP, true
215 }
216 switch {
217 case haveExecutable("pacman"):
218 if up.archPackageInstalled() {
219 // Arch update func just prints a message about how to update,
220 // it doesn't support auto-updates.
221 return up.updateArchLike, false
222 }
223 return up.updateLinuxBinary, true
224 case haveExecutable("apt-get"): // TODO(awly): add support for "apt"
225 // The distro.Debian switch case above should catch most apt-based
226 // systems, but add this fallback just in case.
227 return up.updateDebLike, true
228 case haveExecutable("dnf"):
229 return up.updateFedoraLike("dnf"), true
230 case haveExecutable("yum"):
231 return up.updateFedoraLike("yum"), true
232 case haveExecutable("apk"):
233 return up.updateAlpineLike, true
234 }
235 // If nothing matched, fall back to tarball updates.

Callers 2

NewUpdaterFunction · 0.95
canAutoUpdateUncachedFunction · 0.80

Calls 7

archPackageInstalledMethod · 0.95
updateFedoraLikeMethod · 0.95
NewFunction · 0.92
GetFunction · 0.92
IsMacAppStoreFunction · 0.92
IsMacSysExtFunction · 0.92
haveExecutableFunction · 0.85

Tested by

no test coverage detected