#!/bin/sh # Installs Croft on this computer, a phone, or both. Always the newest version; the address never changes. # curl -fsSL https://get.croftmessaging.com/install.sh | sh Croft Plus on this computer (Linux or macOS) # curl -fsSL https://get.croftmessaging.com/install.sh | sh -s -- --phone all four apps on a phone plugged in with USB debugging on # curl -fsSL https://get.croftmessaging.com/install.sh | sh -s -- --all this computer and the phone # add --apps messages,plus to pick which phone apps (messages, plus, contacts, calls; default all four) # Each phone app is checked against the signed list before it is sent; Android then checks the release signature itself. set -eu B='https://get.croftmessaging.com'; PHONE=0; PC=1; APPS="messages,plus,contacts,calls"; REST="" while [ $# -gt 0 ]; do case "$1" in --phone) PHONE=1; PC=0 ;; --all) PHONE=1; PC=1 ;; --apps) shift; APPS="$1" ;; *) REST="$REST $1" ;; esac; shift; done T=$(mktemp -d); trap 'rm -rf "$T"' EXIT INT TERM if [ "$PHONE" = 1 ]; then command -v adb >/dev/null 2>&1 || { echo "adb is needed for the phone (install android-tools or platform-tools), then run this again"; exit 1; } N=$(adb devices | awk 'NR>1 && $2=="device"' | wc -l) [ "$N" = 1 ] || { echo "plug in exactly one phone with USB debugging on (found $N)"; exit 1; } for a in $(echo "$APPS" | tr ',' ' '); do case "$a" in messages) F=CroftMessaging; M=latest;; plus) F=CroftPlus; M=latest-plus;; contacts) F=CroftContacts; M=latest-contacts;; calls) F=CroftCaller; M=latest-caller;; *) echo "unknown app $a"; exit 1;; esac curl -fsSL --retry 3 "$B/$M.json" -o "$T/$M.json"; curl -fsSL --retry 3 "$B/$F.apk" -o "$T/$F.apk" W=$(sed -n 's/.*"sha256" *: *"\([0-9a-f]*\)".*/\1/p' "$T/$M.json" | head -1) G=$( (sha256sum "$T/$F.apk" 2>/dev/null || shasum -a 256 "$T/$F.apk") | cut -d' ' -f1) [ -n "$W" ] && [ "$W" = "$G" ] || { echo "$F does not match the signed list: not installing"; exit 1; } adb install -r "$T/$F.apk" && echo "installed $F" done fi if [ "$PC" = 1 ]; then curl -fsSL --retry 3 "https://get.croftmessaging.com/desktop/install.sh" -o "$T/install.sh" sh "$T/install.sh" --base-url 'https://get.croftmessaging.com/desktop/{file}' --require-signature $REST fi