installer.sh 17 KB

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