deploy
This commit is contained in:
parent
f8895e28e1
commit
12e9b26157
2 changed files with 23 additions and 11 deletions
|
|
@ -1,18 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
install_lightning_pub() {
|
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}..."
|
log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
||||||
REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/fix/bootstrap"
|
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}"
|
log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}"
|
||||||
exit 1
|
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}"
|
log "${PRIMARY_COLOR}Failed to extract Lightning.Pub.${RESET_COLOR}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
rm lightning_pub.tar.gz
|
rm $USER_HOME/lightning_pub.tar.gz
|
||||||
|
|
||||||
if ! command -v rsync &> /dev/null; then
|
if ! command -v rsync &> /dev/null; then
|
||||||
log "${PRIMARY_COLOR}rsync not found, installing...${RESET_COLOR}"
|
log "${PRIMARY_COLOR}rsync not found, installing...${RESET_COLOR}"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@
|
||||||
install_lnd() {
|
install_lnd() {
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6)
|
USER_HOME=$(getent passwd ${SUDO_USER} | cut -d: -f6)
|
||||||
|
USER_NAME=$SUDO_USER
|
||||||
else
|
else
|
||||||
USER_HOME=$HOME
|
USER_HOME=$HOME
|
||||||
|
USER_NAME=$(whoami)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Improved version extraction logic
|
# Improved version extraction logic
|
||||||
|
|
@ -38,7 +40,7 @@ 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
|
||||||
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}"
|
log "${PRIMARY_COLOR}Failed to download LND.${RESET_COLOR}"
|
||||||
exit 1
|
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}"
|
log "${PRIMARY_COLOR}systemctl not found. Please stop ${SECONDARY_COLOR}LND${RESET_COLOR} manually if it is running.${RESET_COLOR}"
|
||||||
fi
|
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}"
|
log "${PRIMARY_COLOR}Failed to extract LND.${RESET_COLOR}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
rm lnd.tar.gz
|
rm $USER_HOME/lnd.tar.gz
|
||||||
mv $USER_HOME/lnd-* $USER_HOME/lnd
|
sudo -u $USER_NAME mv $USER_HOME/lnd-* $USER_HOME/lnd
|
||||||
|
|
||||||
# Create .lnd directory if it doesn't exist
|
# 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
|
# 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
|
||||||
cat <<EOF > $USER_HOME/.lnd/lnd.conf
|
sudo -u $USER_NAME bash -c "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."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue