3 from twisted.python import usage
4 from allmydata.scripts.common import BasedirMixin, NoDefaultBasedirMixin
6 class CreateClientOptions(BasedirMixin, usage.Options):
8 ["basedir", "C", None, "which directory to create the client in"],
9 ["webport", "p", "tcp:8123:interface=127.0.0.1",
10 "which TCP port to run the HTTP interface on. Use 'none' to disable."],
13 class CreateIntroducerOptions(NoDefaultBasedirMixin, usage.Options):
15 ["basedir", "C", None, "which directory to create the introducer in"],
21 from allmydata import client
22 from twisted.application import service
26 application = service.Application("allmydata_client")
27 c.setServiceParent(application)
33 from allmydata import introducer_and_vdrive
34 from twisted.application import service
36 c = introducer_and_vdrive.IntroducerAndVdrive()
38 application = service.Application("allmydata_introducer")
39 c.setServiceParent(application)
42 def create_client(basedir, config, out=sys.stdout, err=sys.stderr):
43 if os.path.exists(basedir):
44 if os.listdir(basedir):
45 print >>err, "The base directory already exists: %s" % basedir
46 print >>err, "To avoid clobbering anything, I am going to quit now"
47 print >>err, "Please use a different directory, or delete this one"
49 # we're willing to use an empty directory
52 f = open(os.path.join(basedir, "tahoe-client.tac"), "w")
55 if config.get('webport', "none").lower() != "none":
56 f = open(os.path.join(basedir, "webport"), "w")
57 f.write(config['webport'] + "\n")
59 print >>out, "client created in %s" % basedir
60 print >>out, " please copy introducer.furl and vdrive.furl into the directory"
62 def create_introducer(basedir, config, out=sys.stdout, err=sys.stderr):
63 if os.path.exists(basedir):
64 if os.listdir(basedir):
65 print >>err, "The base directory already exists: %s" % basedir
66 print >>err, "To avoid clobbering anything, I am going to quit now"
67 print >>err, "Please use a different directory, or delete this one"
69 # we're willing to use an empty directory
72 f = open(os.path.join(basedir, "tahoe-introducer.tac"), "w")
73 f.write(introducer_tac)
75 print >>out, "introducer created in %s" % basedir
78 ["create-client", None, CreateClientOptions, "Create a client node."],
79 ["create-introducer", None, CreateIntroducerOptions, "Create a introducer node."],
84 "create-client": create_client,
85 "create-introducer": create_introducer,