#!/bin/sh # Passlish installer for Mac and Linux. # Run: curl -fsSL https://passlish.com/install | sh # It downloads Passlish Import for this computer from passlish.com, checks it against the published # checksum, installs it in your home folder (nothing system-wide, no admin password) and opens it. # # Device access (contracts/DEVICE-ACCESS.md): curl -fsSL https://passlish.com/install | sh -s -- device # installs the Passlish device service system-wide. It needs the computer's admin password and asks # you to approve before anything is installed, then for the pairing code shown in Passlish, Devices. set -eu BASE="https://passlish.com/download" OS=$(uname -s); ARCH=$(uname -m) sha_of() { if command -v shasum >/dev/null 2>&1; then shasum -a 256 "$1" | cut -d' ' -f1; else sha256sum "$1" | cut -d' ' -f1; fi; } if [ "${1:-}" = "device" ]; then case "$OS" in Darwin) FILE="passlish-device-mac"; DEST="/usr/local/libexec/passlish" ;; Linux) case "$ARCH" in x86_64|amd64) FILE="passlish-device-linux-amd64" ;; aarch64|arm64) FILE="passlish-device-linux-arm64" ;; *) echo "The Passlish device service does not run on this processor ($ARCH)."; exit 1 ;; esac DEST="/usr/local/lib/passlish" ;; *) echo "On Windows, open PowerShell as administrator and run: iex \"& { \$(irm https://passlish.com/install.ps1) } -Device\""; exit 1 ;; esac SUDO="" if [ "$(id -u)" != "0" ]; then command -v sudo >/dev/null 2>&1 || { echo "Admin rights are needed. Run this again as root."; exit 1; } SUDO="sudo" echo "Passlish needs this computer's admin password to manage sign-ins." fi TMP=$(mktemp -d "${TMPDIR:-/tmp}/passlish.XXXXXX") echo "Downloading the Passlish device service..." curl -fsSL "$BASE/$FILE" -o "$TMP/$FILE" curl -fsSL "$BASE/SHA256SUMS.txt" -o "$TMP/sums" WANT=$(grep " $FILE\$" "$TMP/sums" | cut -d' ' -f1) GOT=$(sha_of "$TMP/$FILE") if [ -z "$WANT" ] || [ "$WANT" != "$GOT" ]; then echo "The download did not match its checksum. Nothing was installed."; exit 1; fi echo "Checked." STAMP=$(date +%Y%m%d%H%M%S) $SUDO mkdir -p "$DEST" # Keep the earlier version instead of deleting it. if [ -e "$DEST/passlish-device" ]; then $SUDO mkdir -p "$DEST/previous"; $SUDO mv "$DEST/passlish-device" "$DEST/previous/passlish-device-$STAMP"; fi $SUDO mv "$TMP/$FILE" "$DEST/passlish-device" $SUDO chown root "$DEST/passlish-device" 2>/dev/null || true $SUDO chmod 755 "$DEST/passlish-device" # Approval, pairing code and the service. It reads your answers from this terminal. $SUDO "$DEST/passlish-device" setup --installer "$(id -un)" exit 0 fi case "$OS" in Darwin) FILE="passlish-import-mac.zip" ;; Linux) case "$ARCH" in x86_64|amd64) FILE="passlish-import-linux-amd64" ;; aarch64|arm64) FILE="passlish-import-linux-arm64" ;; *) echo "Passlish Import does not run on this processor ($ARCH)."; exit 1 ;; esac ;; *) echo "On Windows, open PowerShell and run: irm https://passlish.com/install.ps1 | iex"; exit 1 ;; esac DIR="$HOME/.passlish"; mkdir -p "$DIR" TMP=$(mktemp -d "${TMPDIR:-/tmp}/passlish.XXXXXX") echo "Downloading Passlish Import..." curl -fsSL "$BASE/$FILE" -o "$TMP/$FILE" curl -fsSL "$BASE/SHA256SUMS.txt" -o "$TMP/sums" WANT=$(grep " $FILE\$" "$TMP/sums" | cut -d' ' -f1) GOT=$(sha_of "$TMP/$FILE") if [ -z "$WANT" ] || [ "$WANT" != "$GOT" ]; then echo "The download did not match its checksum. Nothing was installed."; exit 1; fi echo "Checked." STAMP=$(date +%Y%m%d%H%M%S) if [ "$OS" = "Darwin" ]; then APPS="$HOME/Applications"; mkdir -p "$APPS" # Keep the earlier version instead of deleting it. if [ -e "$APPS/Passlish Import.app" ]; then mkdir -p "$DIR/previous"; mv "$APPS/Passlish Import.app" "$DIR/previous/Passlish Import $STAMP.app"; fi /usr/bin/ditto -x -k "$TMP/$FILE" "$APPS" echo "Installed in $APPS. Opening Passlish Import..." open "$APPS/Passlish Import.app" else if [ -e "$DIR/passlish-import" ]; then mkdir -p "$DIR/previous"; mv "$DIR/passlish-import" "$DIR/previous/passlish-import-$STAMP"; fi mv "$TMP/$FILE" "$DIR/passlish-import"; chmod 755 "$DIR/passlish-import" echo "Installed in $DIR. Opening Passlish Import..." nohup "$DIR/passlish-import" >/dev/null 2>&1 & fi echo "Passlish opens in your browser. Unlock it and press Bring in."