mac restore

This commit is contained in:
shocknet-justin 2025-11-26 16:25:43 -05:00
parent 438bea47a7
commit 688033769d
3 changed files with 18 additions and 22 deletions

View file

@ -10,13 +10,11 @@ install_lnd() {
USER_NAME=$(whoami) USER_NAME=$(whoami)
log "Checking latest LND version..." log "Checking latest LND version..."
local api_response=$(download_stdout "https://api.github.com/repos/lightningnetwork/lnd/releases/latest") LND_VERSION=$(get_latest_release_tag "lightningnetwork/lnd")
LND_VERSION=$(json_value "tag_name" "$api_response")
if [ -z "$LND_VERSION" ]; then if [ -z "$LND_VERSION" ]; then
# Fallback to a known stable version if GitHub API fails (e.g. rate limit) log "${PRIMARY_COLOR}Failed to fetch latest LND version.${RESET_COLOR}"
LND_VERSION="v0.18.3-beta" exit 1
log "${PRIMARY_COLOR}Warning: Failed to fetch latest LND version from GitHub. Using fallback: ${LND_VERSION}${RESET_COLOR}"
fi fi
log "Latest LND version: $LND_VERSION" log "Latest LND version: $LND_VERSION"

View file

@ -13,11 +13,10 @@ install_nodejs() {
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
if ! command -v nvm &> /dev/null; then if ! command -v nvm &> /dev/null; then
local nvm_api=$(download_stdout "https://api.github.com/repos/nvm-sh/nvm/releases/latest") NVM_VERSION=$(get_latest_release_tag "nvm-sh/nvm")
NVM_VERSION=$(json_value "tag_name" "$nvm_api")
if [ -z "$NVM_VERSION" ]; then if [ -z "$NVM_VERSION" ]; then
NVM_VERSION="v0.39.7" log "Failed to fetch latest NVM version."
log "Warning: Failed to fetch latest NVM version. Using fallback: $NVM_VERSION" return 1
fi fi
download_stdout "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" | bash > /dev/null 2>&1 download_stdout "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" | bash > /dev/null 2>&1
export NVM_DIR="${NVM_DIR}" export NVM_DIR="${NVM_DIR}"

View file

@ -81,28 +81,27 @@ json_value() {
download() { download() {
local url="$1" local url="$1"
local dest="$2" local dest="$2"
if command -v wget &> /dev/null; then if [ "$OS" = "Mac" ]; then
wget -q "$url" -O "$dest"
elif command -v curl &> /dev/null; then
# -f: fail on HTTP errors (404/500)
# -s: silent
# -L: follow redirects
curl -fsL "$url" -o "$dest" curl -fsL "$url" -o "$dest"
else else
log "Error: Neither wget nor curl found." wget -q "$url" -O "$dest"
return 1
fi fi
} }
# Download to stdout (wget or curl) # Download to stdout (wget or curl)
download_stdout() { download_stdout() {
local url="$1" local url="$1"
if command -v wget &> /dev/null; then if [ "$OS" = "Mac" ]; then
wget -qO- "$url"
elif command -v curl &> /dev/null; then
curl -fsL "$url" curl -fsL "$url"
else else
log "Error: Neither wget nor curl found." wget -qO- "$url"
return 1
fi fi
} }
# Get latest release tag from GitHub (via API)
get_latest_release_tag() {
local repo="$1"
local url="https://api.github.com/repos/${repo}/releases/latest"
local api_json=$(download_stdout "$url")
json_value "tag_name" "$api_json"
}