isolated-protonmail-bridge/isolated-protonmail-bridge.sh

34 lines
1.9 KiB
Bash
Raw Normal View History

2020-05-21 15:11:31 +00:00
#!/usr/bin/env bash
set -euo pipefail
HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
JAIL_HOME=/home/proton
BIN="${BIN:-entrypoint.sh}"
if [[ -z "${BRIDGE_HOME:-}" ]]; then
echo "Please set the BRIDGE_HOME envvar!"
exit 1
else
BRIDGE_HOME="$(realpath "${BRIDGE_HOME}")"
fi
2020-05-23 01:24:28 +00:00
exec nsjail -Mo \
2020-05-21 15:11:31 +00:00
--disable_clone_newnet \
2020-05-26 16:23:20 +00:00
--disable_rlimits \
2020-05-21 15:11:31 +00:00
--cwd "${JAIL_HOME}" \
--tmpfsmount /tmp --tmpfsmount /run \
--bindmount "${BRIDGE_HOME}:${JAIL_HOME}" \
--symlink /proc/self/fd:/dev/fd \
2020-05-21 15:11:31 +00:00
--bindmount_ro "${HERE}/entrypoint.sh:${JAIL_HOME}/entrypoint.sh" \
--bindmount_ro "${HERE}/gpg-keygen-params.txt:${JAIL_HOME}/gpg-keygen-params.txt" \
--bindmount_ro /bin --bindmount_ro /sbin \
--bindmount_ro /usr --bindmount_ro /lib --bindmount_ro /lib64 \
--bindmount_ro /dev/null --bindmount_ro /dev/urandom --bindmount_ro /dev/random \
--bindmount_ro /etc/resolv.conf \
2020-05-21 15:11:31 +00:00
--env HOME=/home/proton \
--env PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin \
2020-05-22 21:26:34 +00:00
--env BRIDGE_USER \
--env BRIDGE_PASS \
-- ${BIN} "${1:-}"
2020-05-21 15:11:31 +00:00