Browse code

Split proot options into multiple bash variables.

Xavier G authored on 29/02/2016 14:53:01
Showing 1 changed files
... ...
@@ -73,47 +73,65 @@ if [ -x "$(which proot)" ]; then
73 73
 	echo '  Do you need to download files?'
74 74
 	echo "    They should end up in ${download_dir}"
75 75
 
76
-	# Leverage proot to make iceweasel believe that:
77
-	#   - the home directory is almost empty
76
+	# Leverage proot to make the browser believe that:
78 77
 	#   - /home is either empty or contains only our home
78
+	slash_home_options="--bind=${slash_home_dir}:/home"
79
+	#   - the home directory is almost empty
80
+	home_options="--bind=${home_dir}:${HOME}"
79 81
 	#   - its configuration directory is still there
80 82
 	#   - its cache directory is still there
83
+	browser_conf_options="
84
+		--bind=${HOME}/.mozilla/firefox:${HOME}/.mozilla/firefox \
85
+		--bind=${HOME}/.cache/mozilla/firefox:${HOME}/.cache/mozilla/firefox"
81 86
 	#   - its download directory is still there
82 87
 	#     (at least the one for English speakers)
88
+	download_options="--bind=${download_dir}:${HOME}/Downloads"
83 89
 	#   - a ~/Uploads directory is present
90
+	upload_options="--bind=${upload_dir}:${HOME}/Uploads"
84 91
 	#   - ~/.adobe and ~/.macromedia are still there
85 92
 	#     (for the sake of Flash Player and other plugins)
93
+	adobe_options="
94
+		--bind=${HOME}/.adobe:${HOME}/.adobe \
95
+		--bind=${HOME}/.macromedia:${HOME}/.macromedia"
86 96
 	#   - various directories related to Java applets are still there
87 97
 	#     (assuming IcedTea-Web >= 1.5 / OpenJDK)
98
+	java_options="
99
+		--bind=${HOME}/.config/icedtea-web:${HOME}/.config/icedtea-web
100
+		--bind=${HOME}/.cache/icedtea-web:${HOME}/.cache/icedtea-web
101
+		--bind=${HOME}/.java:${HOME}/.java
102
+		--bind=${HOME}/.local/share/applications/javaws:${HOME}/.local/share/application/javaws"
88 103
 	#   - /tmp is empty
89 104
 	#     (as in: do not even try to mess with the Unix sockets to ssh-agent)
105
+	tmp_options="--bind=${tmp_dir}:/tmp"
90 106
 	#   - /sys is simply absent
91 107
 	#     (Firefox tries to reach various things under /sys/devices/system/ but
92 108
 	#     seems to cope without it)
109
+	sys_options="--bind=/dev/null:/sys"
93 110
 	#   - /proc is still there, unless you want to hit that very detailed error:
94 111
 	#       too much recursion
95 112
 	#   - /proc/sys is still there, unless you want to hit that charming error:
96 113
 	#       FATAL: error reading `/proc/sys/crypto/fips_enabled' in libgcrypt: Not a directory
114
+	proc_options=""
97 115
 	#   - /dev is present yet minimalist
116
+	dev_options="
117
+		--bind=${dev_dir}:/dev
118
+		--bind=/dev/null:/dev/null
119
+		--bind=/dev/random:/dev/random
120
+		--bind=/dev/urandom:/dev/urandom"
98 121
 	proot \
99
-		-b "${slash_home_dir}:/home" \
100
-		-b "${home_dir}:${HOME}" \
101
-		-b "${HOME}/.mozilla/firefox:${HOME}/.mozilla/firefox" \
102
-		-b "${HOME}/.cache/mozilla/firefox:${HOME}/.cache/mozilla/firefox" \
103
-		-b "${download_dir}:${HOME}/Downloads" \
104
-		-b "${upload_dir}:${HOME}/Uploads" \
105
-		-b "${HOME}/.adobe:${HOME}/.adobe" \
106
-		-b "${HOME}/.macromedia:${HOME}/.macromedia" \
107
-		-b "${HOME}/.config/icedtea-web:${HOME}/.config/icedtea-web" \
108
-		-b "${HOME}/.cache/icedtea-web:${HOME}/.cache/icedtea-web" \
109
-		-b "${HOME}/.java:${HOME}/.java" \
110
-		-b "${HOME}/.local/share/applications/javaws:${HOME}/.local/share/application/javaws" \
111
-		-b "${tmp_dir}:/tmp" \
112
-		-b "/dev/null:/sys" \
113
-		-b "${dev_dir}:/dev" \
114
-		-b "/dev/null:/dev/null" \
115
-		-b "/dev/random:/dev/random" \
116
-		-b "/dev/urandom:/dev/urandom" \
122
+		${pre_options} \
123
+		${slash_home_options} \
124
+		${home_options} \
125
+		${browser_conf_options} \
126
+		${download_options} \
127
+		${upload_options} \
128
+		${adobe_options} \
129
+		${java_options} \
130
+		${tmp_options} \
131
+		${sys_options} \
132
+		${proc_options} \
133
+		${dev_options} \
134
+		${post_options} \
117 135
 		--cwd="${HOME}" \
118 136
 		"${browser_path}" "$@"
119 137
 else