You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
697 B
Bash

#!/usr/bin/env bash
set -euo pipefail
BRIDGE="${BRIDGE:-/usr/bin/protonmail-bridge}"
INPIPE=/tmp/input
setup() {
gpg --generate-key --batch gpg-keygen-params.txt
pass init proton
bridge-cli
echo "login" >&3
echo "$BRIDGE_USER" >&3
echo "$BRIDGE_PASS" >&3
echo "exit" >&3
wait $bridge_pid
}
bridge-cli() {
mkfifo $INPIPE
$BRIDGE --cli < $INPIPE &
exec 3> $INPIPE
bridge_pid=$!
}
start() {
bridge-cli
echo "info" >&3
wait $bridge_pid
}
umask 077
case "${1:-}" in
setup)
setup
;;
start)
start
;;
test)
bash -i
;;
*)
echo "Usage: isolated_protonmail_bridge.sh [setup|start|test]"
exit 1
;;
esac