Skip to content

Commit

Permalink
Merge pull request #109 from victormlg/CFE-4446-check-binaries-in-path
Browse files Browse the repository at this point in the history
Added check if binaries are in path
  • Loading branch information
olehermanse authored Jan 8, 2025
2 parents f86e5a4 + cf2e698 commit a22a1d7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cf_remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,23 @@ def deploy_masterfiles(host, tarball, *, connection=None):
scp(tarball, host, connection=connection, rename="masterfiles.tgz")
tarball = "masterfiles.tgz"
ssh_cmd(connection, "tar -xzf %s" % tarball)

cfagent_path = ""
if not ssh_sudo(connection, "command -v cf-agent"):
log.debug("cf-agent is not in $PATH")

if ssh_cmd(connection, "command -v /var/cfengine/bin/cf-agent"):
cfagent_path = "/var/cfengine/bin/"
else:
user_error("Cannot find the path to cf-agent.")

commands = [
"rm -rf /var/cfengine/masterfiles.delete",
"mv /var/cfengine/masterfiles /var/cfengine/masterfiles.delete",
"mv masterfiles /var/cfengine/masterfiles",
"rm -rf /var/cfengine/masterfiles.delete",
"cf-agent -Kf update.cf",
"cf-agent -K",
"{}cf-agent -Kf update.cf".format(cfagent_path),
"{}cf-agent -K".format(cfagent_path),
]
combined = " && ".join(commands)
print("Running: '%s'" % combined)
Expand Down

0 comments on commit a22a1d7

Please sign in to comment.