Browse code

Parse arguments for compatibility with mount.

Xavier G authored on 05/04/2020 19:20:40
Showing 1 changed files

... ...
@@ -11,6 +11,7 @@ import sys
11 11
 import stat
12 12
 import yaml
13 13
 import errno
14
+import argparse
14 15
 import threading
15 16
 
16 17
 # Excerpt from `apt show python3-fusepy`:
... ...
@@ -288,11 +289,17 @@ class CombinedFS(Operations):
288 289
 		# return EINVAL:
289 290
 		raise FuseOSError(errno.EINVAL)
290 291
 
291
-def main(conf_path, mountpoint):
292
+def main(conf_path, mountpoint, foreground):
292 293
 	conf = {}
293 294
 	with open(conf_path) as conf_file:
294 295
 		conf = yaml.load(conf_file.read())
295
-	FUSE(CombinedFS(conf), mountpoint, foreground=True, ro=True, default_permissions=True, allow_other=True)
296
+	FUSE(CombinedFS(conf), mountpoint, foreground=foreground, ro=True, default_permissions=True, allow_other=True)
296 297
 
297 298
 if __name__ == '__main__':
298
-	main(sys.argv[1], sys.argv[2])
299
+	parser = argparse.ArgumentParser(description='Expose a transformed, version of Let\'s Encrypt / Certbot\'s "live" directory')
300
+	parser.add_argument('conf_path', help='CombinedFS configuration file')
301
+	parser.add_argument('mountpoint', help='mount point')
302
+	parser.add_argument('-o', dest='options', help='mount options (ignored, only there for compatibility purposes)')
303
+	parser.add_argument('-f', '--foreground', dest='foreground', help='run in the foreground', action='store_true')
304
+	args = parser.parse_args()
305
+	main(args.conf_path, args.mountpoint, args.foreground)