upgrade grpc binaries

This commit is contained in:
Justin (shocknet) 2024-08-15 20:23:43 -04:00
parent ae31a2830d
commit a01aae2b2e
5 changed files with 145 additions and 4083 deletions

4138
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@
}, },
"homepage": "https://github.com/shocknet/Lightning.Pub#readme", "homepage": "https://github.com/shocknet/Lightning.Pub#readme",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.8.22",
"@protobuf-ts/grpc-transport": "^2.5.0", "@protobuf-ts/grpc-transport": "^2.5.0",
"@protobuf-ts/plugin": "^2.5.0", "@protobuf-ts/plugin": "^2.5.0",
"@protobuf-ts/runtime": "^2.5.0", "@protobuf-ts/runtime": "^2.5.0",
@ -45,7 +45,7 @@
"eccrypto": "^1.1.6", "eccrypto": "^1.1.6",
"express": "^4.19.2", "express": "^4.19.2",
"globby": "^13.1.2", "globby": "^13.1.2",
"grpc-tools": "^1.11.2", "grpc-tools": "^1.12.4",
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nostr-tools": "^1.9.0", "nostr-tools": "^1.9.0",

View file

@ -1,13 +1,22 @@
#!/bin/bash #!/bin/bash
set -e set -e
SCRIPT_VERSION="0.1.0"
cleanup() {
echo "Cleaning up temporary files..."
rm -f /tmp/*.sh
}
trap cleanup EXIT
log_error() { log_error() {
log "ERROR: $1" log "ERROR: $1"
log "Exiting with status $2" log "Exiting with status $2"
exit $2 exit $2
} }
BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts/" BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/fix-arm/scripts/"
modules=( modules=(
"utils" "utils"
@ -22,6 +31,8 @@ modules=(
"extract_nprofile" "extract_nprofile"
) )
echo "Script version $SCRIPT_VERSION"
for module in "${modules[@]}"; do for module in "${modules[@]}"; do
wget -q "${BASE_URL}/${module}.sh" -O "/tmp/${module}.sh" || log_error "Failed to download ${module}.sh" 1 wget -q "${BASE_URL}/${module}.sh" -O "/tmp/${module}.sh" || log_error "Failed to download ${module}.sh" 1
source "/tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1 source "/tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1
@ -35,6 +46,7 @@ if [ "$OS" = "Mac" ]; then
log "Handling macOS specific setup" log "Handling macOS specific setup"
handle_macos || log_error "macOS setup failed" 1 handle_macos || log_error "macOS setup failed" 1
else else
log "Starting LND installation..."
lnd_output=$(install_lnd) lnd_output=$(install_lnd)
install_result=$? install_result=$?
@ -42,7 +54,6 @@ else
log_error "LND installation failed" $install_result log_error "LND installation failed" $install_result
fi fi
# Extract the LND status from the output
lnd_status=$(echo "$lnd_output" | grep "LND_STATUS:" | cut -d':' -f2) lnd_status=$(echo "$lnd_output" | grep "LND_STATUS:" | cut -d':' -f2)
case $lnd_status in case $lnd_status in
@ -52,16 +63,16 @@ else
*) log "WARNING: Unexpected status from install_lnd: $lnd_status" ;; *) log "WARNING: Unexpected status from install_lnd: $lnd_status" ;;
esac esac
install_nodejs || log_error "NodeJS installation failed" $? log "Starting Node.js installation..."
install_nodejs
pub_output=$(install_lightning_pub) nodejs_result=$?
install_result=$? log "Node.js installation completed with status: $nodejs_result"
if [ $nodejs_result -ne 0 ]; then
if [ $install_result -ne 0 ]; then log_error "NodeJS installation failed" $nodejs_result
log_error "Lightning.Pub installation failed" $install_result
fi fi
# Extract the upgrade status from the output install_lightning_pub
pub_upgrade_status=$(echo "$pub_output" | grep "UPGRADE_STATUS:" | cut -d':' -f2) pub_upgrade_status=$(echo "$pub_output" | grep "UPGRADE_STATUS:" | cut -d':' -f2)
if [ "$pub_upgrade_status" = "100" ]; then if [ "$pub_upgrade_status" = "100" ]; then

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
install_lightning_pub() { install_lightning_pub() {
local upgrade_status=0 local upgrade_status=0
if [ "$EUID" -eq 0 ]; then if [ "$EUID" -eq 0 ]; then
@ -11,6 +12,29 @@ install_lightning_pub() {
USER_NAME=$(whoami) USER_NAME=$(whoami)
fi fi
log "Checking for build essentials..."
if [ "$OS" = "Linux" ]; then
if command -v gcc &> /dev/null && command -v make &> /dev/null; then
log "Build essentials already installed."
else
log "Installing build essentials..."
if command -v apt-get &> /dev/null; then
log "Using apt-get to install build-essential"
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y build-essential > /dev/null 2>&1
elif command -v yum &> /dev/null; then
log "Using yum to install Development Tools"
sudo yum groupinstall -y "Development Tools" > /dev/null 2>&1
else
log "Unable to install build essentials. Neither apt-get nor yum found."
return 1
fi
log "Build essentials installation attempt completed."
fi
else
log "Not on Linux, skipping build essentials check."
fi
log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." 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/master"
@ -50,22 +74,29 @@ install_lightning_pub() {
log "${PRIMARY_COLOR}Installing${RESET_COLOR} npm dependencies..." log "${PRIMARY_COLOR}Installing${RESET_COLOR} npm dependencies..."
npm install > npm_install.log 2>&1 npm install > npm_install.log
npm_exit_code=$? npm_exit_code=$?
if [ $npm_exit_code -ne 0 ]; then if [ $npm_exit_code -ne 0 ]; then
log "${PRIMARY_COLOR}Failed to install npm dependencies. Check npm_install.log for details.${RESET_COLOR}" log "${PRIMARY_COLOR}Failed to install npm dependencies. Error details:${RESET_COLOR}"
tail -n 20 npm_install.log | while IFS= read -r line; do
log " $line"
done
log "${PRIMARY_COLOR}Full log available in $USER_HOME/lightning_pub/npm_install.log${RESET_COLOR}"
return 1 return 1
fi fi
if [ ! -d "node_modules" ] || [ -z "$(ls -A node_modules)" ]; then if [ ! -d "node_modules" ] || [ -z "$(ls -A node_modules)" ]; then
log "${PRIMARY_COLOR}npm install completed, but node_modules is empty or missing. Installation may have failed.${RESET_COLOR}" log "${PRIMARY_COLOR}npm install completed, but node_modules is empty or missing. Installation may have failed.${RESET_COLOR}"
log "Checking npm_install.log for errors:"
grep -i "error" npm_install.log | tail -n 10 | while IFS= read -r line; do
log " $line"
done
log "${PRIMARY_COLOR}Full log available in $USER_HOME/lightning_pub/npm_install.log${RESET_COLOR}"
return 1 return 1
fi fi
log "npm dependencies installed successfully." log "npm dependencies installed successfully."
# Echo a specific string followed by the upgrade status return 0
echo "UPGRADE_STATUS:$upgrade_status"
return 0 # Always return 0 to indicate success
} }

View file

@ -26,9 +26,11 @@ install_nodejs() {
if command -v node &> /dev/null; then if command -v node &> /dev/null; then
NODE_VERSION=$(node -v | sed 's/v//') NODE_VERSION=$(node -v | sed 's/v//')
log "Current Node.js version: $NODE_VERSION"
if [ "$(printf '%s\n' "$MINIMUM_VERSION" "$NODE_VERSION" | sort -V | head -n1)" = "$MINIMUM_VERSION" ]; then 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." log "Node.js is already installed and meets the minimum version requirement."
return log "Exiting install_nodejs function with status 0"
return 0
else else
log "${PRIMARY_COLOR}Updating${RESET_COLOR} Node.js to the LTS version..." log "${PRIMARY_COLOR}Updating${RESET_COLOR} Node.js to the LTS version..."
fi fi
@ -36,10 +38,14 @@ install_nodejs() {
log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}" log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}"
fi fi
sudo -u $USER_NAME bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts" || { log "Attempting to install/update Node.js..."
if ! sudo -u $USER_NAME bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts"; then
log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}" log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}"
exit 1 log "Exiting install_nodejs function with status 1"
} return 1
fi
log "Node.js LTS installation completed." log "Node.js LTS installation completed."
log "Exiting install_nodejs function with status 0"
return 0
} }