userspace, better-sqlite
This commit is contained in:
parent
06ca76419b
commit
f1c5b79eb1
6 changed files with 2121 additions and 1958 deletions
3981
package-lock.json
generated
3981
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -38,6 +38,7 @@
|
||||||
"@types/secp256k1": "^4.0.3",
|
"@types/secp256k1": "^4.0.3",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"bech32": "^2.0.0",
|
"bech32": "^2.0.0",
|
||||||
|
"better-sqlite3": "^9.6.0",
|
||||||
"bitcoin-core": "^4.2.0",
|
"bitcoin-core": "^4.2.0",
|
||||||
"chai": "^4.3.7",
|
"chai": "^4.3.7",
|
||||||
"chai-string": "^1.5.0",
|
"chai-string": "^1.5.0",
|
||||||
|
|
@ -57,10 +58,9 @@
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
"secp256k1": "^5.0.1",
|
"secp256k1": "^5.0.1",
|
||||||
"sqlite3": "^5.1.7",
|
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.7.0",
|
||||||
"ts-proto": "^1.131.2",
|
"ts-proto": "^1.131.2",
|
||||||
"typeorm": "0.3.15",
|
"typeorm": "^0.3.26",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"uri-template": "^2.0.0",
|
"uri-template": "^2.0.0",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
LOG_FILE="/var/log/pubdeploy.log"
|
# Use user-space log file
|
||||||
|
LOG_FILE="$HOME/.lightning_pub/install.log"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$LOG_FILE")"
|
||||||
touch $LOG_FILE
|
touch $LOG_FILE
|
||||||
chmod 644 $LOG_FILE
|
chmod 644 $LOG_FILE
|
||||||
|
|
||||||
|
|
@ -18,7 +20,7 @@ BASE_URL="https://raw.githubusercontent.com/shocknet/Lightning.Pub/master/script
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "Cleaning up temporary files..."
|
echo "Cleaning up temporary files..."
|
||||||
rm -f /tmp/*.sh
|
rm -f "$HOME/.lightning_pub/tmp"/*.sh 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
@ -45,9 +47,12 @@ modules=(
|
||||||
|
|
||||||
log "Script version $SCRIPT_VERSION"
|
log "Script version $SCRIPT_VERSION"
|
||||||
|
|
||||||
|
# Create user-space temp directory
|
||||||
|
mkdir -p "$HOME/.lightning_pub/tmp"
|
||||||
|
|
||||||
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 "$HOME/.lightning_pub/tmp/${module}.sh" || log_error "Failed to download ${module}.sh" 1
|
||||||
source "/tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1
|
source "$HOME/.lightning_pub/tmp/${module}.sh" || log_error "Failed to source ${module}.sh" 1
|
||||||
done
|
done
|
||||||
|
|
||||||
detect_os_arch
|
detect_os_arch
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ install_lightning_pub() {
|
||||||
|
|
||||||
log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
||||||
|
|
||||||
sudo -u $USER_NAME wget -q $REPO_URL -O $USER_HOME/lightning_pub.tar.gz > /dev/null 2>&1 || {
|
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}"
|
log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
sudo -u $USER_NAME mkdir -p $USER_HOME/lightning_pub_temp
|
mkdir -p $USER_HOME/lightning_pub_temp
|
||||||
sudo -u $USER_NAME tar -xzf $USER_HOME/lightning_pub.tar.gz -C $USER_HOME/lightning_pub_temp --strip-components=1 > /dev/null 2>&1 || {
|
tar -xzf $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}"
|
log "${PRIMARY_COLOR}Failed to extract Lightning.Pub.${RESET_COLOR}"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,41 +54,41 @@ install_lnd() {
|
||||||
log "${PRIMARY_COLOR}Downloading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR}..."
|
log "${PRIMARY_COLOR}Downloading${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR}..."
|
||||||
|
|
||||||
# Start the download
|
# Start the download
|
||||||
sudo -u $USER_NAME wget -q $LND_URL -O $USER_HOME/lnd.tar.gz || {
|
wget -q $LND_URL -O $USER_HOME/lnd.tar.gz || {
|
||||||
log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}"
|
log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if LND is already running and stop it if necessary (Linux)
|
# Check if LND is already running and stop it if necessary (user-space)
|
||||||
if [ "$OS" = "Linux" ] && [ "$SYSTEMCTL_AVAILABLE" = true ]; then
|
if [ "$OS" = "Linux" ] && command -v systemctl >/dev/null 2>&1; then
|
||||||
if systemctl is-active --quiet lnd; then
|
if systemctl --user is-active --quiet lnd 2>/dev/null; then
|
||||||
log "${PRIMARY_COLOR}Stopping${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
log "${PRIMARY_COLOR}Stopping${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} user service..."
|
||||||
sudo systemctl stop lnd
|
systemctl --user stop lnd
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log "${PRIMARY_COLOR}systemctl not found. Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}"
|
log "${PRIMARY_COLOR}Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo -u $USER_NAME tar -xzf $USER_HOME/lnd.tar.gz -C $USER_HOME > /dev/null || {
|
tar -xzf $USER_HOME/lnd.tar.gz -C $USER_HOME > /dev/null || {
|
||||||
log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}"
|
log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
rm $USER_HOME/lnd.tar.gz
|
rm $USER_HOME/lnd.tar.gz
|
||||||
sudo -u $USER_NAME mv $USER_HOME/lnd-* $USER_HOME/lnd
|
mv $USER_HOME/lnd-* $USER_HOME/lnd
|
||||||
|
|
||||||
# Create .lnd directory if it doesn't exist
|
# Create .lnd directory if it doesn't exist
|
||||||
sudo -u $USER_NAME mkdir -p $USER_HOME/.lnd
|
mkdir -p $USER_HOME/.lnd
|
||||||
|
|
||||||
# Check if lnd.conf already exists and avoid overwriting it
|
# Check if lnd.conf already exists and avoid overwriting it
|
||||||
if [ -f $USER_HOME/.lnd/lnd.conf ]; then
|
if [ -f $USER_HOME/.lnd/lnd.conf ]; then
|
||||||
log "${PRIMARY_COLOR}lnd.conf already exists. Skipping creation of new lnd.conf file.${RESET_COLOR}"
|
log "${PRIMARY_COLOR}lnd.conf already exists. Skipping creation of new lnd.conf file.${RESET_COLOR}"
|
||||||
else
|
else
|
||||||
sudo -u $USER_NAME bash -c "cat <<EOF > $USER_HOME/.lnd/lnd.conf
|
cat <<EOF > $USER_HOME/.lnd/lnd.conf
|
||||||
bitcoin.mainnet=true
|
bitcoin.mainnet=true
|
||||||
bitcoin.node=neutrino
|
bitcoin.node=neutrino
|
||||||
neutrino.addpeer=neutrino.shock.network
|
neutrino.addpeer=neutrino.shock.network
|
||||||
feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json
|
feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json
|
||||||
EOF"
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "${SECONDARY_COLOR}LND${RESET_COLOR} installation and configuration completed."
|
log "${SECONDARY_COLOR}LND${RESET_COLOR} installation and configuration completed."
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,21 @@ start_services() {
|
||||||
|
|
||||||
if [ "$OS" = "Linux" ]; then
|
if [ "$OS" = "Linux" ]; then
|
||||||
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
|
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
|
||||||
sudo bash -c "cat > /etc/systemd/system/lnd.service <<EOF
|
mkdir -p "$HOME/.config/systemd/user"
|
||||||
|
cat > "$HOME/.config/systemd/user/lnd.service" <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=LND Service
|
Description=LND Service
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=${USER_HOME}/lnd/lnd
|
ExecStart=${USER_HOME}/lnd/lnd
|
||||||
User=${USER_NAME}
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
EOF"
|
EOF
|
||||||
|
|
||||||
sudo bash -c "cat > /etc/systemd/system/lightning_pub.service <<EOF
|
cat > "$HOME/.config/systemd/user/lightning_pub.service" <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Lightning.Pub Service
|
Description=Lightning.Pub Service
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
@ -36,32 +36,31 @@ After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/bash -c 'source ${NVM_DIR}/nvm.sh && npm start'
|
ExecStart=/bin/bash -c 'source ${NVM_DIR}/nvm.sh && npm start'
|
||||||
WorkingDirectory=${USER_HOME}/lightning_pub
|
WorkingDirectory=${USER_HOME}/lightning_pub
|
||||||
User=${USER_NAME}
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
EOF"
|
EOF
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
systemctl --user daemon-reload
|
||||||
sudo systemctl enable lnd >/dev/null 2>&1
|
systemctl --user enable lnd >/dev/null 2>&1
|
||||||
sudo systemctl enable lightning_pub >/dev/null 2>&1
|
systemctl --user enable lightning_pub >/dev/null 2>&1
|
||||||
|
|
||||||
# Always attempt to start or restart LND
|
# Always attempt to start or restart LND
|
||||||
if systemctl is-active --quiet lnd; then
|
if systemctl --user is-active --quiet lnd; then
|
||||||
if [ "$LND_STATUS" = "1" ]; then
|
if [ "$LND_STATUS" = "1" ]; then
|
||||||
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
||||||
sudo systemctl restart lnd
|
systemctl --user restart lnd
|
||||||
else
|
else
|
||||||
log "${SECONDARY_COLOR}LND${RESET_COLOR} service is already running."
|
log "${SECONDARY_COLOR}LND${RESET_COLOR} service is already running."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
||||||
sudo systemctl start lnd
|
systemctl --user start lnd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check LND status after attempting to start/restart
|
# Check LND status after attempting to start/restart
|
||||||
if ! systemctl is-active --quiet lnd; then
|
if ! systemctl --user is-active --quiet lnd; then
|
||||||
log "Failed to start or restart ${SECONDARY_COLOR}LND${RESET_COLOR}. Please check the logs."
|
log "Failed to start or restart ${SECONDARY_COLOR}LND${RESET_COLOR}. Please check the logs."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -70,20 +69,20 @@ EOF"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
# Always attempt to start or restart Lightning.Pub
|
# Always attempt to start or restart Lightning.Pub
|
||||||
if systemctl is-active --quiet lightning_pub; then
|
if systemctl --user is-active --quiet lightning_pub; then
|
||||||
if [ "$PUB_UPGRADE" = "100" ]; then
|
if [ "$PUB_UPGRADE" = "100" ]; then
|
||||||
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
log "${PRIMARY_COLOR}Restarting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||||
sudo systemctl restart lightning_pub
|
systemctl --user restart lightning_pub
|
||||||
else
|
else
|
||||||
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service is already running."
|
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service is already running."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||||
sudo systemctl start lightning_pub
|
systemctl --user start lightning_pub
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check Lightning.Pub status after attempting to start/restart
|
# Check Lightning.Pub status after attempting to start/restart
|
||||||
if ! systemctl is-active --quiet lightning_pub; then
|
if ! systemctl --user is-active --quiet lightning_pub; then
|
||||||
log "Failed to start or restart ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}. Please check the logs."
|
log "Failed to start or restart ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}. Please check the logs."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -112,9 +111,7 @@ LND_PID=\$!
|
||||||
sleep 10
|
sleep 10
|
||||||
npm start &
|
npm start &
|
||||||
NODE_PID=\$!
|
NODE_PID=\$!
|
||||||
wait \$LND_PID
|
wait \$LND_PID \$NODE_PID
|
||||||
wait \$NODE_PID
|
|
||||||
EOF
|
EOF
|
||||||
chmod +x start.sh
|
chmod +x start.sh
|
||||||
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