isolated-protonmail-bridge/entrypoint.sh

52 lines
697 B
Bash
Raw Normal View History

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