]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/scripts/create_node.py
Don't include [magic_folder]enabled and local.directory fields by default.
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / scripts / create_node.py
index 9c223bf099411c0050c851cea473fb8733a9adb3..511fb6434a8171251b1bb2f88a2ab76a5f110f46 100644 (file)
@@ -1,11 +1,12 @@
 
 import os, sys
-from allmydata.scripts.common import BasedirMixin, BaseOptions
+from allmydata.scripts.common import BasedirOptions, NoDefaultBasedirOptions
+from allmydata.scripts.default_nodedir import _default_nodedir
 from allmydata.util.assertutil import precondition
-from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_output
+from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_local_unicode_path
 import allmydata
 
-class CreateClientOptions(BasedirMixin, BaseOptions):
+class _CreateBaseOptions(BasedirOptions):
     optParameters = [
         # we provide 'create-node'-time options for the most common
         # configuration knobs. The rest can be controlled by editing
@@ -14,30 +15,30 @@ class CreateClientOptions(BasedirMixin, BaseOptions):
         ("introducer", "i", None, "Specify the introducer FURL to use."),
         ("webport", "p", "tcp:3456:interface=127.0.0.1",
          "Specify which TCP port to run the HTTP interface on. Use 'none' to disable."),
+        ("basedir", "C", None, "Specify which Tahoe base directory should be used. This has the same effect as the global --node-directory option. [default: %s]"
+         % quote_local_unicode_path(_default_nodedir)),
+
         ]
 
-    def getSynopsis(self):
-        return "Usage:  %s create-client [options] [NODEDIR]" % (self.command_name,)
+    # This is overridden in order to ensure we get a "Wrong number of
+    # arguments." error when more than one argument is given.
+    def parseArgs(self, basedir=None):
+        BasedirOptions.parseArgs(self, basedir)
 
+class CreateClientOptions(_CreateBaseOptions):
+    synopsis = "[options] [NODEDIR]"
+    description = "Create a client-only Tahoe-LAFS node (no storage server)."
 
 class CreateNodeOptions(CreateClientOptions):
     optFlags = [
         ("no-storage", None, "Do not offer storage service to other nodes."),
         ]
+    synopsis = "[options] [NODEDIR]"
+    description = "Create a full Tahoe-LAFS node (client+server)."
 
-    def getSynopsis(self):
-        return "Usage:  %s create-node [options] [NODEDIR]" % (self.command_name,)
-
-
-class CreateIntroducerOptions(BasedirMixin, BaseOptions):
-    default_nodedir = None
-
-    optParameters = [
-        ["node-directory", "d", None, "Specify which directory the introducer should be created in. [no default]"],
-    ]
-
-    def getSynopsis(self):
-        return "Usage:  %s create-introducer [options] NODEDIR" % (self.command_name,)
+class CreateIntroducerOptions(NoDefaultBasedirOptions):
+    subcommand_name = "create-introducer"
+    description = "Create a Tahoe-LAFS introducer."
 
 
 client_tac = """
@@ -108,7 +109,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
 
     if os.path.exists(basedir):
         if listdir_unicode(basedir):
-            print >>err, "The base directory %s is not empty." % quote_output(basedir)
+            print >>err, "The base directory %s is not empty." % quote_local_unicode_path(basedir)
             print >>err, "To avoid clobbering anything, I am going to quit now."
             print >>err, "Please use a different directory, or empty this one."
             return -1
@@ -152,19 +153,19 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
     c.write("enabled = false\n")
     c.write("\n")
 
-    c.write("[drop_upload]\n")
+    c.write("[magic_folder]\n")
     c.write("# Shall this node automatically upload files created or modified in a local directory?\n")
-    c.write("enabled = false\n")
-    c.write("# This must be an URI for a writeable directory.\n")
-    c.write("upload.uri =\n")
-    c.write("local.directory = ~/drop_upload\n")
+    c.write("#enabled = false\n")
+    c.write("# To specify the target of uploads, a mutable directory writecap URI must be placed\n"
+            "# in '%s'.\n" % os.path.join('private', 'magic_folder_dircap'))
+    c.write("#local.directory = \n")
     c.write("\n")
 
     c.close()
 
     from allmydata.util import fileutil
     fileutil.make_dirs(os.path.join(basedir, "private"), 0700)
-    print >>out, "Node created in %s" % quote_output(basedir)
+    print >>out, "Node created in %s" % quote_local_unicode_path(basedir)
     if not config.get("introducer", ""):
         print >>out, " Please set [client]introducer.furl= in tahoe.cfg!"
         print >>out, " The node cannot connect to a grid without it."
@@ -184,7 +185,7 @@ def create_introducer(config, out=sys.stdout, err=sys.stderr):
 
     if os.path.exists(basedir):
         if listdir_unicode(basedir):
-            print >>err, "The base directory %s is not empty." % quote_output(basedir)
+            print >>err, "The base directory %s is not empty." % quote_local_unicode_path(basedir)
             print >>err, "To avoid clobbering anything, I am going to quit now."
             print >>err, "Please use a different directory, or empty this one."
             return -1
@@ -199,7 +200,7 @@ def create_introducer(config, out=sys.stdout, err=sys.stderr):
     write_node_config(c, config)
     c.close()
 
-    print >>out, "Introducer created in %s" % quote_output(basedir)
+    print >>out, "Introducer created in %s" % quote_local_unicode_path(basedir)
     return 0