forked from niclan/Javafox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavafox
executable file
·46 lines (37 loc) · 1.15 KB
/
javafox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
XSOCK=/tmp/.X11-unix
XAUTHD="$(mktemp -d)"
XAUTH="$XAUTHD/xauth"
OS="$(uname)"
HOST_HOME_DIR_PARAM=""
if [ "$OS" == "Darwin" ]; then
xhost + 127.0.0.1
DISPLAY=host.docker.internal:0
fi
if [ "$OS" == "Linux" ]; then
# Mount local home directory (read only), remove :ro for read/write access
HOST_HOME_DIR_PARAM="-v $HOME:/home/ffuser/host_home/:ro"
echo "Mounting host's home directory to /home/ffuser/host_home/"
fi
BASE="${HOME}/.javafox"
me=$(basename $0)
case $me in
firefox-*)
IMAGE=${me/-/:}
BASE="${BASE}/instance/${me}"
;;
*)
IMAGE=javafox ;;
esac
# xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
xauth extract $XAUTH $DISPLAY
mkdir -p "${BASE}/.mozilla"
chmod 1777 "${BASE}/.mozilla"
mkdir -p "${BASE}/.java/deployment/security"
touch "${BASE}/.java/deployment/security/exception.sites"
docker run -ti --rm --net=host -v $XSOCK:$XSOCK -v $XAUTHD:$XAUTHD \
-e XAUTHORITY=$XAUTH -e DISPLAY=$DISPLAY \
-v "${BASE}/.java:/home/ffuser/.java" \
$HOST_HOME_DIR_PARAM \
-v "${BASE}/.mozilla:/home/ffuser/.mozilla" ${IMAGE} "$@"
rm -rf $XAUTHD