Skip to content

Commit

Permalink
fix binary wrapper copy
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed May 28, 2024
1 parent 063799c commit 46247f4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,19 @@ def run_command(cmd, env=None, cwd=None):
raise Exception(f"Failed running {' '.join(cmd)} with error: {result.stderr.decode('utf-8')}")


def copy_files(src_pattern, dest_dir):
"""
Copies files matching the src_pattern to the destination directory.
Parameters:
src_pattern (str): The source file pattern to match.
dest_dir (str): The destination directory where files should be copied.
"""
files = glob.glob(src_pattern)
for file in files:
shutil.copy(file, dest_dir)


def manage_ansible_venv(recreate=False):
if os.path.isdir("/srv/ansible/venv/bin") and not os.path.isfile("/srv/ansible/venv/bin/python3.12"):
print("Python 3.12 not detected in venv, forcing recreate.")
Expand Down Expand Up @@ -751,8 +764,7 @@ def manage_ansible_venv(recreate=False):
"--upgrade", "--requirement", "/srv/git/sb/requirements-saltbox.txt"]
run_command(cmd)

cmd = ["cp", "/srv/ansible/venv/bin/{ansible*,certbot,apprise}", "/usr/local/bin/"]
run_command(cmd)
copy_files("/srv/ansible/venv/bin/{ansible*,certbot,apprise}", "/usr/local/bin/")

cmd = ["chown", "-R", f"{SALTBOX_USER}:{SALTBOX_USER}", ansible_venv_path]
run_command(cmd)
Expand Down

0 comments on commit 46247f4

Please sign in to comment.