From 8dbd283a8ad601dbf121650d8f841d7a944ea47f Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 24 Oct 2023 19:53:48 +0300 Subject: [PATCH] Simplifying deployment utils and making them more robust --- deploy.inc.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/deploy.inc.php b/deploy.inc.php index 13ca427..5b11a69 100644 --- a/deploy.inc.php +++ b/deploy.inc.php @@ -59,20 +59,6 @@ function deploy_declare_node($name, array $props) throw new Exception("Declaration '$name' already exists"); $decl = new DeployNode($name, $props); - $deploy_dir = '/home/' . $decl->get('user') . '/' . $decl->get('dir'); - //for convenience - $decl->set("deploy_dir", $deploy_dir); - - //checking deploy_dir conflicts - foreach($DEPLOY_NODES as $other_name => $other_decl) - { - foreach($other_decl->get('hosts') as $other_host) - { - foreach($decl->get('hosts') as $host) - if($host == $other_host && $other_decl->get('deploy_dir') === $deploy_dir) - throw new Exception("Deploy directory '$deploy_dir' conflicts on nodes '$other_name' and '$name' for host '$host'"); - } - } $DEPLOY_NODES[$name] = $decl; } @@ -288,6 +274,7 @@ function deploy_put_file($name, $path, $contents, $opts = 0) function deploy_scp_put_file($name, $local_path, $remote_path, $opts = 0) { $decl = deploy_get_node($name); + $remote_path = deploy_str($decl, $remote_path); $user = $decl->get('user'); @@ -420,13 +407,14 @@ function deploy_get_file($name, $path, $opts = 0) $decl = deploy_get_node($name); foreach($decl->get('hosts') as $host) { + $path = deploy_str($decl, $path); + if(($opts & DEPLOY_OPT_SILENT) == 0) echo "[GET] $host: $path\n"; if($host !== "localhost") { $ssh = deploy_get_ssh($decl, $host); - $path = deploy_str($decl, $path); $scp = new SCP($ssh); $files[$host] = $scp->get($path); }