]> arthur.barton.de Git - bup.git/blobdiff - cmd/on-cmd.py
cleanup-mounts-under: Don't fail when /proc/mounts isn't readable
[bup.git] / cmd / on-cmd.py
index da7be3757ff32904718f8bd48c1313de58c9f2b8..cebff1aab52ee13aab85cf86e03b7486fa66ef04 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 import sys, os, struct, getopt, subprocess, signal
-from bup import options, ssh
+from bup import options, ssh, path
 from bup.helpers import *
 
 optspec = """
@@ -8,7 +8,7 @@ bup on <hostname> index ...
 bup on <hostname> save ...
 bup on <hostname> split ...
 """
-o = options.Options('bup on', optspec, optfunc=getopt.getopt)
+o = options.Options(optspec, optfunc=getopt.getopt)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 if len(extra) < 2:
     o.fatal('arguments expected')
@@ -28,17 +28,21 @@ p = None
 ret = 99
 
 try:
-    hostname = extra[0]
+    hp = extra[0].split(':')
+    if len(hp) == 1:
+        (hostname, port) = (hp[0], None)
+    else:
+        (hostname, port) = hp
+
     argv = extra[1:]
-    p = ssh.connect(hostname, 'on--server')
+    p = ssh.connect(hostname, port, 'on--server')
 
     argvs = '\0'.join(['bup'] + argv)
     p.stdin.write(struct.pack('!I', len(argvs)) + argvs)
     p.stdin.flush()
 
-    main_exe = os.environ.get('BUP_MAIN_EXE') or sys.argv[0]
-    sp = subprocess.Popen([main_exe, 'server'], stdin=p.stdout, stdout=p.stdin)
-
+    sp = subprocess.Popen([path.exe(), 'server'],
+                          stdin=p.stdout, stdout=p.stdin)
     p.stdin.close()
     p.stdout.close()