chiark / gitweb /
server: specify an identity file for SSH when rsyncing
authorHans-Christoph Steiner <hans@eds.org>
Thu, 5 Jun 2014 20:21:12 +0000 (16:21 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 5 Jun 2014 20:21:12 +0000 (16:21 -0400)
This allows the SSH key used to sync with the server to be specified via
the config.py or the command line.  I need it for running automated tests
and setups.

completion/bash-completion
examples/config.py
fdroidserver/server.py

index 5916c6691993be21ab896dbf4b8aa431651eefda..42be8de3935f809514303acbeec8916d3a07294e 100644 (file)
@@ -247,8 +247,8 @@ __complete_stats() {
 }
 
 __complete_server() {
-       opts="-h -v -q"
-       lopts="--help --verbose --quiet update"
+       opts="-h -i -v -q"
+       lopts="--help --identity-file --verbose --quiet update"
        __complete_options
 }
 
index 501a4f1e48256b721ea152ad944a2baba92daef6..df1ec79b73ab79c5d6bc2b2c9737ff376ca839c8 100644 (file)
@@ -105,6 +105,9 @@ keyaliases['com.example.another.plugin'] = '@com.example.another'
 # sub-directories (i.e. /var/www/packagerepos/fdroid).
 # serverwebroot = 'user@example:/var/www/fdroid'
 
+# optionally specific which identity file to use when using rsync over SSH
+# identity_file = '~/.ssh/fdroid_id_rsa'
+
 # To upload the repo to an Amazon S3 bucket using `fdroid server update`.
 # Warning, this deletes and recreates the whole fdroid/ directory each
 # time. This is based on apache-libcloud, which supports basically all cloud
index 833a88e02ffa2ff25dabba65cfe0dc9d1e76c01b..0d5874ec67be40efb9dfb60df1616bf1676691e0 100644 (file)
@@ -121,6 +121,10 @@ def update_serverwebroot(repo_section):
         rsyncargs += ['--verbose']
     if options.quiet:
         rsyncargs += ['--quiet']
+    if options.identity_file is not None:
+        rsyncargs += ['-e', 'ssh -i ' + options.identity_file]
+    if 'identity_file' in config:
+        rsyncargs += ['-e', 'ssh -i ' + config['identity_file']]
     indexxml = os.path.join(repo_section, 'index.xml')
     indexjar = os.path.join(repo_section, 'index.jar')
     # serverwebroot is guaranteed to have a trailing slash in common.py
@@ -142,6 +146,8 @@ def main():
 
     # Parse command line...
     parser = OptionParser()
+    parser.add_option("-i", "--identity-file", default=None,
+                      help="Specify an identity file to provide to SSH for rsyncing")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Spew out even more information than normal")
     parser.add_option("-q", "--quiet", action="store_true", default=False,