protonmail-bridge-nextcoud-.../build/entrypoint.sh
Dan Williams 5ad6fa81e3 Fix v3.22.0 build, improve stability, and set up for community maintenance
- Add libfido2-dev, libcbor-dev to build deps; libfido2-1, libcbor0 to runtime (fixes #135)
- Make bridge binaries read-only to block built-in auto-updater at runtime
- Add HEALTHCHECK to Dockerfile
- Fix long-uptime stdin stability: replace cat pipe with sleep infinity
- Clean up stale GPG agent sockets on container startup
- Update maintainer label
- Repoint build.yaml to dancwilliams Docker Hub and GHCR repos
- Use clean version/latest tags (drop -build suffix)
- Fix missing checkout in merge job
- Add workflow_dispatch and pip install to update-check.yaml
- Remove Gitee mirror workflow
- Remove legacy deb build (Dockerfile, workflow, and deb/ directory)
2026-02-24 20:15:39 -06:00

49 lines
1.4 KiB
Bash

#!/bin/bash
set -ex
# Workaround for stale gpg-agent socket causing auth failures on restart
# Cleans up leftover sockets in the GPG home directory
if [ -d /root/.gnupg ]; then
rm -f /root/.gnupg/S.gpg-agent*
fi
# 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.
# This allows users to run entrypoint init inside a running conainter
# which is useful in a k8s environment.
# || true to make sure this would not fail in case there is no running instance.
pkill protonmail-bridge || true
# 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
# Keep faketty open indefinitely (more stable than cat pipe over long uptimes)
sleep infinity > faketty &
# Start bridge reading from faketty; wait so container exits with bridge's exit code
/protonmail/proton-bridge --cli $@ < faketty &
wait $!
exit $?
fi