Implement persistent storage and start mode
This commit is contained in:
parent
076e355366
commit
6a89682d5f
@ -2,20 +2,49 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
BRIDGE="${BRIDGE:-/usr/bin/protonmail-bridge}"
|
BRIDGE="${BRIDGE:-/usr/bin/protonmail-bridge}"
|
||||||
|
INPIPE=/tmp/input
|
||||||
|
|
||||||
|
|
||||||
|
setup() {
|
||||||
gpg --generate-key --batch gpg-keygen-params.txt
|
gpg --generate-key --batch gpg-keygen-params.txt
|
||||||
pass init proton
|
pass init proton
|
||||||
|
|
||||||
mkfifo input
|
bridge-cli
|
||||||
sleep infinity > input &
|
|
||||||
$BRIDGE --cli < input &
|
|
||||||
bridge_pid=$!
|
|
||||||
|
|
||||||
echo "login" > input
|
|
||||||
echo "$BRIDGE_USER" > input
|
|
||||||
echo "$BRIDGE_PASS" > input
|
|
||||||
echo "info" > input
|
|
||||||
|
|
||||||
|
echo "login" > $INPIPE
|
||||||
|
echo "$BRIDGE_USER" > $INPIPE
|
||||||
|
echo "$BRIDGE_PASS" > $INPIPE
|
||||||
|
echo "exit" > $INPIPE
|
||||||
wait $bridge_pid
|
wait $bridge_pid
|
||||||
|
}
|
||||||
|
|
||||||
|
bridge-cli() {
|
||||||
|
mkfifo $INPIPE
|
||||||
|
sleep infinity > $INPIPE &
|
||||||
|
$BRIDGE --cli < $INPIPE &
|
||||||
|
bridge_pid=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
bridge-cli
|
||||||
|
|
||||||
|
echo "info" > $INPIPE
|
||||||
|
wait $bridge_pid
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
setup)
|
||||||
|
setup
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
test)
|
||||||
|
bash -i
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: isolated_protonmail_bridge.sh [setup|start|test]"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
@ -3,13 +3,21 @@ set -euo pipefail
|
|||||||
|
|
||||||
HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||||||
JAIL_HOME=/home/proton
|
JAIL_HOME=/home/proton
|
||||||
DEFAULT_BIN=entrypoint.sh
|
BIN="${BIN:-entrypoint.sh}"
|
||||||
BIN="${1:-${DEFAULT_BIN}}"
|
|
||||||
|
if [[ -z "${ROOTFS:-}" ]]; then
|
||||||
|
echo "Please set the ROOTFS envvar!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
ROOTFS="$(realpath "${ROOTFS}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "${ROOTFS}/dev/fd"
|
||||||
|
|
||||||
nsjail -Mo \
|
nsjail -Mo \
|
||||||
--disable_clone_newnet \
|
--disable_clone_newnet \
|
||||||
|
--chroot "${ROOTFS}" --rw \
|
||||||
--cwd "${JAIL_HOME}" \
|
--cwd "${JAIL_HOME}" \
|
||||||
--tmpfsmount / \
|
|
||||||
--tmpfsmount /tmp --tmpfsmount /run \
|
--tmpfsmount /tmp --tmpfsmount /run \
|
||||||
--symlink /proc/self/fd:/dev/fd \
|
--symlink /proc/self/fd:/dev/fd \
|
||||||
--bindmount_ro "${HERE}/entrypoint.sh:${JAIL_HOME}/entrypoint.sh" \
|
--bindmount_ro "${HERE}/entrypoint.sh:${JAIL_HOME}/entrypoint.sh" \
|
||||||
@ -22,5 +30,5 @@ nsjail -Mo
|
|||||||
--env PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin \
|
--env PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin \
|
||||||
--env BRIDGE_USER \
|
--env BRIDGE_USER \
|
||||||
--env BRIDGE_PASS \
|
--env BRIDGE_PASS \
|
||||||
-- ${BIN}
|
-- ${BIN} "${1:-}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user