Skip to content

Commit

Permalink
Merge pull request #56 from craigcomstock/CFE-3821
Browse files Browse the repository at this point in the history
CFE-3821 Modified cfbs install behavior for easier use
  • Loading branch information
olehermanse authored Nov 1, 2021
2 parents 8e71ebd + b184584 commit ceffe68
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,16 +942,29 @@ def build_command() -> int:
build_steps()


def install_command(destination=None) -> int:
def install_command(args) -> int:
if len(args) > 1:
user_error(
"Only one destination is allowed for command: cfbs install [destination]"
)
if not os.path.exists("out/masterfiles"):
r = build_command()
if r != 0:
return r

if not destination:
if os.getuid() == 0:
destination = "/var/cfengine/masterfiles"
if len(args) > 0:
destination = args[0]
elif os.getuid() == 0:
destination = "/var/cfengine/masterfiles"
else:
destination = os.path.join(os.environ["HOME"], ".cfagent/inputs")
if not destination.startswith("/") and not destination.startswith("./"):
destination = "./" + destination
rm(destination, missing_ok=True)
cp("out/masterfiles", destination)
print("Installed to %s" % destination)
return 0


Expand Down

0 comments on commit ceffe68

Please sign in to comment.