isolated-protonmail-bridge/entrypoint.sh
2020-05-23 02:35:29 +02:00

52 lines
697 B
Bash
Executable File

#!/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