mirror of
https://codeberg.org/hyperreal/ansible-homelab
synced 2024-11-25 19:33:40 +01:00
38 lines
954 B
Bash
38 lines
954 B
Bash
#!/usr/bin/env bash
|
|
#
|
|
# This script must be run as the same user running offlineimap, which is
|
|
# preferably a non-privileged user.
|
|
#
|
|
# This script should be daemonized (forked to bg) or used as the value of
|
|
# the ExecStart= directive in a systemd service file.
|
|
set -exo pipefail
|
|
|
|
# If "init" is supplied as arg $1, initialize the bridge.
|
|
if [[ "$1" == "init" ]]; then
|
|
|
|
# Initialize pass
|
|
gpg --generate-key --batch <<EOF
|
|
%no-protection
|
|
%echo Generating a basic OpenPGP key
|
|
Key-Type: RSA
|
|
Key-Length: 2048
|
|
Name-Real: pass-key
|
|
Expire-Date: 0
|
|
%commit
|
|
%echo done
|
|
EOF
|
|
pass init pass-key
|
|
|
|
# Kill other instance of protonmail-bridge as only one can be running at a
|
|
# time.
|
|
pkill protonmail-bridge || true
|
|
|
|
# Login
|
|
protonmail-bridge --cli "$@"
|
|
else
|
|
# Start protonmail-bridge in a fake tty, so it does not quit because of EOF.
|
|
rm -f /tmp/faketty
|
|
mkfifo /tmp/faketty
|
|
cat /tmp/faketty | protonmail-bridge --cli "$@"
|
|
fi
|