installer.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. #!/bin/sh
  2. # Copyright (c) Tailscale Inc & contributors
  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|ultramarine)
  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. steamos)
  336. echo "To install Tailscale on SteamOS, please follow the instructions here:"
  337. echo "https://github.com/tailscale-dev/deck-tailscale"
  338. exit 1
  339. ;;
  340. kde-linux)
  341. echo "The maintainers of KDE Linux provide documentation on multiple ways to install Tailscale. These instructions are not officially supported by Tailscale:"
  342. echo "https://kde.org/linux/docs/more-software/#tailscale"
  343. exit 1
  344. ;;
  345. # TODO: wsl?
  346. # TODO: synology? qnap?
  347. esac
  348. fi
  349. # If we failed to detect something through os-release, consult
  350. # uname and try to infer things from that.
  351. if [ -z "$OS" ]; then
  352. if type uname >/dev/null 2>&1; then
  353. case "$(uname)" in
  354. FreeBSD)
  355. # FreeBSD before 12.2 doesn't have
  356. # /etc/os-release, so we wouldn't have found it in
  357. # the os-release probing above.
  358. OS="freebsd"
  359. VERSION="$(freebsd-version | cut -f1 -d.)"
  360. PACKAGETYPE="pkg"
  361. ;;
  362. OpenBSD)
  363. OS="openbsd"
  364. VERSION="$(uname -r)"
  365. PACKAGETYPE=""
  366. ;;
  367. Darwin)
  368. OS="macos"
  369. VERSION="$(sw_vers -productVersion | cut -f1-2 -d.)"
  370. PACKAGETYPE="appstore"
  371. ;;
  372. Linux)
  373. OS="other-linux"
  374. VERSION=""
  375. PACKAGETYPE=""
  376. ;;
  377. esac
  378. fi
  379. fi
  380. # Ideally we want to use curl, but on some installs we
  381. # only have wget. Detect and use what's available.
  382. CURL=
  383. if type curl >/dev/null; then
  384. CURL="curl -fsSL"
  385. elif type wget >/dev/null; then
  386. CURL="wget -q -O-"
  387. fi
  388. if [ -z "$CURL" ]; then
  389. echo "The installer needs either curl or wget to download files."
  390. echo "Please install either curl or wget to proceed."
  391. exit 1
  392. fi
  393. TEST_URL="https://pkgs.tailscale.com/"
  394. RC=0
  395. TEST_OUT=$($CURL "$TEST_URL" 2>&1) || RC=$?
  396. if [ $RC != 0 ]; then
  397. echo "The installer cannot reach $TEST_URL"
  398. echo "Please make sure that your machine has internet access."
  399. echo "Test output:"
  400. echo $TEST_OUT
  401. exit 1
  402. fi
  403. # Step 2: having detected an OS we support, is it one of the
  404. # versions we support?
  405. OS_UNSUPPORTED=
  406. case "$OS" in
  407. ubuntu|debian|raspbian|centos|oracle|rhel|amazon-linux|opensuse|photon)
  408. # Check with the package server whether a given version is supported.
  409. URL="https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/installer-supported"
  410. $CURL "$URL" 2> /dev/null | grep -q OK || OS_UNSUPPORTED=1
  411. ;;
  412. fedora)
  413. # All versions supported, no version checking required.
  414. ;;
  415. arch)
  416. # Rolling release, no version checking needed.
  417. ;;
  418. manjaro)
  419. # Rolling release, no version checking needed.
  420. ;;
  421. alpine)
  422. # All versions supported, no version checking needed.
  423. # TODO: is that true? When was tailscale packaged?
  424. ;;
  425. void)
  426. # Rolling release, no version checking needed.
  427. ;;
  428. gentoo)
  429. # Rolling release, no version checking needed.
  430. ;;
  431. freebsd)
  432. if [ "$VERSION" != "12" ] && \
  433. [ "$VERSION" != "13" ] && \
  434. [ "$VERSION" != "14" ] && \
  435. [ "$VERSION" != "15" ]
  436. then
  437. OS_UNSUPPORTED=1
  438. fi
  439. ;;
  440. openbsd)
  441. OS_UNSUPPORTED=1
  442. ;;
  443. macos)
  444. # We delegate macOS installation to the app store, it will
  445. # perform version checks for us.
  446. ;;
  447. other-linux)
  448. OS_UNSUPPORTED=1
  449. ;;
  450. *)
  451. OS_UNSUPPORTED=1
  452. ;;
  453. esac
  454. if [ "$OS_UNSUPPORTED" = "1" ]; then
  455. case "$OS" in
  456. other-linux)
  457. echo "Couldn't determine what kind of Linux is running."
  458. echo "You could try the static binaries at:"
  459. echo "https://pkgs.tailscale.com/$TRACK/#static"
  460. ;;
  461. "")
  462. echo "Couldn't determine what operating system you're running."
  463. ;;
  464. *)
  465. echo "$OS $VERSION isn't supported by this script yet."
  466. ;;
  467. esac
  468. echo
  469. echo "If you'd like us to support your system better, please email [email protected]"
  470. echo "and tell us what OS you're running."
  471. echo
  472. echo "Please include the following information we gathered from your system:"
  473. echo
  474. echo "OS=$OS"
  475. echo "VERSION=$VERSION"
  476. echo "PACKAGETYPE=$PACKAGETYPE"
  477. if type uname >/dev/null 2>&1; then
  478. echo "UNAME=$(uname -a)"
  479. else
  480. echo "UNAME="
  481. fi
  482. echo
  483. if [ -f /etc/os-release ]; then
  484. cat /etc/os-release
  485. else
  486. echo "No /etc/os-release"
  487. fi
  488. exit 1
  489. fi
  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. # Step 4: run the installation.
  511. OSVERSION="$OS"
  512. [ "$VERSION" != "" ] && OSVERSION="$OSVERSION $VERSION"
  513. # Prepare package name with optional version
  514. PACKAGE_NAME="tailscale"
  515. if [ -n "$TAILSCALE_VERSION" ]; then
  516. echo "Installing Tailscale $TAILSCALE_VERSION for $OSVERSION, using method $PACKAGETYPE"
  517. else
  518. echo "Installing Tailscale for $OSVERSION, using method $PACKAGETYPE"
  519. fi
  520. case "$PACKAGETYPE" in
  521. apt)
  522. export DEBIAN_FRONTEND=noninteractive
  523. if [ "$APT_KEY_TYPE" = "legacy" ] && ! type gpg >/dev/null; then
  524. $SUDO apt-get update
  525. $SUDO apt-get install -y gnupg
  526. fi
  527. set -x
  528. $SUDO mkdir -p --mode=0755 /usr/share/keyrings
  529. case "$APT_KEY_TYPE" in
  530. legacy)
  531. $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.asc" | $SUDO apt-key add -
  532. $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.list" | $SUDO tee /etc/apt/sources.list.d/tailscale.list
  533. $SUDO chmod 0644 /etc/apt/sources.list.d/tailscale.list
  534. ;;
  535. keyring)
  536. $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.noarmor.gpg" | $SUDO tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
  537. $SUDO chmod 0644 /usr/share/keyrings/tailscale-archive-keyring.gpg
  538. $CURL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION.tailscale-keyring.list" | $SUDO tee /etc/apt/sources.list.d/tailscale.list
  539. $SUDO chmod 0644 /etc/apt/sources.list.d/tailscale.list
  540. ;;
  541. esac
  542. $SUDO apt-get update
  543. if [ -n "$TAILSCALE_VERSION" ]; then
  544. $SUDO apt-get install -y "tailscale=$TAILSCALE_VERSION" tailscale-archive-keyring
  545. else
  546. $SUDO apt-get install -y tailscale tailscale-archive-keyring
  547. fi
  548. if [ "$APT_SYSTEMCTL_START" = "true" ]; then
  549. $SUDO systemctl enable --now tailscaled
  550. $SUDO systemctl start tailscaled
  551. fi
  552. set +x
  553. ;;
  554. yum)
  555. set -x
  556. $SUDO yum install yum-utils -y
  557. $SUDO yum-config-manager -y --add-repo "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
  558. if [ -n "$TAILSCALE_VERSION" ]; then
  559. $SUDO yum install "tailscale-$TAILSCALE_VERSION" -y
  560. else
  561. $SUDO yum install tailscale -y
  562. fi
  563. $SUDO systemctl enable --now tailscaled
  564. set +x
  565. ;;
  566. dnf)
  567. # DNF 5 has a different argument format; determine which one we have.
  568. DNF_VERSION="3"
  569. if LANG=C.UTF-8 dnf --version | grep -q '^dnf5 version'; then
  570. DNF_VERSION="5"
  571. fi
  572. # The 'config-manager' plugin wasn't implemented when
  573. # DNF5 was released; detect that and use the old
  574. # version if necessary.
  575. if [ "$DNF_VERSION" = "5" ]; then
  576. set -x
  577. $SUDO dnf install -y 'dnf-command(config-manager)' && DNF_HAVE_CONFIG_MANAGER=1 || DNF_HAVE_CONFIG_MANAGER=0
  578. set +x
  579. if [ "$DNF_HAVE_CONFIG_MANAGER" != "1" ]; then
  580. if type dnf-3 >/dev/null; then
  581. DNF_VERSION="3"
  582. else
  583. echo "dnf 5 detected, but 'dnf-command(config-manager)' not available and dnf-3 not found"
  584. exit 1
  585. fi
  586. fi
  587. fi
  588. set -x
  589. if [ "$DNF_VERSION" = "3" ]; then
  590. $SUDO dnf install -y 'dnf-command(config-manager)'
  591. $SUDO dnf config-manager --add-repo "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
  592. elif [ "$DNF_VERSION" = "5" ]; then
  593. # Already installed config-manager, above.
  594. $SUDO dnf config-manager addrepo --overwrite --from-repofile="https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
  595. else
  596. echo "unexpected: unknown dnf version $DNF_VERSION"
  597. exit 1
  598. fi
  599. if [ -n "$TAILSCALE_VERSION" ]; then
  600. $SUDO dnf install -y "tailscale-$TAILSCALE_VERSION"
  601. else
  602. $SUDO dnf install -y tailscale
  603. fi
  604. $SUDO systemctl enable --now tailscaled
  605. set +x
  606. ;;
  607. tdnf)
  608. set -x
  609. curl -fsSL "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo" > /etc/yum.repos.d/tailscale.repo
  610. if [ -n "$TAILSCALE_VERSION" ]; then
  611. $SUDO tdnf install -y "tailscale-$TAILSCALE_VERSION"
  612. else
  613. $SUDO tdnf install -y tailscale
  614. fi
  615. $SUDO systemctl enable --now tailscaled
  616. set +x
  617. ;;
  618. zypper)
  619. set -x
  620. $SUDO rpm --import "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/repo.gpg"
  621. $SUDO zypper --non-interactive ar -g -r "https://pkgs.tailscale.com/$TRACK/$OS/$VERSION/tailscale.repo"
  622. $SUDO zypper --non-interactive --gpg-auto-import-keys refresh
  623. if [ -n "$TAILSCALE_VERSION" ]; then
  624. $SUDO zypper --non-interactive install "tailscale=$TAILSCALE_VERSION"
  625. else
  626. $SUDO zypper --non-interactive install tailscale
  627. fi
  628. $SUDO systemctl enable --now tailscaled
  629. set +x
  630. ;;
  631. pacman)
  632. set -x
  633. if [ -n "$TAILSCALE_VERSION" ]; then
  634. 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."
  635. $SUDO pacman -S "tailscale=$TAILSCALE_VERSION" --noconfirm
  636. else
  637. $SUDO pacman -S tailscale --noconfirm
  638. fi
  639. $SUDO systemctl enable --now tailscaled
  640. set +x
  641. ;;
  642. pkg)
  643. set -x
  644. if [ -n "$TAILSCALE_VERSION" ]; then
  645. echo "Warning: FreeBSD maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
  646. $SUDO pkg install --yes "tailscale-$TAILSCALE_VERSION"
  647. else
  648. $SUDO pkg install --yes tailscale
  649. fi
  650. $SUDO service tailscaled enable
  651. $SUDO service tailscaled start
  652. set +x
  653. ;;
  654. apk)
  655. set -x
  656. if ! grep -Eq '^http.*/community$' /etc/apk/repositories; then
  657. if type setup-apkrepos >/dev/null; then
  658. $SUDO setup-apkrepos -c -1
  659. else
  660. echo "installing tailscale requires the community repo to be enabled in /etc/apk/repositories"
  661. exit 1
  662. fi
  663. fi
  664. if [ -n "$TAILSCALE_VERSION" ]; then
  665. 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."
  666. $SUDO apk add "tailscale=$TAILSCALE_VERSION"
  667. else
  668. $SUDO apk add tailscale
  669. fi
  670. $SUDO rc-update add tailscale
  671. $SUDO rc-service tailscale start
  672. set +x
  673. ;;
  674. xbps)
  675. set -x
  676. if [ -n "$TAILSCALE_VERSION" ]; then
  677. 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."
  678. $SUDO xbps-install "tailscale-$TAILSCALE_VERSION" -y
  679. else
  680. $SUDO xbps-install tailscale -y
  681. fi
  682. set +x
  683. ;;
  684. emerge)
  685. set -x
  686. if [ -n "$TAILSCALE_VERSION" ]; then
  687. echo "Warning: Gentoo maintains their own Tailscale package. Version pinning may not work as expected, as the target version may no longer be available."
  688. $SUDO emerge --ask=n "=net-vpn/tailscale-$TAILSCALE_VERSION"
  689. else
  690. $SUDO emerge --ask=n net-vpn/tailscale
  691. fi
  692. set +x
  693. ;;
  694. appstore)
  695. set -x
  696. open "https://apps.apple.com/us/app/tailscale/id1475387142"
  697. set +x
  698. ;;
  699. *)
  700. echo "unexpected: unknown package type $PACKAGETYPE"
  701. exit 1
  702. ;;
  703. esac
  704. echo "Installation complete! Log in to start using Tailscale by running:"
  705. echo
  706. if [ -z "$SUDO" ]; then
  707. echo "tailscale up"
  708. else
  709. echo "$SUDO tailscale up"
  710. fi
  711. }
  712. main