From ca19799c5ddda6dda8b1273becd6e4b4f057703f Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Wed, 3 Jul 2024 17:03:06 -0400 Subject: [PATCH 01/16] deploy --- deploy.sh | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/deploy.sh b/deploy.sh index 7f14b2ac..7d0ba72c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -26,14 +26,20 @@ fi check_homebrew() { if ! command -v brew &> /dev/null; then log "${PRIMARY_COLOR}Homebrew not found. Installing Homebrew...${RESET_COLOR}" - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || { + log "${PRIMARY_COLOR}Failed to install Homebrew.${RESET_COLOR}" + exit 1 + } fi } install_rsync_mac() { check_homebrew log "${PRIMARY_COLOR}Installing${RESET_COLOR} rsync using Homebrew..." - brew install rsync + brew install rsync || { + log "${PRIMARY_COLOR}Failed to install rsync.${RESET_COLOR}" + exit 1 + } } create_launchd_plist() { @@ -90,6 +96,7 @@ handle_macos() { install_rsync_mac install_nodejs install_lightning_pub + create_launchd_plist # Ensure this function is called start_services_mac } @@ -147,7 +154,10 @@ install_lnd() { log "${PRIMARY_COLOR}Downloading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR}..." # Start the download - wget -q $LND_URL -O lnd.tar.gz + wget -q $LND_URL -O lnd.tar.gz || { + log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}" + exit 1 + } # Check if LND is already running and stop it if necessary (Linux) if [ "$OS" = "Linux" ] && [ "$SYSTEMCTL_AVAILABLE" = true ]; then @@ -159,7 +169,10 @@ install_lnd() { log "${PRIMARY_COLOR}systemctl not found. Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}" fi - tar -xzf lnd.tar.gz -C ~/ > /dev/null + tar -xzf lnd.tar.gz -C ~/ > /dev/null || { + log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}" + exit 1 + } rm lnd.tar.gz mv lnd-* lnd @@ -209,7 +222,10 @@ install_nodejs() { log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}" fi - nvm install --lts + nvm install --lts || { + log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}" + exit 1 + } log "Node.js LTS installation completed." } @@ -217,9 +233,15 @@ install_nodejs() { install_lightning_pub() { log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master" - wget $REPO_URL -O lightning_pub.tar.gz > /dev/null 2>&1 + wget $REPO_URL -O lightning_pub.tar.gz > /dev/null 2>&1 || { + log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}" + exit 1 + } mkdir -p lightning_pub_temp - tar -xvzf lightning_pub.tar.gz -C lightning_pub_temp --strip-components=1 > /dev/null 2>&1 + tar -xvzf lightning_pub.tar.gz -C lightning_pub_temp --strip-components=1 > /dev/null 2>&1 || { + log "${PRIMARY_COLOR}Failed to extract Lightning.Pub.${RESET_COLOR}" + exit 1 + } rm lightning_pub.tar.gz if ! command -v rsync &> /dev/null; then @@ -254,9 +276,10 @@ install_lightning_pub() { log "${PRIMARY_COLOR}Installing${RESET_COLOR} npm dependencies..." - npm install > npm_install.log 2>&1 & - npm_pid=$! - wait $npm_pid + npm install > npm_install.log 2>&1 || { + log "${PRIMARY_COLOR}Failed to install npm dependencies.${RESET_COLOR}" + exit 1 + } log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} installation completed." } @@ -373,4 +396,4 @@ else install_nodejs install_lightning_pub start_services -fi +fi \ No newline at end of file From 4017e8ab5c3fb227f591afbf5895f61e3a7a3609 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 16:19:24 -0400 Subject: [PATCH 02/16] deploy --- scripts/check_homebrew.sh | 11 ++++ scripts/create_launchd_plist.sh | 43 +++++++++++++++ scripts/install.sh | 43 +++++++++++++++ scripts/install_lightning_pub.sh | 55 +++++++++++++++++++ scripts/install_lnd.sh | 78 +++++++++++++++++++++++++++ scripts/install_nodejs.sh | 36 +++++++++++++ scripts/install_rsync_mac.sh | 10 ++++ scripts/start_services.sh | 93 ++++++++++++++++++++++++++++++++ scripts/start_services_mac.sh | 17 ++++++ scripts/utils.sh | 40 ++++++++++++++ 10 files changed, 426 insertions(+) create mode 100755 scripts/check_homebrew.sh create mode 100755 scripts/create_launchd_plist.sh create mode 100755 scripts/install.sh create mode 100755 scripts/install_lightning_pub.sh create mode 100755 scripts/install_lnd.sh create mode 100755 scripts/install_nodejs.sh create mode 100755 scripts/install_rsync_mac.sh create mode 100755 scripts/start_services.sh create mode 100755 scripts/start_services_mac.sh create mode 100755 scripts/utils.sh diff --git a/scripts/check_homebrew.sh b/scripts/check_homebrew.sh new file mode 100755 index 00000000..fd58489e --- /dev/null +++ b/scripts/check_homebrew.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +check_homebrew() { + if ! command -v brew &> /dev/null; then + log "${PRIMARY_COLOR}Homebrew not found. Installing Homebrew...${RESET_COLOR}" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || { + log "${PRIMARY_COLOR}Failed to install Homebrew.${RESET_COLOR}" + exit 1 + } + fi +} diff --git a/scripts/create_launchd_plist.sh b/scripts/create_launchd_plist.sh new file mode 100755 index 00000000..9964a1fe --- /dev/null +++ b/scripts/create_launchd_plist.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +create_launchd_plist() { + create_plist() { + local plist_path=$1 + local label=$2 + local program_args=$3 + local working_dir=$4 + + if [ -f "$plist_path" ]; then + log "${PRIMARY_COLOR}${label} already exists. Skipping creation.${RESET_COLOR}" + else + cat < "$plist_path" + + + + + Label + ${label} + ProgramArguments + + ${program_args} + + WorkingDirectory + ${working_dir} + RunAtLoad + + KeepAlive + + + +EOF + fi + } + USER_HOME=$(eval echo ~$(whoami)) + NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${USER_HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" + LAUNCH_AGENTS_DIR="${USER_HOME}/Library/LaunchAgents" + + create_plist "${LAUNCH_AGENTS_DIR}/local.lnd.plist" "local.lnd" "${USER_HOME}/lnd/lnd" "" + create_plist "${LAUNCH_AGENTS_DIR}/local.lightning_pub.plist" "local.lightning_pub" "/bin/bash-csource ${NVM_DIR}/nvm.sh && npm start" "${USER_HOME}/lightning_pub" + + log "${PRIMARY_COLOR}Created launchd plists. Please load them using launchctl.${RESET_COLOR}" +} diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 00000000..39b24518 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -e + +BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts" + +modules=( + "utils" + "check_homebrew" + "install_rsync_mac" + "create_launchd_plist" + "start_services_mac" + "install_lnd" + "install_nodejs" + "install_lightning_pub" + "start_services" +) + +for module in "${modules[@]}"; do + wget -q "${BASE_URL}/${module}.sh" -O "/tmp/${module}.sh" + source "/tmp/${module}.sh" +done + +# Upgrade flag +SKIP_PROMPT=false +for arg in "$@"; do + case $arg in + --yes) + SKIP_PROMPT=true + shift + ;; + esac +done + +detect_os_arch + +if [ "$OS" = "Mac" ]; then + handle_macos +else + install_lnd + install_nodejs + install_lightning_pub + start_services +fi diff --git a/scripts/install_lightning_pub.sh b/scripts/install_lightning_pub.sh new file mode 100755 index 00000000..0b4b3277 --- /dev/null +++ b/scripts/install_lightning_pub.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +install_lightning_pub() { + log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." + REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master" + wget $REPO_URL -O lightning_pub.tar.gz > /dev/null 2>&1 || { + log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}" + exit 1 + } + mkdir -p lightning_pub_temp + tar -xvzf lightning_pub.tar.gz -C lightning_pub_temp --strip-components=1 > /dev/null 2>&1 || { + log "${PRIMARY_COLOR}Failed to extract Lightning.Pub.${RESET_COLOR}" + exit 1 + } + rm lightning_pub.tar.gz + + if ! command -v rsync &> /dev/null; then + log "${PRIMARY_COLOR}rsync not found, installing...${RESET_COLOR}" + if [ "$OS" = "Mac" ]; then + brew install rsync + elif [ "$OS" = "Linux" ]; then + if [ -x "$(command -v apt-get)" ]; then + sudo apt-get update > /dev/null 2>&1 + sudo apt-get install -y rsync > /dev/null 2>&1 + elif [ -x "$(command -v yum)" ]; then + sudo yum install -y rsync > /dev/null 2>&1 + else + log "${PRIMARY_COLOR}Package manager not found. Please install rsync manually.${RESET_COLOR}" + exit 1 + fi + else + log "${PRIMARY_COLOR}Package manager not found. Please install rsync manually.${RESET_COLOR}" + exit 1 + fi + fi + + # Merge if upgrade + rsync -av --exclude='*.sqlite' --exclude='.env' --exclude='logs' --exclude='node_modules' lightning_pub_temp/ lightning_pub/ > /dev/null 2>&1 + rm -rf lightning_pub_temp + + # Load nvm and npm + export NVM_DIR="${NVM_DIR}" + [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" + + cd lightning_pub + + log "${PRIMARY_COLOR}Installing${RESET_COLOR} npm dependencies..." + + npm install > npm_install.log 2>&1 || { + log "${PRIMARY_COLOR}Failed to install npm dependencies.${RESET_COLOR}" + exit 1 + } + + log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} installation completed." +} \ No newline at end of file diff --git a/scripts/install_lnd.sh b/scripts/install_lnd.sh new file mode 100755 index 00000000..5ca6217f --- /dev/null +++ b/scripts/install_lnd.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +install_lnd() { + if [ "$EUID" -eq 0 ]; then + USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + else + USER_HOME=$HOME + fi + + LND_VERSION=$(wget -qO- https://api.github.com/repos/lightningnetwork/lnd/releases/latest | grep 'tag_name' | cut -d\" -f4) + LND_URL="https://github.com/lightningnetwork/lnd/releases/download/${LND_VERSION}/lnd-${OS}-${ARCH}-${LND_VERSION}.tar.gz" + + # Check if LND is already installed + if [ -d "$USER_HOME/lnd" ]; then + CURRENT_VERSION=$("$USER_HOME/lnd/lnd" --version | grep -oP 'version \K[^\s]+') + if [ "$CURRENT_VERSION" == "${LND_VERSION#v}" ]; then + log "${SECONDARY_COLOR}LND${RESET_COLOR} is already up-to-date (version $CURRENT_VERSION)." + return + else + if [ "$SKIP_PROMPT" != true ]; then + read -p "LND version $CURRENT_VERSION is installed. Do you want to upgrade to version $LND_VERSION? (y/N): " response + case "$response" in + [yY][eE][sS]|[yY]) + log "${PRIMARY_COLOR}Upgrading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} from version $CURRENT_VERSION to $LND_VERSION..." + ;; + *) + log "$(date '+%Y-%m-%d %H:%M:%S') Upgrade cancelled." + return + ;; + esac + else + log "${PRIMARY_COLOR}Upgrading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} from version $CURRENT_VERSION to $LND_VERSION..." + fi + fi + fi + + log "${PRIMARY_COLOR}Downloading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR}..." + + # Start the download + wget -q $LND_URL -O lnd.tar.gz || { + log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}" + exit 1 + } + + # Check if LND is already running and stop it if necessary (Linux) + if [ "$OS" = "Linux" ] && [ "$SYSTEMCTL_AVAILABLE" = true ]; then + if systemctl is-active --quiet lnd; then + log "${PRIMARY_COLOR}Stopping${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..." + sudo systemctl stop lnd + fi + else + log "${PRIMARY_COLOR}systemctl not found. Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}" + fi + + tar -xzf lnd.tar.gz -C $USER_HOME > /dev/null || { + log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}" + exit 1 + } + rm lnd.tar.gz + mv $USER_HOME/lnd-* $USER_HOME/lnd + + # Create .lnd directory if it doesn't exist + mkdir -p $USER_HOME/.lnd + + # Check if lnd.conf already exists and avoid overwriting it + if [ -f $USER_HOME/.lnd/lnd.conf ]; then + log "${PRIMARY_COLOR}lnd.conf already exists. Skipping creation of new lnd.conf file.${RESET_COLOR}" + else + cat < $USER_HOME/.lnd/lnd.conf +bitcoin.mainnet=true +bitcoin.node=neutrino +neutrino.addpeer=neutrino.shock.network +feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json +EOF + fi + + log "${SECONDARY_COLOR}LND${RESET_COLOR} installation and configuration completed." +} \ No newline at end of file diff --git a/scripts/install_nodejs.sh b/scripts/install_nodejs.sh new file mode 100755 index 00000000..880a1d69 --- /dev/null +++ b/scripts/install_nodejs.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +install_nodejs() { + log "${PRIMARY_COLOR}Checking${RESET_COLOR} for Node.js..." + MINIMUM_VERSION="18.0.0" + + # Load nvm if it already exists + export NVM_DIR="${NVM_DIR}" + [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" + + if ! command -v nvm &> /dev/null; then + NVM_VERSION=$(wget -qO- https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') + wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash > /dev/null 2>&1 + export NVM_DIR="${NVM_DIR}" + [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" + fi + + if command -v node &> /dev/null; then + NODE_VERSION=$(node -v | sed 's/v//') + if [ "$(printf '%s\n' "$MINIMUM_VERSION" "$NODE_VERSION" | sort -V | head -n1)" = "$MINIMUM_VERSION" ]; then + log "Node.js is already installed and meets the minimum version requirement." + return + else + log "${PRIMARY_COLOR}Updating${RESET_COLOR} Node.js to the LTS version..." + fi + else + log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}" + fi + + nvm install --lts || { + log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}" + exit 1 + } + + log "Node.js LTS installation completed." +} \ No newline at end of file diff --git a/scripts/install_rsync_mac.sh b/scripts/install_rsync_mac.sh new file mode 100755 index 00000000..f1973a76 --- /dev/null +++ b/scripts/install_rsync_mac.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +install_rsync_mac() { + check_homebrew + log "${PRIMARY_COLOR}Installing${RESET_COLOR} rsync using Homebrew..." + brew install rsync || { + log "${PRIMARY_COLOR}Failed to install rsync.${RESET_COLOR}" + exit 1 + } +} diff --git a/scripts/start_services.sh b/scripts/start_services.sh new file mode 100755 index 00000000..2bb7b411 --- /dev/null +++ b/scripts/start_services.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +start_services() { + USER_HOME=$(eval echo ~$(whoami)) + if [ "$OS" = "Linux" ]; then + if [ "$SYSTEMCTL_AVAILABLE" = true ]; then + sudo bash -c "cat > /etc/systemd/system/lnd.service < /etc/systemd/system/lightning_pub.service < start.sh +#!/bin/bash +${USER_HOME}/lnd/lnd & +LND_PID=\$! +sleep 10 +npm start & +NODE_PID=\$! +wait \$LND_PID +wait \$NODE_PID +EOF + chmod +x start.sh + log "systemctl not available. Created start.sh. Please use this script to start the services manually." +} \ No newline at end of file diff --git a/scripts/start_services_mac.sh b/scripts/start_services_mac.sh new file mode 100755 index 00000000..81f817c1 --- /dev/null +++ b/scripts/start_services_mac.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +start_services_mac() { + create_launchd_plist + launchctl load "${LAUNCH_AGENTS_DIR}/local.lnd.plist" + launchctl load "${LAUNCH_AGENTS_DIR}/local.lightning_pub.plist" + log "${SECONDARY_COLOR}LND${RESET_COLOR} and ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} services started using launchd." +} + +handle_macos() { + check_homebrew + install_rsync_mac + install_nodejs + install_lightning_pub + create_launchd_plist + start_services_mac +} diff --git a/scripts/utils.sh b/scripts/utils.sh new file mode 100755 index 00000000..e31a30a8 --- /dev/null +++ b/scripts/utils.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +PRIMARY_COLOR="\e[38;5;208m" # #f59322 +SECONDARY_COLOR="\e[38;5;165m" # #c740c7 +RESET_COLOR="\e[0m" +LOG_FILE="/var/log/deploy.log" + +touch $LOG_FILE +chmod 644 $LOG_FILE + +log() { + local message="$(date '+%Y-%m-%d %H:%M:%S') $1" + if [ -t 1 ]; then + echo -e "$message" + fi + echo -e "$(echo $message | sed 's/\\e\[[0-9;]*m//g')" >> $LOG_FILE +} + +detect_os_arch() { + OS="$(uname -s)" + ARCH="$(uname -m)" + case "$OS" in + Linux*) OS=Linux;; + Darwin*) OS=Mac;; + CYGWIN*) OS=Cygwin;; + MINGW*) OS=MinGw;; + *) OS="UNKNOWN" + esac + case "$ARCH" in + x86_64) ARCH=amd64;; + arm64) ARCH=arm64;; + *) ARCH="UNKNOWN" + esac + + if [ "$OS" = "Linux" ] && command -v systemctl &> /dev/null; then + SYSTEMCTL_AVAILABLE=true + else + SYSTEMCTL_AVAILABLE=false + fi +} From 9203f55ae7706e9ddb81e689bcfc7fe8db7bd97c Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 16:26:17 -0400 Subject: [PATCH 03/16] deploy --- scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 39b24518..35cb812c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts" +BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/fix/bootstrap/scripts/" modules=( "utils" From 8c458feb63eb744498dd9daf7ebefd7e5bb65cdc Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 16:37:13 -0400 Subject: [PATCH 04/16] deploy --- scripts/start_services.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/start_services.sh b/scripts/start_services.sh index 2bb7b411..f1d71f6e 100755 --- a/scripts/start_services.sh +++ b/scripts/start_services.sh @@ -1,7 +1,12 @@ #!/bin/bash start_services() { - USER_HOME=$(eval echo ~$(whoami)) + if [ "$EUID" -eq 0 ]; then + USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + else + USER_HOME=$HOME + fi + if [ "$OS" = "Linux" ]; then if [ "$SYSTEMCTL_AVAILABLE" = true ]; then sudo bash -c "cat > /etc/systemd/system/lnd.service < Date: Fri, 5 Jul 2024 16:58:15 -0400 Subject: [PATCH 05/16] deploy --- src/services/lnd/index.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/lnd/index.ts b/src/services/lnd/index.ts index 0d671ef6..1a03cf5a 100644 --- a/src/services/lnd/index.ts +++ b/src/services/lnd/index.ts @@ -4,18 +4,21 @@ import os from 'os' import path from 'path' const resolveHome = (filepath: string) => { - if (filepath[0] === '~') { - return path.join(os.homedir(), filepath.slice(1)) + let homeDir; + if (process.env.SUDO_USER) { + homeDir = path.join('/home', process.env.SUDO_USER); + } else { + homeDir = os.homedir(); } - return filepath + return path.join(homeDir, filepath); } export const LoadLndSettingsFromEnv = (): LndSettings => { const lndAddr = process.env.LND_ADDRESS || "127.0.0.1:10009" - const lndCertPath = process.env.LND_CERT_PATH || resolveHome("~/.lnd/tls.cert") - const lndMacaroonPath = process.env.LND_MACAROON_PATH || resolveHome("~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon") + const lndCertPath = process.env.LND_CERT_PATH || resolveHome("/.lnd/tls.cert") + const lndMacaroonPath = process.env.LND_MACAROON_PATH || resolveHome("/.lnd/data/chain/bitcoin/mainnet/admin.macaroon") const feeRateLimit = EnvCanBeInteger("OUTBOUND_MAX_FEE_BPS", 60) / 10000 const feeFixedLimit = EnvCanBeInteger("OUTBOUND_MAX_FEE_EXTRA_SATS", 100) const mockLnd = EnvCanBeBoolean("MOCK_LND") return { mainNode: { lndAddr, lndCertPath, lndMacaroonPath }, feeRateLimit, feeFixedLimit, mockLnd } -} +} \ No newline at end of file From c2d214fd8c1112161666597b17c96859d178fb2f Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 17:03:54 -0400 Subject: [PATCH 06/16] deploy --- scripts/install_lightning_pub.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_lightning_pub.sh b/scripts/install_lightning_pub.sh index 0b4b3277..a83589b0 100755 --- a/scripts/install_lightning_pub.sh +++ b/scripts/install_lightning_pub.sh @@ -2,7 +2,7 @@ install_lightning_pub() { log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." - REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master" + REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/fix/bootstrap" wget $REPO_URL -O lightning_pub.tar.gz > /dev/null 2>&1 || { log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}" exit 1 From 1ec83e05874c8d92bc27c0241a617b7ffa1c3be0 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 17:36:45 -0400 Subject: [PATCH 07/16] deploy --- scripts/install_lnd.sh | 3 ++- scripts/install_nodejs.sh | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/install_lnd.sh b/scripts/install_lnd.sh index 5ca6217f..aa4047fe 100755 --- a/scripts/install_lnd.sh +++ b/scripts/install_lnd.sh @@ -7,7 +7,8 @@ install_lnd() { USER_HOME=$HOME fi - LND_VERSION=$(wget -qO- https://api.github.com/repos/lightningnetwork/lnd/releases/latest | grep 'tag_name' | cut -d\" -f4) + # Improved version extraction logic + LND_VERSION=$(wget -qO- https://api.github.com/repos/lightningnetwork/lnd/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') LND_URL="https://github.com/lightningnetwork/lnd/releases/download/${LND_VERSION}/lnd-${OS}-${ARCH}-${LND_VERSION}.tar.gz" # Check if LND is already installed diff --git a/scripts/install_nodejs.sh b/scripts/install_nodejs.sh index 880a1d69..b4053854 100755 --- a/scripts/install_nodejs.sh +++ b/scripts/install_nodejs.sh @@ -1,6 +1,15 @@ #!/bin/bash install_nodejs() { + if [ "$EUID" -eq 0 ] && [ -n "$SUDO_USER" ]; then + USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + USER_NAME=${SUDO_USER} + else + USER_HOME=$HOME + USER_NAME=$(whoami) + fi + + NVM_DIR="$USER_HOME/.nvm" log "${PRIMARY_COLOR}Checking${RESET_COLOR} for Node.js..." MINIMUM_VERSION="18.0.0" @@ -10,7 +19,7 @@ install_nodejs() { if ! command -v nvm &> /dev/null; then NVM_VERSION=$(wget -qO- https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') - wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash > /dev/null 2>&1 + sudo -u $USER_NAME bash -c "wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash > /dev/null 2>&1" export NVM_DIR="${NVM_DIR}" [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" fi @@ -27,7 +36,7 @@ install_nodejs() { log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}" fi - nvm install --lts || { + sudo -u $USER_NAME bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts" || { log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}" exit 1 } From f8895e28e1c7e527bee9c4e31c56dc5e6f7fb5b8 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 17:59:37 -0400 Subject: [PATCH 08/16] deploy --- scripts/start_services.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/start_services.sh b/scripts/start_services.sh index f1d71f6e..b236d89e 100755 --- a/scripts/start_services.sh +++ b/scripts/start_services.sh @@ -3,8 +3,10 @@ start_services() { if [ "$EUID" -eq 0 ]; then USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + USER_NAME=$SUDO_USER else USER_HOME=$HOME + USER_NAME=$(whoami) fi if [ "$OS" = "Linux" ]; then @@ -16,7 +18,7 @@ After=network.target [Service] ExecStart=${USER_HOME}/lnd/lnd -User=$(whoami) +User=${USER_NAME} Restart=always [Install] @@ -31,7 +33,7 @@ After=network.target [Service] ExecStart=/bin/bash -c 'source ${NVM_DIR}/nvm.sh && npm start' WorkingDirectory=${USER_HOME}/lightning_pub -User=$(whoami) +User=${USER_NAME} Restart=always [Install] From 12e9b261577fe33238423f2e90e56e3c7b27b497 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 18:41:21 -0400 Subject: [PATCH 09/16] deploy --- scripts/install_lightning_pub.sh | 18 ++++++++++++++---- scripts/install_lnd.sh | 16 +++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/scripts/install_lightning_pub.sh b/scripts/install_lightning_pub.sh index a83589b0..c82be736 100755 --- a/scripts/install_lightning_pub.sh +++ b/scripts/install_lightning_pub.sh @@ -1,18 +1,28 @@ #!/bin/bash install_lightning_pub() { + if [ "$EUID" -eq 0 ]; then + USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + USER_NAME=$SUDO_USER + else + USER_HOME=$HOME + USER_NAME=$(whoami) + fi + log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/fix/bootstrap" - wget $REPO_URL -O lightning_pub.tar.gz > /dev/null 2>&1 || { + + sudo -u $USER_NAME wget $REPO_URL -O $USER_HOME/lightning_pub.tar.gz > /dev/null 2>&1 || { log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}" exit 1 } - mkdir -p lightning_pub_temp - tar -xvzf lightning_pub.tar.gz -C lightning_pub_temp --strip-components=1 > /dev/null 2>&1 || { + + sudo -u $USER_NAME mkdir -p $USER_HOME/lightning_pub_temp + sudo -u $USER_NAME tar -xvzf $USER_HOME/lightning_pub.tar.gz -C $USER_HOME/lightning_pub_temp --strip-components=1 > /dev/null 2>&1 || { log "${PRIMARY_COLOR}Failed to extract Lightning.Pub.${RESET_COLOR}" exit 1 } - rm lightning_pub.tar.gz + rm $USER_HOME/lightning_pub.tar.gz if ! command -v rsync &> /dev/null; then log "${PRIMARY_COLOR}rsync not found, installing...${RESET_COLOR}" diff --git a/scripts/install_lnd.sh b/scripts/install_lnd.sh index aa4047fe..736f67b7 100755 --- a/scripts/install_lnd.sh +++ b/scripts/install_lnd.sh @@ -3,8 +3,10 @@ install_lnd() { if [ "$EUID" -eq 0 ]; then USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + USER_NAME=$SUDO_USER else USER_HOME=$HOME + USER_NAME=$(whoami) fi # Improved version extraction logic @@ -38,7 +40,7 @@ install_lnd() { log "${PRIMARY_COLOR}Downloading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR}..." # Start the download - wget -q $LND_URL -O lnd.tar.gz || { + sudo -u $USER_NAME wget -q $LND_URL -O $USER_HOME/lnd.tar.gz || { log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}" exit 1 } @@ -53,26 +55,26 @@ install_lnd() { log "${PRIMARY_COLOR}systemctl not found. Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}" fi - tar -xzf lnd.tar.gz -C $USER_HOME > /dev/null || { + sudo -u $USER_NAME tar -xzf $USER_HOME/lnd.tar.gz -C $USER_HOME > /dev/null || { log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}" exit 1 } - rm lnd.tar.gz - mv $USER_HOME/lnd-* $USER_HOME/lnd + rm $USER_HOME/lnd.tar.gz + sudo -u $USER_NAME mv $USER_HOME/lnd-* $USER_HOME/lnd # Create .lnd directory if it doesn't exist - mkdir -p $USER_HOME/.lnd + sudo -u $USER_NAME mkdir -p $USER_HOME/.lnd # Check if lnd.conf already exists and avoid overwriting it if [ -f $USER_HOME/.lnd/lnd.conf ]; then log "${PRIMARY_COLOR}lnd.conf already exists. Skipping creation of new lnd.conf file.${RESET_COLOR}" else - cat < $USER_HOME/.lnd/lnd.conf + sudo -u $USER_NAME bash -c "cat < $USER_HOME/.lnd/lnd.conf bitcoin.mainnet=true bitcoin.node=neutrino neutrino.addpeer=neutrino.shock.network feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json -EOF +EOF" fi log "${SECONDARY_COLOR}LND${RESET_COLOR} installation and configuration completed." From bfb0c0ac6b6ac9ab63ee19c9adffbc1a576057ee Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 19:12:28 -0400 Subject: [PATCH 10/16] deploy --- scripts/extract_nprofile.sh | 46 +++++++++++++++++++++++++++++++++++++ scripts/install.sh | 5 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 scripts/extract_nprofile.sh diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh new file mode 100644 index 00000000..ee7e9044 --- /dev/null +++ b/scripts/extract_nprofile.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +get_log_info() { + if [ "$EUID" -eq 0 ]; then + USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6) + USER_NAME=$SUDO_USER + else + USER_HOME=$HOME + USER_NAME=$(whoami) + fi + + LOG_DIR="$USER_HOME/lightning_pub/logs" + MAX_ATTEMPTS=4 + ATTEMPT=0 + + find_latest_log() { + ls -1t ${LOG_DIR}/components/nostrMiddleware_*.log 2>/dev/null | head -n 1 + } + + while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do + LATEST_LOG=$(find_latest_log) + if [ -n "$LATEST_LOG" ]; then + break + fi + echo "Awaiting nostr information..." + sleep 4 + ATTEMPT=$((ATTEMPT + 1)) + done + + if [ -z "$LATEST_LOG" ]; then + echo "Failed to find the log file, check service status" + exit 1 + fi + + nprofile_key=$(grep -oP 'nprofile: \K\w+' "$LATEST_LOG") + + if [ -z "$nprofile_key" ]; then + echo "No nprofile key found in the log." + exit 1 + fi + + # Print the extracted key + echo "Paste this string into ShockWallet to connect to the node: $nprofile_key" +} + +get_log_info \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index 35cb812c..a47132e8 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,6 @@ set -e BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/fix/bootstrap/scripts/" - modules=( "utils" "check_homebrew" @@ -13,6 +12,7 @@ modules=( "install_nodejs" "install_lightning_pub" "start_services" + "extract_nprofile" # Add extract_nprofile to the modules array ) for module in "${modules[@]}"; do @@ -40,4 +40,5 @@ else install_nodejs install_lightning_pub start_services -fi + get_log_info +fi \ No newline at end of file From a79e0fe4ec2c3a684904224e2e208712a07e01d4 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 22:41:21 -0400 Subject: [PATCH 11/16] deploy --- scripts/extract_nprofile.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index ee7e9044..cb98be12 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -41,6 +41,4 @@ get_log_info() { # Print the extracted key echo "Paste this string into ShockWallet to connect to the node: $nprofile_key" -} - -get_log_info \ No newline at end of file +} \ No newline at end of file From 78dc82862405e309412d17662ed2754c82991a40 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 22:55:00 -0400 Subject: [PATCH 12/16] init retry mechanism --- src/services/main/unlocker.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/main/unlocker.ts b/src/services/main/unlocker.ts index 6d7ffdfb..f6a8bbf6 100644 --- a/src/services/main/unlocker.ts +++ b/src/services/main/unlocker.ts @@ -83,7 +83,16 @@ export class Unlocker { const initRes = await unlocker.initWallet(req, DeadLineMetadata(60 * 1000)) const adminMacaroon = Buffer.from(initRes.response.adminMacaroon).toString('hex') const ln = this.GetLightningClient(lndCert, adminMacaroon) - const info = await this.GetLndInfo(ln) + + // Retry mechanism to ensure LND is ready + let info; + for (let i = 0; i < 10; i++) { + info = await this.GetLndInfo(ln); + if (info.ok) break; + this.log("LND not ready, retrying in 5 seconds..."); + await new Promise(res => setTimeout(res, 5000)); + } + if (!info.ok) { throw new Error("failed to init lnd wallet " + info.failure) } From 5940f5f3c084ec1348a2ec6acb1b2ba9288db33c Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 23:06:14 -0400 Subject: [PATCH 13/16] deploy --- src/services/main/unlocker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/main/unlocker.ts b/src/services/main/unlocker.ts index f6a8bbf6..ecf8618c 100644 --- a/src/services/main/unlocker.ts +++ b/src/services/main/unlocker.ts @@ -93,8 +93,8 @@ export class Unlocker { await new Promise(res => setTimeout(res, 5000)); } - if (!info.ok) { - throw new Error("failed to init lnd wallet " + info.failure) + if (!info || !info.ok) { + throw new Error("failed to init lnd wallet " + (info ? info.failure : "unknown error")) } await this.storage.liquidityStorage.SaveNodeSeed(info.pub, JSON.stringify(encryptedData)) this.log("created wallet with pub:", info.pub) From 671b5f1f9c28372147f5908ca6512ee483b57b20 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 23:30:08 -0400 Subject: [PATCH 14/16] deploy --- scripts/extract_nprofile.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index cb98be12..c511215a 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -17,6 +17,35 @@ get_log_info() { ls -1t ${LOG_DIR}/components/nostrMiddleware_*.log 2>/dev/null | head -n 1 } + TIMEOUT=30 + while ! grep -q "rimraf build" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log) && [ $TIMEOUT -gt 0 ]; do + sleep 1 + TIMEOUT=$((TIMEOUT - 1)) + done + if [ $TIMEOUT -le 0 ]; then + echo "Timeout waiting for 'rimraf build' message." + exit 1 + fi + echo "Running build..." + + TIMEOUT=45 + while ! grep -q -e "unlocker >> macaroon not found, creating wallet..." -e "unlocker >> the wallet is already unlocked" -e "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log) && [ $TIMEOUT -gt 0 ]; do + sleep 1 + TIMEOUT=$((TIMEOUT - 1)) + done + if [ $TIMEOUT -le 0 ]; then + echo "Timeout waiting for wallet status message." + exit 1 + fi + + if grep -q "unlocker >> macaroon not found, creating wallet..." <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log); then + echo "Creating wallet..." + elif grep -q "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log); then + echo "Unlocking wallet..." + else + echo "Wallet is already unlocked." + fi + while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do LATEST_LOG=$(find_latest_log) if [ -n "$LATEST_LOG" ]; then From 6c30914057f4412f4425072c159a9e2f3baa294b Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 23:50:39 -0400 Subject: [PATCH 15/16] deploy --- scripts/extract_nprofile.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index c511215a..59d80fab 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -17,19 +17,19 @@ get_log_info() { ls -1t ${LOG_DIR}/components/nostrMiddleware_*.log 2>/dev/null | head -n 1 } - TIMEOUT=30 - while ! grep -q "rimraf build" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log) && [ $TIMEOUT -gt 0 ]; do - sleep 1 - TIMEOUT=$((TIMEOUT - 1)) + TIMEOUT=180 + while [ ! -f ${LOG_DIR}/components/unlocker_*.log ] && [ $TIMEOUT -gt 0 ]; do + echo "Waiting for build..." + sleep 10 + TIMEOUT=$((TIMEOUT - 10)) done if [ $TIMEOUT -le 0 ]; then - echo "Timeout waiting for 'rimraf build' message." + echo "Timeout waiting for unlocker log file." exit 1 fi - echo "Running build..." TIMEOUT=45 - while ! grep -q -e "unlocker >> macaroon not found, creating wallet..." -e "unlocker >> the wallet is already unlocked" -e "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log) && [ $TIMEOUT -gt 0 ]; do + while ! grep -q -e "unlocker >> macaroon not found, creating wallet..." -e "unlocker >> the wallet is already unlocked" -e "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log) && [ $TIMEOUT -gt 0 ]; do sleep 1 TIMEOUT=$((TIMEOUT - 1)) done @@ -38,9 +38,9 @@ get_log_info() { exit 1 fi - if grep -q "unlocker >> macaroon not found, creating wallet..." <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log); then + if grep -q "unlocker >> macaroon not found, creating wallet..." <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log); then echo "Creating wallet..." - elif grep -q "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/nostrMiddleware_*.log); then + elif grep -q "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log); then echo "Unlocking wallet..." else echo "Wallet is already unlocked." From 9ea355d9e10522526928178dcc52a57173426b42 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" Date: Fri, 5 Jul 2024 23:57:18 -0400 Subject: [PATCH 16/16] deploy --- scripts/extract_nprofile.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index 59d80fab..c2579094 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -17,6 +17,7 @@ get_log_info() { ls -1t ${LOG_DIR}/components/nostrMiddleware_*.log 2>/dev/null | head -n 1 } + # Echo "Waiting for build..." every 10 seconds until the unlocker log is available, with a 3-minute timeout TIMEOUT=180 while [ ! -f ${LOG_DIR}/components/unlocker_*.log ] && [ $TIMEOUT -gt 0 ]; do echo "Waiting for build..." @@ -28,8 +29,12 @@ get_log_info() { exit 1 fi + # Wait for wallet status messages with a 45s timeout TIMEOUT=45 - while ! grep -q -e "unlocker >> macaroon not found, creating wallet..." -e "unlocker >> the wallet is already unlocked" -e "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log) && [ $TIMEOUT -gt 0 ]; do + while [ $TIMEOUT -gt 0 ]; do + if grep -q -e "unlocker >> macaroon not found, creating wallet..." -e "unlocker >> the wallet is already unlocked" -e "unlocker >> wallet is locked, unlocking" ${LOG_DIR}/components/unlocker_*.log; then + break + fi sleep 1 TIMEOUT=$((TIMEOUT - 1)) done @@ -38,17 +43,20 @@ get_log_info() { exit 1 fi - if grep -q "unlocker >> macaroon not found, creating wallet..." <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log); then + if grep -q "unlocker >> macaroon not found, creating wallet..." ${LOG_DIR}/components/unlocker_*.log; then echo "Creating wallet..." - elif grep -q "unlocker >> wallet is locked, unlocking" <(tail -n 0 -F ${LOG_DIR}/components/unlocker_*.log); then + elif grep -q "unlocker >> wallet is locked, unlocking" ${LOG_DIR}/components/unlocker_*.log; then echo "Unlocking wallet..." else echo "Wallet is already unlocked." fi + echo "Proceeding to nprofile attempts..." + while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do LATEST_LOG=$(find_latest_log) if [ -n "$LATEST_LOG" ]; then + echo "Found latest log: $LATEST_LOG" break fi echo "Awaiting nostr information..."