commit
2a09dacde7
7 changed files with 124 additions and 4114 deletions
4138
package-lock.json
generated
4138
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/shocknet/Lightning.Pub#readme",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"@grpc/grpc-js": "^1.8.22",
|
||||
"@protobuf-ts/grpc-transport": "^2.5.0",
|
||||
"@protobuf-ts/plugin": "^2.5.0",
|
||||
"@protobuf-ts/runtime": "^2.5.0",
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
"eccrypto": "^1.1.6",
|
||||
"express": "^4.19.2",
|
||||
"globby": "^13.1.2",
|
||||
"grpc-tools": "^1.11.2",
|
||||
"grpc-tools": "^1.12.4",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"nostr-tools": "^1.9.0",
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ get_log_info() {
|
|||
done
|
||||
|
||||
if [ -z "$latest_entry" ]; then
|
||||
log "Error: Failed to retrieve wallet status. Please check the service logs."
|
||||
log "Can't retrieve wallet status, check the service logs."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -88,10 +88,10 @@ get_log_info() {
|
|||
done
|
||||
|
||||
if [ ! -f "$DATA_DIR/.admin_connect" ] && [ ! -f "$DATA_DIR/app.nprofile" ]; then
|
||||
log "Error: Neither .admin_connect nor app.nprofile file found after waiting. Please check the service status."
|
||||
log "Neither .admin_connect nor app.nprofile file found after waiting. Please check the service status."
|
||||
exit 1
|
||||
elif [ -f "$DATA_DIR/.admin_connect" ] && ! [[ $(cat "$DATA_DIR/.admin_connect") == nprofile1* ]] && ! [[ $(cat "$DATA_DIR/.admin_connect") == *:* ]]; then
|
||||
log "Error: Admin connect information is incomplete. Please check the service status."
|
||||
log "Admin connect information is incomplete. Please check the service status."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,13 +1,34 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
LOG_FILE="/var/log/pubdeploy.log"
|
||||
|
||||
touch $LOG_FILE
|
||||
chmod 644 $LOG_FILE
|
||||
|
||||
log() {
|
||||
local message="$(date '+%Y-%m-%d %H:%M:%S') $1"
|
||||
echo -e "$message"
|
||||
echo -e "$(echo $message | sed 's/\\e\[[0-9;]*m//g')" >> $LOG_FILE
|
||||
}
|
||||
|
||||
SCRIPT_VERSION="0.1.0"
|
||||
REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master"
|
||||
BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts/"
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up temporary files..."
|
||||
rm -f /tmp/*.sh
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
log_error() {
|
||||
log "ERROR: $1"
|
||||
log "Exiting with status $2"
|
||||
exit $2
|
||||
}
|
||||
|
||||
BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts/"
|
||||
|
||||
modules=(
|
||||
"utils"
|
||||
|
|
@ -22,6 +43,8 @@ modules=(
|
|||
"extract_nprofile"
|
||||
)
|
||||
|
||||
log "Script version $SCRIPT_VERSION"
|
||||
|
||||
for module in "${modules[@]}"; do
|
||||
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
|
||||
|
|
@ -42,7 +65,6 @@ else
|
|||
log_error "LND installation failed" $install_result
|
||||
fi
|
||||
|
||||
# Extract the LND status from the output
|
||||
lnd_status=$(echo "$lnd_output" | grep "LND_STATUS:" | cut -d':' -f2)
|
||||
|
||||
case $lnd_status in
|
||||
|
|
@ -52,26 +74,9 @@ else
|
|||
*) log "WARNING: Unexpected status from install_lnd: $lnd_status" ;;
|
||||
esac
|
||||
|
||||
install_nodejs || log_error "NodeJS installation failed" $?
|
||||
install_nodejs || log_error "Failed to install Node.js" 1
|
||||
|
||||
pub_output=$(install_lightning_pub)
|
||||
install_result=$?
|
||||
|
||||
if [ $install_result -ne 0 ]; then
|
||||
log_error "Lightning.Pub installation failed" $install_result
|
||||
fi
|
||||
|
||||
# Extract the upgrade status from the output
|
||||
pub_upgrade_status=$(echo "$pub_output" | grep "UPGRADE_STATUS:" | cut -d':' -f2)
|
||||
|
||||
if [ "$pub_upgrade_status" = "100" ]; then
|
||||
log "Lightning.Pub upgrade completed successfully."
|
||||
elif [ "$pub_upgrade_status" = "0" ]; then
|
||||
log "Lightning.Pub fresh installation completed successfully."
|
||||
else
|
||||
log "WARNING: Unexpected return status from install_lightning_pub: $pub_upgrade_status"
|
||||
log "Full output: $pub_output"
|
||||
fi
|
||||
install_lightning_pub "$REPO_URL" || log_error "Failed to install Lightning.Pub" 1
|
||||
|
||||
log "Starting services..."
|
||||
start_services $lnd_status $pub_upgrade_status || log_error "Failed to start services" 1
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
install_lightning_pub() {
|
||||
local REPO_URL="$1"
|
||||
local upgrade_status=0
|
||||
|
||||
if [ -z "$REPO_URL" ]; then
|
||||
log "REPO_URL missing"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6)
|
||||
USER_NAME=$SUDO_USER
|
||||
|
|
@ -12,7 +18,6 @@ install_lightning_pub() {
|
|||
fi
|
||||
|
||||
log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
||||
REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master"
|
||||
|
||||
sudo -u $USER_NAME wget -q $REPO_URL -O $USER_HOME/lightning_pub.tar.gz > /dev/null 2>&1 || {
|
||||
log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}"
|
||||
|
|
@ -54,18 +59,13 @@ install_lightning_pub() {
|
|||
npm_exit_code=$?
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
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}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "npm dependencies installed successfully."
|
||||
|
||||
# Echo a specific string followed by the upgrade status
|
||||
echo "UPGRADE_STATUS:$upgrade_status"
|
||||
return 0 # Always return 0 to indicate success
|
||||
return 0
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ install_nodejs() {
|
|||
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
|
||||
return 0
|
||||
else
|
||||
log "${PRIMARY_COLOR}Updating${RESET_COLOR} Node.js to the LTS version..."
|
||||
fi
|
||||
|
|
@ -36,10 +36,11 @@ install_nodejs() {
|
|||
log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}"
|
||||
fi
|
||||
|
||||
sudo -u $USER_NAME bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts" || {
|
||||
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}"
|
||||
exit 1
|
||||
}
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "Node.js LTS installation completed."
|
||||
return 0
|
||||
}
|
||||
|
|
@ -3,16 +3,6 @@
|
|||
PRIMARY_COLOR="\e[38;5;208m"
|
||||
SECONDARY_COLOR="\e[38;5;165m"
|
||||
RESET_COLOR="\e[0m"
|
||||
LOG_FILE="/var/log/pubdeploy.log"
|
||||
|
||||
touch $LOG_FILE
|
||||
chmod 644 $LOG_FILE
|
||||
|
||||
log() {
|
||||
local message="$(date '+%Y-%m-%d %H:%M:%S') $1"
|
||||
echo -e "$message"
|
||||
echo -e "$(echo $message | sed 's/\\e\[[0-9;]*m//g')" >> $LOG_FILE
|
||||
}
|
||||
|
||||
detect_os_arch() {
|
||||
OS="$(uname -s)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue