diff --git a/scripts/handle_macos.sh b/scripts/handle_macos.sh index 9474ae55..9c32f7ab 100644 --- a/scripts/handle_macos.sh +++ b/scripts/handle_macos.sh @@ -21,6 +21,7 @@ handle_macos() { install_result=$? if [ $install_result -ne 0 ]; then + printf "%s\n" "$lnd_output" log_error "LND installation failed" $install_result fi diff --git a/scripts/install.sh b/scripts/install.sh index 882df457..87d9842f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,9 +6,10 @@ TMP_LOG_FILE=$(mktemp) log() { local message="$(date '+%Y-%m-%d %H:%M:%S') $1" - echo -e "$message" - # Write to the temporary log file. - echo -e "$(echo "$message" | sed 's/\\e\[[0-9;]*m//g')" >> "$TMP_LOG_FILE" + # Use printf for cross-platform compatibility (macOS echo -e issues) + printf "%b\n" "$message" + # Write to the temporary log file (strip colors) + echo "$message" | sed 's/\\e\[[0-9;]*m//g' >> "$TMP_LOG_FILE" } SCRIPT_VERSION="0.3.0" @@ -35,7 +36,7 @@ download() { if command -v wget &> /dev/null; then wget -q "$url" -O "$dest" elif command -v curl &> /dev/null; then - curl -sL "$url" -o "$dest" + curl -fsL "$url" -o "$dest" else log_error "Neither wget nor curl found. Please install one." 1 fi @@ -112,9 +113,10 @@ else lnd_output=$(install_lnd) install_result=$? - if [ $install_result -ne 0 ]; then - log_error "LND installation failed" $install_result - fi +if [ $install_result -ne 0 ]; then + printf "%s\n" "$lnd_output" + log_error "LND installation failed" $install_result +fi lnd_status=$(echo "$lnd_output" | grep "LND_STATUS:" | cut -d':' -f2) diff --git a/scripts/install_lnd.sh b/scripts/install_lnd.sh index c525572b..ba1cb7d6 100755 --- a/scripts/install_lnd.sh +++ b/scripts/install_lnd.sh @@ -11,6 +11,11 @@ install_lnd() { log "Checking latest LND version..." local api_response=$(download_stdout "https://api.github.com/repos/lightningnetwork/lnd/releases/latest") LND_VERSION=$(json_value "tag_name" "$api_response") + + if [ -z "$LND_VERSION" ]; then + log "${PRIMARY_COLOR}Failed to fetch latest LND version.${RESET_COLOR}" + exit 1 + fi log "Latest LND version: $LND_VERSION" local LND_OS="$OS"; [ "$OS" = "Mac" ] && LND_OS="darwin" diff --git a/scripts/utils.sh b/scripts/utils.sh index 7f5c8ccb..30b88fe5 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -84,7 +84,10 @@ download() { if command -v wget &> /dev/null; then wget -q "$url" -O "$dest" elif command -v curl &> /dev/null; then - curl -sL "$url" -o "$dest" + # -f: fail on HTTP errors (404/500) + # -s: silent + # -L: follow redirects + curl -fsL "$url" -o "$dest" else log "Error: Neither wget nor curl found." return 1 @@ -97,7 +100,7 @@ download_stdout() { if command -v wget &> /dev/null; then wget -qO- "$url" elif command -v curl &> /dev/null; then - curl -sL "$url" + curl -fsL "$url" else log "Error: Neither wget nor curl found." return 1