installer.sh 19 KB

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