installer.sh 17 KB

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