deploy
This commit is contained in:
parent
3a726f583e
commit
8b1cbbbe8e
5 changed files with 94 additions and 25 deletions
|
|
@ -49,8 +49,10 @@ get_log_info() {
|
|||
log "Creating wallet..."
|
||||
elif echo "$latest_entry" | grep -q "unlocker >> wallet is locked, unlocking"; then
|
||||
log "Unlocking wallet..."
|
||||
else
|
||||
elif echo "$latest_entry" | grep -q "unlocker >> the wallet is already unlocked"; then
|
||||
log "Wallet is already unlocked."
|
||||
else
|
||||
log "Unknown wallet status."
|
||||
fi
|
||||
|
||||
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||
|
|
@ -76,5 +78,5 @@ get_log_info() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
log "Paste this string into ShockWallet to connect to the node: $latest_nprofile_key"
|
||||
log "Paste this admin string into ShockWallet to manage the node: $latest_nprofile_key"
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts/"
|
||||
#BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/scripts/"
|
||||
BASE_URL="https://bolt12.info/deploy"
|
||||
modules=(
|
||||
"utils"
|
||||
"check_homebrew"
|
||||
|
|
@ -37,8 +38,9 @@ if [ "$OS" = "Mac" ]; then
|
|||
handle_macos
|
||||
else
|
||||
install_lnd
|
||||
LND_UPGRADE=$?
|
||||
install_nodejs
|
||||
install_lightning_pub
|
||||
start_services
|
||||
PUB_UPGRADE_STATUS=$(install_lightning_pub)
|
||||
start_services $LND_UPGRADE $PUB_UPGRADE_STATUS
|
||||
get_log_info
|
||||
fi
|
||||
|
|
@ -44,6 +44,13 @@ install_lightning_pub() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$USER_HOME/lightning_pub" ]; then
|
||||
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} is already installed. Upgrading..."
|
||||
PUB_UPGRADE=true
|
||||
else
|
||||
PUB_UPGRADE=false
|
||||
fi
|
||||
|
||||
# Merge if upgrade
|
||||
rsync -av --exclude='*.sqlite' --exclude='.env' --exclude='logs' --exclude='node_modules' --exclude='.jwt_secret' --exclude='.wallet_secret' --exclude='admin.npub' --exclude='app.nprofile' --exclude='.admin_connect' --exclude='.admin_enroll' lightning_pub_temp/ lightning_pub/ > /dev/null 2>&1
|
||||
rm -rf lightning_pub_temp
|
||||
|
|
@ -61,5 +68,13 @@ install_lightning_pub() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} installation completed."
|
||||
if [ "$PUB_UPGRADE" = true ]; then
|
||||
PUB_UPGRADE_STATUS=1
|
||||
else
|
||||
PUB_UPGRADE_STATUS=0
|
||||
fi
|
||||
|
||||
log "PUB_UPGRADE_STATUS set to $PUB_UPGRADE_STATUS"
|
||||
|
||||
echo $PUB_UPGRADE_STATUS
|
||||
}
|
||||
|
|
@ -17,21 +17,23 @@ install_lnd() {
|
|||
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
|
||||
return 0
|
||||
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..."
|
||||
PERFORM_UPGRADE=true
|
||||
;;
|
||||
*)
|
||||
log "$(date '+%Y-%m-%d %H:%M:%S') Upgrade cancelled."
|
||||
return
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log "${PRIMARY_COLOR}Upgrading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} from version $CURRENT_VERSION to $LND_VERSION..."
|
||||
PERFORM_UPGRADE=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
@ -77,4 +79,11 @@ EOF"
|
|||
fi
|
||||
|
||||
log "${SECONDARY_COLOR}LND${RESET_COLOR} installation and configuration completed."
|
||||
|
||||
# Return 1 if it was an upgrade, 0 otherwise
|
||||
if [ "$PERFORM_UPGRADE" = true ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
start_services() {
|
||||
LND_UPGRADE=$1
|
||||
PUB_UPGRADE=$2
|
||||
|
||||
log "Entered start_services with LND_UPGRADE=$LND_UPGRADE and PUB_UPGRADE=$PUB_UPGRADE"
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6)
|
||||
USER_NAME=$SUDO_USER
|
||||
|
|
@ -9,6 +14,8 @@ start_services() {
|
|||
USER_NAME=$(whoami)
|
||||
fi
|
||||
|
||||
log "USER_HOME: $USER_HOME, USER_NAME: $USER_NAME"
|
||||
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
|
||||
sudo bash -c "cat > /etc/systemd/system/lnd.service <<EOF
|
||||
|
|
@ -44,30 +51,64 @@ EOF"
|
|||
sudo systemctl enable lnd >/dev/null 2>&1
|
||||
sudo systemctl enable lightning_pub >/dev/null 2>&1
|
||||
|
||||
if [ "$LND_UPGRADE" = true ]; then
|
||||
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
||||
sudo systemctl restart lnd &
|
||||
lnd_pid=$!
|
||||
wait $lnd_pid
|
||||
if systemctl is-active --quiet lnd; then
|
||||
log "LND restarted successfully using systemd."
|
||||
else
|
||||
log "Failed to restart ${SECONDARY_COLOR}LND${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
||||
sudo systemctl start lnd &
|
||||
lnd_pid=$!
|
||||
wait $lnd_pid
|
||||
if systemctl is-active --quiet lnd; then
|
||||
log "${SECONDARY_COLOR}LND${RESET_COLOR} started successfully using systemd."
|
||||
log "LND started successfully using systemd."
|
||||
else
|
||||
log "Failed to start ${SECONDARY_COLOR}LND${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Giving ${SECONDARY_COLOR}LND${RESET_COLOR} a few seconds to start before starting ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
||||
sleep 10
|
||||
|
||||
if [ "$PUB_UPGRADE" = "1" ]; then
|
||||
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||
sudo systemctl restart lightning_pub &
|
||||
lightning_pub_pid=$!
|
||||
wait $lightning_pub_pid
|
||||
if systemctl is-active --quiet lightning_pub; then
|
||||
log "Lightning.Pub restarted successfully using systemd."
|
||||
else
|
||||
log "Failed to restart ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||
sudo systemctl start lightning_pub &
|
||||
lightning_pub_pid=$!
|
||||
wait $lightning_pub_pid
|
||||
if systemctl is-active --quiet lightning_pub; then
|
||||
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} started successfully using systemd."
|
||||
log "Lightning.Pub started successfully using systemd."
|
||||
else
|
||||
log "Failed to start ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Checking status of ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||
if sudo systemctl is-active lightning_pub >/dev/null 2>&1; then
|
||||
log "Lightning.Pub is started"
|
||||
else
|
||||
log "Lightning.Pub is not started"
|
||||
fi
|
||||
|
||||
else
|
||||
create_start_script
|
||||
log "systemctl not available. Created start.sh. Please use this script to start the services manually."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue