installer.sh 17 KB

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