Browse code

Group our directories together using mktemp.

Xavier G authored on 28/02/2016 15:26:21
Showing 2 changed files
... ...
@@ -2,4 +2,3 @@
2 2
 - Make the proot'ing configurable (typically via a configuration file, e.g.
3 3
   ~/.config/prooties/browser-wrapper.<browser>.conf
4 4
 - If needed, rewrite in Perl instead of bash
5
-- Use mktemp instead of suffixing directories with pids?
... ...
@@ -42,12 +42,18 @@ specific_config_path="${HOME}/.config/browser-wrapper/${invoked_name}.conf"
42 42
 if [ -x "$(which proot)" ]; then
43 43
 	echo "proot is present and will be used to mask some directories"
44 44
 
45
+	# Base directory for our crap
46
+	work_dir_base="/run/user/$(id -u)/browser-wrapper"
47
+	mk_dir "${work_dir_base}" 0700
48
+	work_dir="$(mktemp --directory "${work_dir_base}/$$.XXXXXXXX")" || \
49
+		exit_with_message 110 "Unable to create working directory, aborting."
50
+
45 51
 	# Directory to replace $HOME
46
-	home_dir="/run/user/$(id -u)/home.$$"
52
+	home_dir="${work_dir}/home"
47 53
 	# Directory to replace /tmp
48
-	tmp_dir="/run/user/$(id -u)/tmp.$$"
54
+	tmp_dir="${work_dir}/tmp"
49 55
 	# Empty dir to replace /dev
50
-	dev_dir="/run/user/$(id -u)/dev.$$"
56
+	dev_dir="${work_dir}/dev"
51 57
 	# Directory for uploads
52 58
 	upload_dir="${HOME}/Uploads"
53 59
 	# Directory for downloads