installer.sh 19 KB

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