summaryrefslogtreecommitdiff
path: root/host-control
diff options
context:
space:
mode:
Diffstat (limited to 'host-control')
-rwxr-xr-xhost-control47
1 files changed, 43 insertions, 4 deletions
diff --git a/host-control b/host-control
index d0ad0de..71863a0 100755
--- a/host-control
+++ b/host-control
@@ -105,7 +105,7 @@ class host_control():
return None
- def config_copy(self, host, source, sink):
+ def config_copy_command(self, host, source, sink):
source_path = os.path.join(self.config_path(), source)
if self.host_address(host) == self.hostname:
@@ -118,9 +118,33 @@ class host_control():
command = [ "scp", source_path, sink_address ]
+ return command
- self.print_command(command)
- subprocess.call(command)
+ def config_owner_command(self, host, sink, owner):
+ self.print_message("Ownership of " + sink + " to " + owner)
+
+ command_base = [ "chown", owner, sink ]
+
+ if self.host_address(host) == self.hostname:
+ command = command_base
+ else:
+ address = self.ssh_address(host)
+ command = self.ssh_command(address, command_base)
+
+ return command
+
+ def config_mode_command(self, host, sink, mode):
+ self.print_message("Mode of " + sink + " to " + mode)
+
+ command_base = [ "chmod", mode, sink ]
+
+ if self.host_address(host) == self.hostname:
+ command = command_base
+ else:
+ address = self.ssh_address(host)
+ command = self.ssh_command(address, command_base)
+
+ return command
def config_update(self, host, name):
config = self.config_lookup(host, name)
@@ -135,7 +159,22 @@ class host_control():
source = f.split(":")[0]
sink = f.split(":")[1]
- self.config_copy(host, source, sink)
+ command = self.config_copy_command(host, source, sink)
+
+ self.print_command(command)
+ subprocess.call(command)
+
+ if "owner" in config:
+ command = self.config_owner_command(host, sink, config["owner"])
+
+ self.print_command(command)
+ subprocess.call(command)
+
+ if "mode" in config:
+ command = self.config_mode_command(host, sink, str(config["mode"]))
+
+ self.print_command(command)
+ subprocess.call(command)
return 0