protonmail-bridge-nextcoud-.../build/entrypoint.sh
Nilesh 680e82076e
Fix entrypoint so it works correctly on init
Ran into this issue when trying to use in kubernetes via k8s-at-home/protonmail-bridge. Took a bit of figuring out before I realized I had to manually kill the other instance. The only output from the failed load is a dbus issue, and an immediate exit.
2022-05-12 11:31:03 -07:00

33 lines
761 B
Bash

#!/bin/bash
set -ex
# Initialize
if [[ $1 == init ]]; then
# Initialize pass
gpg --generate-key --batch /protonmail/gpgparams
pass init pass-key
# Kill the other instance as only one can be running at a time
pkill protonmail-bridge
# Login
/protonmail/proton-bridge --cli $@
else
# socat will make the conn appear to come from 127.0.0.1
# ProtonMail Bridge currently expects that.
# It also allows us to bind to the real ports :)
socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 &
socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 &
# Start protonmail
# Fake a terminal, so it does not quit because of EOF...
rm -f faketty
mkfifo faketty
cat faketty | /protonmail/proton-bridge --cli $@
fi