installer.sh 16 KB

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