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}"
|
2020-05-22 22:31:37 +00:00
|
|
|
INPIPE=/tmp/input
|
2020-05-22 21:26:34 +00:00
|
|
|
|
|
|
|
|
2020-05-22 22:31:37 +00:00
|
|
|
setup() {
|
|
|
|
gpg --generate-key --batch gpg-keygen-params.txt
|
|
|
|
pass init proton
|
2020-05-21 15:11:31 +00:00
|
|
|
|
2020-05-22 22:31:37 +00:00
|
|
|
bridge-cli
|
2020-05-22 21:26:34 +00:00
|
|
|
|
2020-05-22 23:08:23 +00:00
|
|
|
echo "login" >&3
|
|
|
|
echo "$BRIDGE_USER" >&3
|
|
|
|
echo "$BRIDGE_PASS" >&3
|
|
|
|
echo "exit" >&3
|
2020-05-22 22:31:37 +00:00
|
|
|
wait $bridge_pid
|
|
|
|
}
|
2020-05-22 21:26:34 +00:00
|
|
|
|
2020-05-22 22:31:37 +00:00
|
|
|
bridge-cli() {
|
|
|
|
mkfifo $INPIPE
|
|
|
|
$BRIDGE --cli < $INPIPE &
|
2020-05-22 23:08:23 +00:00
|
|
|
exec 3> $INPIPE
|
2020-05-22 22:31:37 +00:00
|
|
|
bridge_pid=$!
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
bridge-cli
|
|
|
|
|
2020-05-22 23:08:23 +00:00
|
|
|
echo "info" >&3
|
2020-05-22 22:31:37 +00:00
|
|
|
wait $bridge_pid
|
|
|
|
}
|
|
|
|
|
2020-05-23 00:35:29 +00:00
|
|
|
umask 077
|
2020-05-22 22:31:37 +00:00
|
|
|
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
|
|
|
|