#!/bin/sh # Pantheon Desk for Mac and Linux. Paste into a terminal: # curl -fsSL https://pantheon-desk.vercel.app/install.sh | sh -s -- 'YOUR INVITE LINK' # With an invite it first installs Pantheon and joins you to the team (it asks for your email and a code). # Then it installs Pantheon Desk into Applications, opens it, and starts it whenever you log in. set -eu URL="https://pantheon-desk.vercel.app" INVITE="${1:-}" say() { printf '\n\033[1m%s\033[0m\n' "$1"; } fail() { printf '\n\033[31m%s\033[0m\n' "$1" >&2; exit 1; } OS=$(uname -s) [ "$OS" = "Darwin" ] || [ "$OS" = "Linux" ] || fail "This installer is for Mac and Linux. On Windows use the Windows download (see $URL)." PANTHEON="$HOME/.pantheon/bin/pantheon" if [ -n "$INVITE" ] && ! { [ -x "$PANTHEON" ] || command -v pantheon >/dev/null 2>&1; }; then say "Step 1 of 2: installing Pantheon and joining your team" # Saved to a file first: piping it into sh while also giving sh the keyboard would make sh read # its commands from the keyboard. The installer needs the keyboard for the email and the code. PI=$(mktemp); curl -fsSL https://relay.joinpantheon.network/install.sh -o "$PI" JOINED=1; sh "$PI" join "$INVITE" /dev/null 2>&1; }; then # No invite: install Pantheon only. Signing in and joining happen in the app. say "Step 1 of 2: installing Pantheon" PI=$(mktemp); curl -fsSL https://relay.joinpantheon.network/install.sh -o "$PI"; sh "$PI" /dev/null || true) [ -n "$NODE" ] && [ -x "$NODE" ] || fail "Pantheon isn't installed yet. Run this again with the invite link your teammate sent, in quotes, after install.sh." NODE_MAJOR=$("$NODE" -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0) [ "$NODE_MAJOR" -ge 20 ] 2>/dev/null || fail "This Mac's Node is too old (needs 20 or newer). Run this again with your invite link: it installs Pantheon with its own Node." say "Step 2 of 2: installing Pantheon Desk" TMP=$(mktemp -d) trap 'rm -rf "$TMP"' EXIT curl -fsSL "$URL/updater.mjs" -o "$TMP/updater.mjs" "$NODE" "$TMP/updater.mjs" install || fail "Couldn't download Pantheon Desk. Check the internet connection and run this again." if [ "$OS" = "Linux" ]; then # Linux: a small launcher that always runs the current version, a menu entry, and start at login. H="$HOME/.local/share/pantheon-desk" cat > "$H/launch.mjs" <<'JS' import { readFileSync } from "node:fs"; import { join, dirname } from "node:path"; import { pathToFileURL, fileURLToPath } from "node:url"; const home = dirname(fileURLToPath(import.meta.url)); const v = readFileSync(join(home, "current.txt"), "utf8").trim(); const desk = join(home, "versions", v, "desk.mjs"); process.argv[1] = desk; await import(pathToFileURL(desk).href); JS CUR=$(cat "$H/current.txt"); ICON="$H/versions/$CUR/web/icon-512.png" mkdir -p "$HOME/.local/share/applications" "$HOME/.config/autostart" for F in "$HOME/.local/share/applications/pantheon-desk.desktop" "$HOME/.config/autostart/pantheon-desk.desktop"; do ARGS=""; case "$F" in *autostart*) ARGS=" --no-window";; esac cat > "$F" </dev/null 2>&1 & say "Done. Pantheon Desk is opening. It's in your apps menu and starts when you log in." echo "It updates itself: when you're told there's a new version, press F5 in its window." exit 0 fi curl -fsSL "$URL/PantheonDesk-mac.zip" -o "$TMP/desk.zip" # The app must match the digest inside the signed version that was just verified and installed. CUR=$(cat "$HOME/Library/Application Support/PantheonDesk/current.txt") WANT=$(cat "$HOME/Library/Application Support/PantheonDesk/versions/$CUR/app-mac.sha256" 2>/dev/null || true) GOT=$(shasum -a 256 "$TMP/desk.zip" | cut -c1-64) [ -n "$WANT" ] && [ "$WANT" = "$GOT" ] || fail "The app download didn't match the signed version. Nothing was installed. Try again in a few minutes." mkdir -p "$HOME/Applications" APP="$HOME/Applications/Pantheon Desk.app" osascript -e 'quit app "Pantheon Desk"' >/dev/null 2>&1 || true rm -rf "$APP" ditto -x -k "$TMP/desk.zip" "$HOME/Applications" xattr -dr com.apple.quarantine "$APP" 2>/dev/null || true # Start at login, quietly in the background. PL="$HOME/Library/LaunchAgents/network.joinpantheon.desk.plist" mkdir -p "$HOME/Library/LaunchAgents" cat > "$PL" < Labelnetwork.joinpantheon.desk ProgramArguments/usr/bin/open-g-a$APP--args--background RunAtLoad PLIST open "$APP" say "Done. Pantheon Desk is open, and it's in your Applications folder." if [ "${JOINED:-1}" = "0" ]; then printf '\n\033[33m%s\033[0m\n' "Joining the team didn't finish (the invite may be used or expired). Ask for a new invite, then in the app click + Add next to Teams and paste it."; fi echo "It updates itself: when you're told there's a new version, press Cmd+R in the app."