From c1d76ef52919b25ac1282bbe2cab93c621b1a686 Mon Sep 17 00:00:00 2001 From: hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:26:13 +0200 Subject: [PATCH] Stop relying on Bash being located at /bin/bash (#580) --- resources/images/bitcoin/insecure/entrypoint.sh | 2 +- resources/scripts/connect_logging.sh | 2 +- resources/scripts/setup_user_contexts.sh | 2 +- src/warnet/bitcoin.py | 2 +- src/warnet/process.py | 6 ++---- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/resources/images/bitcoin/insecure/entrypoint.sh b/resources/images/bitcoin/insecure/entrypoint.sh index 56d55b5d6..c81d95aa9 100755 --- a/resources/images/bitcoin/insecure/entrypoint.sh +++ b/resources/images/bitcoin/insecure/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e if [ "$(echo "$1" | cut -c1)" = "-" ]; then diff --git a/resources/scripts/connect_logging.sh b/resources/scripts/connect_logging.sh index 20ea4a63e..f09ffeeaf 100755 --- a/resources/scripts/connect_logging.sh +++ b/resources/scripts/connect_logging.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # NO `set -e` here so an error does not exit the script POD_NAME=$(kubectl get pods --namespace warnet-logging -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=loki-grafana" -o jsonpath="{.items[0].metadata.name}") diff --git a/resources/scripts/setup_user_contexts.sh b/resources/scripts/setup_user_contexts.sh index 8d1a06eec..5a4b631b2 100755 --- a/resources/scripts/setup_user_contexts.sh +++ b/resources/scripts/setup_user_contexts.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Function to check if a command exists command_exists() { diff --git a/src/warnet/bitcoin.py b/src/warnet/bitcoin.py index 8be750613..c4a4aae53 100644 --- a/src/warnet/bitcoin.py +++ b/src/warnet/bitcoin.py @@ -189,7 +189,7 @@ def get_messages(tank_a: str, tank_b: str, chain: str): import subprocess blob = subprocess.run( - cmd, shell=True, capture_output=True, executable="/bin/bash" + cmd, shell=True, capture_output=True, executable="bash" ).stdout # Parse the blob diff --git a/src/warnet/process.py b/src/warnet/process.py index fd5b2a04b..6161774b1 100644 --- a/src/warnet/process.py +++ b/src/warnet/process.py @@ -2,9 +2,7 @@ def run_command(command: str) -> str: - result = subprocess.run( - command, shell=True, capture_output=True, text=True, executable="/bin/bash" - ) + result = subprocess.run(command, shell=True, capture_output=True, text=True, executable="bash") if result.returncode != 0: raise Exception(result.stderr) return result.stdout @@ -12,7 +10,7 @@ def run_command(command: str) -> str: def stream_command(command: str) -> bool: process = subprocess.Popen( - ["/bin/bash", "-c", command], + ["bash", "-c", command], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,