-
Notifications
You must be signed in to change notification settings - Fork 0
/
firefox_ssb.sh
executable file
·83 lines (73 loc) · 2.04 KB
/
firefox_ssb.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
firefox_ssb() {
if [ -n "$SSB_DEBUG" ]; then
set -x
SSB_DETACH=""
SSB_RM=""
else
SSB_DETACH="--detach"
SSB_RM="--rm"
fi
SITE=$1; shift
if [ -z "$SITE" ]; then
echo "a site name argument is required" 2>&1
return 1
fi
if ! (printf '%s' "$SITE" | grep -Eq '^[A-Za-z0-9-]{1,}$'); then
echo "the site name argument must only contain letters, numbers, dashes" 2>&1
return 1
fi
if ! [ -d "$HOME" ]; then
echo "the HOME environment variable must be set" 2>&1
return 1
fi
SSB_BASE="${HOME}/.firefox_ssb"
if ! [ -d "$SSB_BASE" ]; then
if ! mkdir -p "$SSB_BASE"; then
echo "unable to make ssb base directory \"${SSB_BASE}\"" 2>&1
return 1
fi
fi
# 15-May-2024 disabled for now
#SECCOMP_PROFILE="${SSB_BASE}/seccomp.json"
#if ! [ -f "$SECCOMP_PROFILE" ]; then
# if ! curl -sSLf --tlsv1.2 -o "$SECCOMP_PROFILE" \
# "https://raw.githubusercontent.com/backplane/conex/master/firefox/seccomp.json"; then
# echo "unable to obtain seccomp profile from github" 2>&1
# return 1
# fi
#fi
#
# --security-opt "seccomp=${SECCOMP_PROFILE}"
# not on macOS:
# --device /dev/snd
# --device /dev/dri
# --volume "/tmp/.X11-unix:/tmp/.X11-unix"
# --volume /dev/shm:/dev/shm
# if DISPLAY is blank or a file path, set it to docker container's host address
case "${DISPLAY:-}" in
""|/*)
DISPLAY="host.docker.internal:0"
;;
esac
docker run \
$SSB_DETACH \
$SSB_RM \
--interactive \
--tty \
--cpuset-cpus "${SSB_CPUS:-0}" \
--memory "${SSB_MEM:-512mb}" \
--env "DISPLAY" \
--volume "firefox_ssb_${SITE}:/data" \
--volume "${HOME}/Downloads:/home/user/Downloads" \
--name "firefox_ssb_${SITE}" \
"${FIREFOX_SSB_IMAGE:-backplane/firefox}" \
"$@"
[ -n "$SSB_DEBUG" ] && printf '%s\n' \
"" \
"In debug mode this exited container is not automatically removed. To remote it, run:" \
"" \
"docker container rm 'firefox_ssb_${SITE}'" \
""
}
[ -n "$IMPORT" ] || firefox_ssb "$@"