29 lines
1 KiB
Bash
Executable file
29 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Add local user
|
|
# Either use the PUID/PGID if passed in at runtime or fallback to 9001.
|
|
USER_ID=${PUID:-9001}
|
|
GROUP_ID=${PGID:-$USER_ID}
|
|
echo "Starting with UID : $USER_ID:$GROUP_ID"
|
|
GROUP=proton
|
|
if getent group $GROUP_ID > /dev/null; then
|
|
echo "Using group $GROUP with GID $GROUP_ID..."
|
|
GROUP=$(getent group $GROUP_ID | cut -d: -f1)
|
|
else
|
|
echo "Adding group $GROUP with GID $GROUP_ID..."
|
|
addgroup -g $GROUP_ID $GROUP
|
|
fi
|
|
echo "Adding user proton ($USER_ID) with group $GROUP ${GROUP_ID}..."
|
|
adduser -D -u $USER_ID -G $GROUP -h /var/lib/proton -s /bin/sh proton
|
|
chown -R ${USER_ID}:${GROUP_ID} /var/lib/proton
|
|
export HOME=/var/lib/proton
|
|
|
|
# The ProtonMail Bridge expects connections from 127.0.0.1. Use socat to
|
|
# redirect incoming connections to localhost. Also, this allows us to use
|
|
# the default SMTP/IMAP ports.
|
|
setcap 'cap_net_bind_service=+ep' /usr/bin/socat
|
|
socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 &
|
|
socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 &
|
|
|
|
echo "Starting ProtonMail Bridge..."
|
|
exec /usr/sbin/gosu proton "$@"
|