Skip to content
Snippets Groups Projects
run-client.py 1.44 KiB
Newer Older
  • Learn to ignore specific revisions
  • #
    # Create a PrivateStorage.io-enabled Tahoe-LAFS client node and run it as a
    # daemon.  Exit with success when we think we've started it.
    #
    
    
    from os import environ
    from sys import argv
    from shutil import which
    from subprocess import check_output
    
    from configparser import ConfigParser
    
        (nodePath, introducerFURL, issuerURL) = argv[1:]
    
    
        run(["tahoe", "--version"])
        run([
            "tahoe", "create-client",
            "--shares-needed", "1",
            "--shares-happy", "1",
            "--shares-total", "1",
            "--introducer", introducerFURL,
    
        # Add necessary ZKAPAuthorizer configuration bits.
        config = ConfigParser()
        with open("/tmp/client/tahoe.cfg") as cfg:
            config.read_file(cfg)
    
        config.set(u"client", u"storage.plugins", u"privatestorageio-zkapauthz-v1")
        config.add_section(u"storageclient.plugins.privatestorageio-zkapauthz-v1")
        config.set(u"storageclient.plugins.privatestorageio-zkapauthz-v1", u"redeemer", u"ristretto")
    
        config.set(u"storageclient.plugins.privatestorageio-zkapauthz-v1", u"ristretto-issuer-root-url", issuerURL)
    
    
        with open("/tmp/client/tahoe.cfg", "wt") as cfg:
            config.write(cfg)
    
    
        run([
            "daemonize",
            "-o", "/tmp/stdout",
            "-e", "/tmp/stderr",
            which("tahoe"), "run", "/tmp/client",
        ])
    
    def run(argv):
        print("{}: {}".format(argv, check_output(argv)))
    
    
    if __name__ == '__main__':
        main()