F-urkan commited on
Commit
323791d
·
verified ·
1 Parent(s): 71874b1

Update install.sh

Browse files
Files changed (1) hide show
  1. install.sh +721 -0
install.sh CHANGED
@@ -0,0 +1,721 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # Copyright (c) Tailscale Inc & AUTHORS
3
+ # SPDX-License-Identifier: BSD-3-Clause
4
+ #
5
+ # This script detects the current operating system, and installs
6
+ # Tailscale according to that OS's conventions.
7
+ #
8
+ # Environment variables:
9
+ # TRACK: Set to "stable" or "unstable" (default: stable)
10
+ # TAILSCALE_VERSION: Pin to a specific version (e.g., "1.88.4")
11
+ #
12
+ # Examples:
13
+ # curl -fsSL https://tailscale.com/install.sh | sh
14
+ # curl -fsSL https://tailscale.com/install.sh | TAILSCALE_VERSION=1.88.4 sh
15
+ # curl -fsSL https://tailscale.com/install.sh | TRACK=unstable sh
16
+
17
+ set -eu
18
+
19
+ # All the code is wrapped in a main function that gets called at the
20
+ # bottom of the file, so that a truncated partial download doesn't end
21
+ # up executing half a script.
22
+ main() {
23
+ # Step 1: detect the current linux distro, version, and packaging system.
24
+ #
25
+ # We rely on a combination of 'uname' and /etc/os-release to find
26
+ # an OS name and version, and from there work out what
27
+ # installation method we should be using.
28
+ #
29
+ # The end result of this step is that the following three
30
+ # variables are populated, if detection was successful.
31
+ OS=""
32
+ VERSION=""
33
+ PACKAGETYPE=""
34
+ APT_KEY_TYPE="" # Only for apt-based distros
35
+ APT_SYSTEMCTL_START=false # Only needs to be true for Kali
36
+ TRACK="${TRACK:-stable}"
37
+ TAILSCALE_VERSION="${TAILSCALE_VERSION:-}"
38
+
39
+ case "$TRACK" in
40
+ stable|unstable)
41
+ ;;
42
+ *)
43
+ echo "unsupported track $TRACK"
44
+ exit 1
45
+ ;;
46
+ esac
47
+
48
+ if [ -f /etc/os-release ]; then
49
+ # /etc/os-release populates a number of shell variables. We care about the following:
50
+ # - ID: the short name of the OS (e.g. "debian", "freebsd")
51
+ # - VERSION_ID: the numeric release version for the OS, if any (e.g. "18.04")
52
+ # - VERSION_CODENAME: the codename of the OS release, if any (e.g. "buster")
53
+ # - UBUNTU_CODENAME: if it exists, use instead of VERSION_CODENAME
54
+ . /etc/os-release
55
+ VERSION_MAJOR="${VERSION_ID:-}"
56
+ VERSION_MAJOR="${VERSION_MAJOR%%.*}"
57
+ case "$ID" in
58
+ ubuntu|pop|neon|zorin|tuxedo)
59
+ OS="ubuntu"
60
+ if [ "${UBUNTU_CODENAME:-}" != "" ]; then
61
+ VERSION="$UBUNTU_CODENAME"
62
+ else
63
+ VERSION="$VERSION_CODENAME"
64
+ fi
65
+ PACKAGETYPE="apt"
66
+ # Third-party keyrings became the preferred method of
67
+ # installation in Ubuntu 20.04.
68
+ if [ "$VERSION_MAJOR" -lt 20 ]; then
69
+ APT_KEY_TYPE="legacy"
70
+ else
71
+ APT_KEY_TYPE="keyring"
72
+ fi
73
+ ;;
74
+ debian)
75
+ OS="$ID"
76
+ VERSION="$VERSION_CODENAME"
77
+ PACKAGETYPE="apt"
78
+ # Third-party keyrings became the preferred method of
79
+ # installation in Debian 11 (Bullseye).
80
+ if [ -z "${VERSION_ID:-}" ]; then
81
+ # rolling release. If you haven't kept current, that's on you.
82
+ APT_KEY_TYPE="keyring"
83
+ # Parrot Security is a special case that uses ID=debian
84
+ elif [ "$NAME" = "Parrot Security" ]; then
85
+ # All versions new enough to have this behaviour prefer keyring
86
+ # and their VERSION_ID is not consistent with Debian.
87
+ APT_KEY_TYPE="keyring"
88
+ # They don't specify the Debian version they're based off in os-release
89
+ # but Parrot 6 is based on Debian 12 Bookworm.
90
+ VERSION=bookworm
91
+ elif [ "$VERSION_MAJOR" -lt 11 ]; then
92
+ APT_KEY_TYPE="legacy"
93
+ else
94
+ APT_KEY_TYPE="keyring"
95
+ fi
96
+ ;;
97
+ linuxmint)
98
+ if [ "${UBUNTU_CODENAME:-}" != "" ]; then
99
+ OS="ubuntu"
100
+ VERSION="$UBUNTU_CODENAME"
101
+ elif [ "${DEBIAN_CODENAME:-}" != "" ]; then
102
+ OS="debian"
103
+ VERSION="$DEBIAN_CODENAME"
104
+ else
105
+ OS="ubuntu"
106
+ VERSION="$VERSION_CODENAME"
107
+ fi
108
+ PACKAGETYPE="apt"
109
+ if [ "$VERSION_MAJOR" -lt 5 ]; then
110
+ APT_KEY_TYPE="legacy"
111
+ else
112
+ APT_KEY_TYPE="keyring"
113
+ fi
114
+ ;;
115
+ elementary)
116
+ OS="ubuntu"
117
+ VERSION="$UBUNTU_CODENAME"
118
+ PACKAGETYPE="apt"
119
+ if [ "$VERSION_MAJOR" -lt 6 ]; then
120
+ APT_KEY_TYPE="legacy"
121
+ else
122
+ APT_KEY_TYPE="keyring"
123
+ fi
124
+ ;;
125
+ industrial-os)
126
+ OS="debian"
127
+ PACKAGETYPE="apt"
128
+ if [ "$VERSION_MAJOR" -lt 5 ]; then
129
+ VERSION="buster"
130
+ APT_KEY_TYPE="legacy"
131
+ else
132
+ VERSION="bullseye"
133
+ APT_KEY_TYPE="keyring"
134
+ fi
135
+ ;;
136
+ parrot|mendel)
137
+ OS="debian"
138
+ PACKAGETYPE="apt"
139
+ if [ "$VERSION_MAJOR" -lt 5 ]; then
140
+ VERSION="buster"
141
+ APT_KEY_TYPE="legacy"
142
+ else
143
+ VERSION="bullseye"
144
+ APT_KEY_TYPE="keyring"
145
+ fi
146
+ ;;
147
+ galliumos)
148
+ OS="ubuntu"
149
+ PACKAGETYPE="apt"
150
+ VERSION="bionic"
151
+ APT_KEY_TYPE="legacy"
152
+ ;;
153
+ pureos|kaisen)
154
+ OS="debian"
155
+ PACKAGETYPE="apt"
156
+ VERSION="bullseye"
157
+ APT_KEY_TYPE="keyring"
158
+ ;;
159
+ raspbian)
160
+ OS="$ID"
161
+ VERSION="$VERSION_CODENAME"
162
+ PACKAGETYPE="apt"
163
+ # Third-party keyrings became the preferred method of
164
+ # installation in Raspbian 11 (Bullseye).
165
+ if [ "$VERSION_MAJOR" -lt 11 ]; then
166
+ APT_KEY_TYPE="legacy"
167
+ else
168
+ APT_KEY_TYPE="keyring"
169
+ fi
170
+ ;;
171
+ kali)
172
+ OS="debian"
173
+ PACKAGETYPE="apt"
174
+ APT_SYSTEMCTL_START=true
175
+ # Third-party keyrings became the preferred method of
176
+ # installation in Debian 11 (Bullseye), which Kali switched
177
+ # to in roughly 2021.x releases
178
+ if [ "$VERSION_MAJOR" -lt 2021 ]; then
179
+ # Kali VERSION_ID is "kali-rolling", which isn't distinguishing
180
+ VERSION="buster"
181
+ APT_KEY_TYPE="legacy"
182
+ else
183
+ VERSION="bullseye"
184
+ APT_KEY_TYPE="keyring"
185
+ fi
186
+ ;;
187
+ Deepin|deepin) # https://github.com/tailscale/tailscale/issues/7862
188
+ OS="debian"
189
+ PACKAGETYPE="apt"
190
+ if [ "$VERSION_MAJOR" -lt 20 ]; then
191
+ APT_KEY_TYPE="legacy"
192
+ VERSION="buster"
193
+ else
194
+ APT_KEY_TYPE="keyring"
195
+ VERSION="bullseye"
196
+ fi
197
+ ;;
198
+ pika)
199
+ PACKAGETYPE="apt"
200
+ # All versions of PikaOS are new enough to prefer keyring
201
+ APT_KEY_TYPE="keyring"
202
+ # Older versions of PikaOS are based on Ubuntu rather than Debian
203
+ if [ "$VERSION_MAJOR" -lt 4 ]; then
204
+ OS="ubuntu"
205
+ VERSION="$UBUNTU_CODENAME"
206
+ else
207
+ OS="debian"
208
+ VERSION="$DEBIAN_CODENAME"
209
+ fi
210
+ ;;
211
+ sparky)
212
+ OS="debian"
213
+ PACKAGETYPE="apt"
214
+ VERSION="$DEBIAN_CODENAME"
215
+ APT_KEY_TYPE="keyring"
216
+ ;;
217
+ centos)
218
+ OS="$ID"
219
+ VERSION="$VERSION_MAJOR"
220
+ PACKAGETYPE="dnf"
221
+ if [ "$VERSION" = "7" ]; then
222
+ PACKAGETYPE="yum"
223
+ fi
224
+ ;;
225
+ ol)
226
+ OS="oracle"
227
+ VERSION="$VERSION_MAJOR"
228
+ PACKAGETYPE="dnf"
229
+ if [ "$VERSION" = "7" ]; then
230
+ PACKAGETYPE="yum"
231
+ fi
232
+ ;;
233
+ rhel|miraclelinux)
234
+ OS="$ID"
235
+ if [ "$ID" = "miraclelinux" ]; then
236
+ OS="rhel"
237
+ fi
238
+ VERSION="$VERSION_MAJOR"
239
+ PACKAGETYPE="dnf"
240
+ if [ "$VERSION" = "7" ]; then
241
+ PACKAGETYPE="yum"
242
+ fi
243
+ ;;
244
+ fedora)
245
+ OS="$ID"
246
+ VERSION=""
247
+ PACKAGETYPE="dnf"
248
+ ;;
249
+ rocky|almalinux|nobara|openmandriva|sangoma|risios|cloudlinux|alinux|fedora-asahi-remix)
250
+ OS="fedora"
251
+ VERSION=""
252
+ PACKAGETYPE="dnf"
253
+ ;;
254
+ amzn)
255
+ OS="amazon-linux"
256
+ VERSION="$VERSION_ID"
257
+ PACKAGETYPE="yum"
258
+ ;;
259
+ xenenterprise)
260
+ OS="centos"
261
+ VERSION="$VERSION_MAJOR"
262
+ PACKAGETYPE="yum"
263
+ ;;
264
+ opensuse-leap|sles)
265
+ OS="opensuse"
266
+ VERSION="leap/$VERSION_ID"
267
+ PACKAGETYPE="zypper"
268
+ ;;
269
+ opensuse-tumbleweed)
270
+ OS="opensuse"
271
+ VERSION="tumbleweed"
272
+ PACKAGETYPE="zypper"
273
+ ;;
274
+ sle-micro-rancher)
275
+ OS="opensuse"
276
+ VERSION="leap/15.4"
277
+ PACKAGETYPE="zypper"
278
+ ;;
279
+ arch|archarm|endeavouros|blendos|garuda|archcraft|cachyos)
280
+ OS="arch"
281
+ VERSION="" # rolling release
282
+ PACKAGETYPE="pacman"
283
+ ;;
284
+ manjaro|manjaro-arm|biglinux)
285
+ OS="manjaro"
286
+ VERSION="" # rolling release
287
+ PACKAGETYPE="pacman"
288
+ ;;
289
+ alpine)
290
+ OS="$ID"
291
+ VERSION="$VERSION_ID"
292
+ PACKAGETYPE="apk"
293
+ ;;
294
+ postmarketos)
295
+ OS="alpine"
296
+ VERSION="$VERSION_ID"
297
+ PACKAGETYPE="apk"
298
+ ;;
299
+ nixos)
300
+ echo "Please add Tailscale to your NixOS configuration directly:"
301
+ echo
302
+ echo "services.tailscale.enable = true;"
303
+ exit 1
304
+ ;;
305
+ bazzite)
306
+ echo "Bazzite comes with Tailscale installed by default."
307
+ echo "Please enable Tailscale by running the following commands as root:"
308
+ echo
309
+ echo "ujust enable-tailscale"
310
+ echo "tailscale up"
311
+ exit 1
312
+ ;;
313
+ void)
314
+ OS="$ID"
315
+ VERSION="" # rolling release
316
+ PACKAGETYPE="xbps"
317
+ ;;
318
+ gentoo)
319
+ OS="$ID"
320
+ VERSION="" # rolling release
321
+ PACKAGETYPE="emerge"
322
+ ;;
323
+ freebsd)
324
+ OS="$ID"
325
+ VERSION="$VERSION_MAJOR"
326
+ PACKAGETYPE="pkg"
327
+ ;;
328
+ osmc)
329
+ OS="debian"
330
+ PACKAGETYPE="apt"
331
+ VERSION="bullseye"
332
+ APT_KEY_TYPE="keyring"
333
+ ;;
334
+ photon)
335
+ OS="photon"
336
+ VERSION="$VERSION_MAJOR"
337
+ PACKAGETYPE="tdnf"
338
+ ;;
339
+
340
+ # TODO: wsl?
341
+ # TODO: synology? qnap?
342
+ esac
343
+ fi
344
+
345
+ # If we failed to detect something through os-release, consult
346
+ # uname and try to infer things from that.
347
+ if [ -z "$OS" ]; then
348
+ if type uname >/dev/null 2>&1; then
349
+ case "$(uname)" in
350
+ FreeBSD)
351
+ # FreeBSD before 12.2 doesn't have
352
+ # /etc/os-release, so we wouldn't have found it in
353
+ # the os-release probing above.
354
+ OS="freebsd"
355
+ VERSION="$(freebsd-version | cut -f1 -d.)"
356
+ PACKAGETYPE="pkg"
357
+ ;;
358
+ OpenBSD)
359
+ OS="openbsd"
360
+ VERSION="$(uname -r)"
361
+ PACKAGETYPE=""
362
+ ;;
363
+ Darwin)
364
+ OS="macos"
365
+ VERSION="$(sw_vers -productVersion | cut -f1-2 -d.)"
366
+ PACKAGETYPE="appstore"
367
+ ;;
368
+ Linux)
369
+ OS="other-linux"
370
+ VERSION=""
371
+ PACKAGETYPE=""
372
+ ;;
373
+ esac
374
+ fi
375
+ fi
376
+
377
+ # Ideally we want to use curl, but on some installs we
378
+ # only have wget. Detect and use what's available.
379
+ CURL=
380
+ if type curl >/dev/null; then
381
+ CURL="curl -fsSL"
382
+ elif type wget >/dev/null; then
383
+ CURL="wget -q -O-"
384
+ fi
385
+ if [ -z "$CURL" ]; then
386
+ echo "The installer needs either curl or wget to download files."
387
+ echo "Please install either curl or wget to proceed."
388
+ exit 1
389
+ fi
390
+
391
+ TEST_URL="https://pkgs.tailscale.com/"
392
+ RC=0
393
+ TEST_OUT=$($CURL "$TEST_URL" 2>&1) || RC=$?
394
+ if [ $RC != 0 ]; then
395
+ echo "The installer cannot reach $TEST_URL"
396
+ echo "Please make sure that your machine has internet access."
397
+ echo "Test output:"
398
+ echo $TEST_OUT
399
+ exit 1
400
+ fi
401
+
402
+ # Step 2: having detected an OS we support, is it one of the
403
+ # versions we support?
404
+ OS_UNSUPPORTED=
405
+ case "$OS" in
406
+ ubuntu|debian|raspbian|centos|oracle|rhel|amazon-linux|opensuse|photon)
407
+ # Check with the package server whether a given version is supported.
408
+ URL="https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/installer-supported"
409
+ $CURL "$URL" 2> /dev/null | grep -q OK || OS_UNSUPPORTED=1
410
+ ;;
411
+ fedora)
412
+ # All versions supported, no version checking required.
413
+ ;;
414
+ arch)
415
+ # Rolling release, no version checking needed.
416
+ ;;
417
+ manjaro)
418
+ # Rolling release, no version checking needed.
419
+ ;;
420
+ alpine)
421
+ # All versions supported, no version checking needed.
422
+ # TODO: is that true? When was tailscale packaged?
423
+ ;;
424
+ void)
425
+ # Rolling release, no version checking needed.
426
+ ;;
427
+ gentoo)
428
+ # Rolling release, no version checking needed.
429
+ ;;
430
+ freebsd)
431
+ if [ "$VERSION" != "12" ] && \
432
+ [ "$VERSION" != "13" ] && \
433
+ [ "$VERSION" != "14" ] && \
434
+ [ "$VERSION" != "15" ]
435
+ then
436
+ OS_UNSUPPORTED=1
437
+ fi
438
+ ;;
439
+ openbsd)
440
+ OS_UNSUPPORTED=1
441
+ ;;
442
+ macos)
443
+ # We delegate macOS installation to the app store, it will
444
+ # perform version checks for us.
445
+ ;;
446
+ other-linux)
447
+ OS_UNSUPPORTED=1
448
+ ;;
449
+ *)
450
+ OS_UNSUPPORTED=1
451
+ ;;
452
+ esac
453
+ if [ "$OS_UNSUPPORTED" = "1" ]; then
454
+ case "$OS" in
455
+ other-linux)
456
+ echo "Couldn't determine what kind of Linux is running."
457
+ echo "You could try the static binaries at:"
458
+ echo "https://pkgs.tailscale.com/$TRACK/#static"
459
+ ;;
460
+ "")
461
+ echo "Couldn't determine what operating system you're running."
462
+ ;;
463
+ *)
464
+ echo "$OS $VERSION isn't supported by this script yet."
465
+ ;;
466
+ esac
467
+ echo
468
+ echo "If you'd like us to support your system better, please email support@tailscale.com"
469
+ echo "and tell us what OS you're running."
470
+ echo
471
+ echo "Please include the following information we gathered from your system:"
472
+ echo
473
+ echo "OS=$OS"
474
+ echo "VERSION=$VERSION"
475
+ echo "PACKAGETYPE=$PACKAGETYPE"
476
+ if type uname >/dev/null 2>&1; then
477
+ echo "UNAME=$(uname -a)"
478
+ else
479
+ echo "UNAME="
480
+ fi
481
+ echo
482
+ if [ -f /etc/os-release ]; then
483
+ cat /etc/os-release
484
+ else
485
+ echo "No /etc/os-release"
486
+ fi
487
+ exit 1
488
+ fi
489
+
490
+ # Step 3: work out if we can run privileged commands, and if so,
491
+ # how.
492
+ CAN_ROOT=
493
+ SUDO=
494
+ if [ "$(id -u)" = 0 ]; then
495
+ CAN_ROOT=1
496
+ SUDO=""
497
+ elif type sudo >/dev/null; then
498
+ CAN_ROOT=1
499
+ SUDO="sudo"
500
+ elif type doas >/dev/null; then
501
+ CAN_ROOT=1
502
+ SUDO="doas"
503
+ fi
504
+ if [ "$CAN_ROOT" != "1" ]; then
505
+ echo "This installer needs to run commands as root."
506
+ echo "We tried looking for 'sudo' and 'doas', but couldn't find them."
507
+ echo "Either re-run this script as root, or set up sudo/doas."
508
+ exit 1
509
+ fi
510
+
511
+
512
+ # Step 4: run the installation.
513
+ OSVERSION="$OS"
514
+ [ "$VERSION" != "" ] && OSVERSION="$OSVERSION $VERSION"
515
+
516
+ # Prepare package name with optional version
517
+ PACKAGE_NAME="tailscale"
518
+ if [ -n "$TAILSCALE_VERSION" ]; then
519
+ echo "Installing Tailscale $TAILSCALE_VERSION for $OSVERSION, using method $PACKAGETYPE"
520
+ else
521
+ echo "Installing Tailscale for $OSVERSION, using method $PACKAGETYPE"
522
+ fi
523
+ case "$PACKAGETYPE" in
524
+ apt)
525
+ export DEBIAN_FRONTEND=noninteractive
526
+ if [ "$APT_KEY_TYPE" = "legacy" ] && ! type gpg >/dev/null; then
527
+ $SUDO apt-get update
528
+ $SUDO apt-get install -y gnupg
529
+ fi
530
+
531
+ set -x
532
+ $SUDO mkdir -p --mode=0755 /usr/share/keyrings
533
+ case "$APT_KEY_TYPE" in
534
+ legacy)
535
+ $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.asc" | $SUDO apt-key add -
536
+ $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.list" | $SUDO tee /etc/apt/sources.list.d/tailscale.list
537
+ $SUDO chmod 0644 /etc/apt/sources.list.d/tailscale.list
538
+ ;;
539
+ keyring)
540
+ $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.noarmor.gpg" | $SUDO tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
541
+ $SUDO chmod 0644 /usr/share/keyrings/tailscale-archive-keyring.gpg
542
+ $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.tailscale-keyring.list" | $SUDO tee /etc/apt/sources.list.d/tailscale.list
543
+ $SUDO chmod 0644 /etc/apt/sources.list.d/tailscale.list
544
+ ;;
545
+ esac
546
+ $SUDO apt-get update
547
+ if [ -n "$TAILSCALE_VERSION" ]; then
548
+ $SUDO apt-get install -y "tailscale=$TAILSCALE_VERSION" tailscale-archive-keyring
549
+ else
550
+ $SUDO apt-get install -y tailscale tailscale-archive-keyring
551
+ fi
552
+ if [ "$APT_SYSTEMCTL_START" = "true" ]; then
553
+ $SUDO systemctl enable --now tailscaled
554
+ $SUDO systemctl start tailscaled
555
+ fi
556
+ set +x
557
+ ;;
558
+ yum)
559
+ set -x
560
+ $SUDO yum install yum-utils -y
561
+ $SUDO yum-config-manager -y --add-repo "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
562
+ if [ -n "$TAILSCALE_VERSION" ]; then
563
+ $SUDO yum install "tailscale-$TAILSCALE_VERSION" -y
564
+ else
565
+ $SUDO yum install tailscale -y
566
+ fi
567
+ $SUDO systemctl enable --now tailscaled
568
+ set +x
569
+ ;;
570
+ dnf)
571
+ # DNF 5 has a different argument format; determine which one we have.
572
+ DNF_VERSION="3"
573
+ if LANG=C.UTF-8 dnf --version | grep -q '^dnf5 version'; then
574
+ DNF_VERSION="5"
575
+ fi
576
+
577
+ # The 'config-manager' plugin wasn't implemented when
578
+ # DNF5 was released; detect that and use the old
579
+ # version if necessary.
580
+ if [ "$DNF_VERSION" = "5" ]; then
581
+ set -x
582
+ $SUDO dnf install -y 'dnf-command(config-manager)' && DNF_HAVE_CONFIG_MANAGER=1 || DNF_HAVE_CONFIG_MANAGER=0
583
+ set +x
584
+
585
+ if [ "$DNF_HAVE_CONFIG_MANAGER" != "1" ]; then
586
+ if type dnf-3 >/dev/null; then
587
+ DNF_VERSION="3"
588
+ else
589
+ echo "dnf 5 detected, but 'dnf-command(config-manager)' not available and dnf-3 not found"
590
+ exit 1
591
+ fi
592
+ fi
593
+ fi
594
+
595
+ set -x
596
+ if [ "$DNF_VERSION" = "3" ]; then
597
+ $SUDO dnf install -y 'dnf-command(config-manager)'
598
+ $SUDO dnf config-manager --add-repo "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
599
+ elif [ "$DNF_VERSION" = "5" ]; then
600
+ # Already installed config-manager, above.
601
+ $SUDO dnf config-manager addrepo --from-repofile="https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
602
+ else
603
+ echo "unexpected: unknown dnf version $DNF_VERSION"
604
+ exit 1
605
+ fi
606
+ if [ -n "$TAILSCALE_VERSION" ]; then
607
+ $SUDO dnf install -y "tailscale-$TAILSCALE_VERSION"
608
+ else
609
+ $SUDO dnf install -y tailscale
610
+ fi
611
+ $SUDO systemctl enable --now tailscaled
612
+ set +x
613
+ ;;
614
+ tdnf)
615
+ set -x
616
+ curl -fsSL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo" > /etc/yum.repos.d/tailscale.repo
617
+ if [ -n "$TAILSCALE_VERSION" ]; then
618
+ $SUDO tdnf install -y "tailscale-$TAILSCALE_VERSION"
619
+ else
620
+ $SUDO tdnf install -y tailscale
621
+ fi
622
+ $SUDO systemctl enable --now tailscaled
623
+ set +x
624
+ ;;
625
+ zypper)
626
+ set -x
627
+ $SUDO rpm --import "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/repo.gpg"
628
+ $SUDO zypper --non-interactive ar -g -r "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
629
+ $SUDO zypper --non-interactive --gpg-auto-import-keys refresh
630
+ if [ -n "$TAILSCALE_VERSION" ]; then
631
+ $SUDO zypper --non-interactive install "tailscale=$TAILSCALE_VERSION"
632
+ else
633
+ $SUDO zypper --non-interactive install tailscale
634
+ fi
635
+ $SUDO systemctl enable --now tailscaled
636
+ set +x
637
+ ;;
638
+ pacman)
639
+ set -x
640
+ if [ -n "$TAILSCALE_VERSION" ]; then
641
+ echo "Warning: Arch Linux maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
642
+ $SUDO pacman -S "tailscale=$TAILSCALE_VERSION" --noconfirm
643
+ else
644
+ $SUDO pacman -S tailscale --noconfirm
645
+ fi
646
+ $SUDO systemctl enable --now tailscaled
647
+ set +x
648
+ ;;
649
+ pkg)
650
+ set -x
651
+ if [ -n "$TAILSCALE_VERSION" ]; then
652
+ echo "Warning: FreeBSD maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
653
+ $SUDO pkg install --yes "tailscale-$TAILSCALE_VERSION"
654
+ else
655
+ $SUDO pkg install --yes tailscale
656
+ fi
657
+ $SUDO service tailscaled enable
658
+ $SUDO service tailscaled start
659
+ set +x
660
+ ;;
661
+ apk)
662
+ set -x
663
+ if ! grep -Eq '^http.*/community$' /etc/apk/repositories; then
664
+ if type setup-apkrepos >/dev/null; then
665
+ $SUDO setup-apkrepos -c -1
666
+ else
667
+ echo "installing tailscale requires the community repo to be enabled in /etc/apk/repositories"
668
+ exit 1
669
+ fi
670
+ fi
671
+ if [ -n "$TAILSCALE_VERSION" ]; then
672
+ echo "Warning: Alpine Linux maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
673
+ $SUDO apk add "tailscale=$TAILSCALE_VERSION"
674
+ else
675
+ $SUDO apk add tailscale
676
+ fi
677
+ $SUDO rc-update add tailscale
678
+ $SUDO rc-service tailscale start
679
+ set +x
680
+ ;;
681
+ xbps)
682
+ set -x
683
+ if [ -n "$TAILSCALE_VERSION" ]; then
684
+ echo "Warning: Void Linux maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
685
+ $SUDO xbps-install "tailscale-$TAILSCALE_VERSION" -y
686
+ else
687
+ $SUDO xbps-install tailscale -y
688
+ fi
689
+ set +x
690
+ ;;
691
+ emerge)
692
+ set -x
693
+ if [ -n "$TAILSCALE_VERSION" ]; then
694
+ echo "Warning: Gentoo maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
695
+ $SUDO emerge --ask=n "=net-vpn/tailscale-$TAILSCALE_VERSION"
696
+ else
697
+ $SUDO emerge --ask=n net-vpn/tailscale
698
+ fi
699
+ set +x
700
+ ;;
701
+ appstore)
702
+ set -x
703
+ open "https://apps.apple.com/us/app/tailscale/id1475387142"
704
+ set +x
705
+ ;;
706
+ *)
707
+ echo "unexpected: unknown package type $PACKAGETYPE"
708
+ exit 1
709
+ ;;
710
+ esac
711
+
712
+ echo "Installation complete! Log in to start using Tailscale by running:"
713
+ echo
714
+ if [ -z "$SUDO" ]; then
715
+ echo "tailscale up"
716
+ else
717
+ echo "$SUDO tailscale up"
718
+ fi
719
+ }
720
+
721
+ main