Browse Source

Make sure we do not announce domains ending in .lan and .local (#149)

* Do not announce internal hostname

* update environment on btcpay-update.sh

* Rename to btcpay_update_docker_env

* Properly quote enclose some env variables
feature/more-args
Nicolas Dorier 6 years ago
committed by GitHub
parent
commit
947f9fdce9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      btcpay-setup.sh
  2. 1
      btcpay-update.sh
  3. 9
      changedomain.sh
  4. 2
      docker-compose-generator/docker-fragments/bitcoin-clightning.yml
  5. 2
      docker-compose-generator/docker-fragments/bitcoin-lnd.yml
  6. 2
      docker-compose-generator/docker-fragments/litecoin-clightning.yml
  7. 2
      docker-compose-generator/docker-fragments/litecoin-lnd.yml
  8. 38
      helpers.sh

42
btcpay-setup.sh

@ -109,9 +109,9 @@ fi
: "${ACME_CA_URI:=https://acme-v01.api.letsencrypt.org/directory}"
: "${BTCPAY_PROTOCOL:=https}"
OLD_BTCPAY_DOCKER_COMPOSE=$BTCPAY_DOCKER_COMPOSE
ORIGINAL_DIRECTORY=$(pwd)
BTCPAY_BASE_DIRECTORY="$(dirname $(pwd))"
OLD_BTCPAY_DOCKER_COMPOSE="$BTCPAY_DOCKER_COMPOSE"
ORIGINAL_DIRECTORY="$(pwd)"
BTCPAY_BASE_DIRECTORY="$(dirname "$(pwd)")"
if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then
if [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production ]]; then
@ -146,16 +146,11 @@ if [[ "$BTCPAYGEN_REVERSEPROXY" == "nginx" ]] && [[ "$BTCPAY_HOST" ]]; then
BTCPAY_HOST="$DOMAIN_NAME"
fi
BTCPAY_CRYPTOS=""
for i in "$BTCPAYGEN_CRYPTO1" "$BTCPAYGEN_CRYPTO2" "$BTCPAYGEN_CRYPTO3" "$BTCPAYGEN_CRYPTO4" "$BTCPAYGEN_CRYPTO5" "$BTCPAYGEN_CRYPTO5" "$BTCPAYGEN_CRYPTO6" "$BTCPAYGEN_CRYPTO7" "$BTCPAYGEN_CRYPTO8"
do
if [ ! -z "$i" ]; then
if [ ! -z "$BTCPAY_CRYPTOS" ]; then
BTCPAY_CRYPTOS="$BTCPAY_CRYPTOS;"
fi
BTCPAY_CRYPTOS="$BTCPAY_CRYPTOS$i"
fi
done
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh
btcpay_expand_variables
cd "$ORIGINAL_DIRECTORY"
echo "
-------SETUP-----------
@ -193,6 +188,7 @@ BTCPAYGEN_OLD_PREGEN=$BTCPAYGEN_OLD_PREGEN
BTCPAY_SSHKEYFILE=$BTCPAY_SSHKEYFILE
BTCPAY_SSHTRUSTEDFINGERPRINTS:$BTCPAY_SSHTRUSTEDFINGERPRINTS
BTCPAY_CRYPTOS:$BTCPAY_CRYPTOS
BTCPAY_ANNOUNCEABLE_HOST:$BTCPAY_ANNOUNCEABLE_HOST
----------------------
"
@ -235,22 +231,7 @@ chmod +x /etc/profile.d/btcpay-env.sh
echo -e "BTCPay Server environment variables successfully saved in /etc/profile.d/btcpay-env.sh\n"
# Set .env file
touch $BTCPAY_ENV_FILE
echo "
BTCPAY_PROTOCOL=$BTCPAY_PROTOCOL
BTCPAY_HOST=$BTCPAY_HOST
BTCPAY_IMAGE=$BTCPAY_IMAGE
ACME_CA_URI=$ACME_CA_URI
NBITCOIN_NETWORK=$NBITCOIN_NETWORK
LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL
LIGHTNING_ALIAS=$LIGHTNING_ALIAS
BTCPAY_SSHTRUSTEDFINGERPRINTS=$BTCPAY_SSHTRUSTEDFINGERPRINTS
BTCPAY_SSHKEYFILE=$BTCPAY_SSHKEYFILE
LIBREPATRON_HOST=$LIBREPATRON_HOST
BTCTRANSMUTER_HOST=$BTCTRANSMUTER_HOST
BTCPAY_CRYPTOS=$BTCPAY_CRYPTOS
WOOCOMMERCE_HOST=$WOOCOMMERCE_HOST" > $BTCPAY_ENV_FILE
btcpay_update_docker_env
echo -e "BTCPay Server docker-compose parameters saved in $BTCPAY_ENV_FILE\n"
. /etc/profile.d/btcpay-env.sh
@ -406,8 +387,7 @@ if [[ -f "$BTCPAY_HOST_SSHKEYFILE" ]]; then
docker cp "$BTCPAY_HOST_SSHKEYFILE" $(docker ps --filter "name=_btcpayserver_" -q):$BTCPAY_SSHKEYFILE
fi
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
install_tooling
cd $ORIGINAL_DIRECTORY

1
btcpay-update.sh

@ -43,6 +43,7 @@ fi
. helpers.sh
install_tooling
btcpay_update_docker_env
cd "`dirname $BTCPAY_ENV_FILE`"
docker-compose -f $BTCPAY_DOCKER_COMPOSE up -d --remove-orphans -t "${COMPOSE_HTTP_TIMEOUT:-180}"

9
changedomain.sh

@ -13,11 +13,12 @@ echo "Changing domain from \"$OLD_HOST\" to \"$NEW_HOST\""
export BTCPAY_HOST="$NEW_HOST"
export ACME_CA_URI="https://acme-v01.api.letsencrypt.org/directory"
ORIGINAL_DIRECTORY="$(pwd)"
# Modify environment file
sed -i '/^BTCPAY_HOST/d' "$BTCPAY_ENV_FILE"
sed -i '/^ACME_CA_URI/d' "$BTCPAY_ENV_FILE"
echo "BTCPAY_HOST=$BTCPAY_HOST" >> "$BTCPAY_ENV_FILE"
echo "ACME_CA_URI=$ACME_CA_URI" >> "$BTCPAY_ENV_FILE"
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh
btcpay_update_docker_env
cd "$ORIGINAL_DIRECTORY"
cd "`dirname $BTCPAY_ENV_FILE`"
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d -t "${COMPOSE_HTTP_TIMEOUT:-180}"

2
docker-compose-generator/docker-fragments/bitcoin-clightning.yml

@ -9,7 +9,7 @@ services:
LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest}
LIGHTNINGD_CHAIN: btc
LIGHTNINGD_ALIAS: ${LIGHTNING_ALIAS}
LIGHTNINGD_ANNOUNCEADDR: ${BTCPAY_HOST}
LIGHTNINGD_ANNOUNCEADDR: ${BTCPAY_ANNOUNCEABLE_HOST}
LIGHTNINGD_PORT: 9735
LIGHTNINGD_READY_FILE: /root/.nbxplorer/btc_fully_synched
LIGHTNINGD_OPT: |

2
docker-compose-generator/docker-fragments/bitcoin-lnd.yml

@ -7,7 +7,7 @@ services:
restart: unless-stopped
environment:
LND_CHAIN: "btc"
LND_EXTERNALIP: ${BTCPAY_HOST}
LND_EXTERNALIP: ${BTCPAY_ANNOUNCEABLE_HOST}
LND_PORT: 9735
LND_ALIAS: ${LIGHTNING_ALIAS}
LND_ENVIRONMENT: "${NBITCOIN_NETWORK:-regtest}"

2
docker-compose-generator/docker-fragments/litecoin-clightning.yml

@ -9,7 +9,7 @@ services:
LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest}
LIGHTNINGD_CHAIN: ltc
LIGHTNINGD_ALIAS: ${LIGHTNING_ALIAS}
LIGHTNINGD_ANNOUNCEADDR: ${BTCPAY_HOST}
LIGHTNINGD_ANNOUNCEADDR: ${BTCPAY_ANNOUNCEABLE_HOST}
LIGHTNINGD_PORT: 9735
LIGHTNINGD_READY_FILE: /root/.nbxplorer/ltc_fully_synched
LIGHTNINGD_OPT: |

2
docker-compose-generator/docker-fragments/litecoin-lnd.yml

@ -7,7 +7,7 @@ services:
restart: unless-stopped
environment:
LND_CHAIN: "ltc"
LND_EXTERNALIP: ${BTCPAY_HOST}
LND_EXTERNALIP: ${BTCPAY_ANNOUNCEABLE_HOST}
LND_PORT: 9736
LND_ALIAS: ${LIGHTNING_ALIAS}
LND_ENVIRONMENT: "${NBITCOIN_NETWORK:-regtest}"

38
helpers.sh

@ -44,4 +44,42 @@ install_tooling() {
fi
i=`expr $i + 3`
done
}
btcpay_expand_variables() {
BTCPAY_CRYPTOS=""
for i in "$BTCPAYGEN_CRYPTO1" "$BTCPAYGEN_CRYPTO2" "$BTCPAYGEN_CRYPTO3" "$BTCPAYGEN_CRYPTO4" "$BTCPAYGEN_CRYPTO5" "$BTCPAYGEN_CRYPTO5" "$BTCPAYGEN_CRYPTO6" "$BTCPAYGEN_CRYPTO7" "$BTCPAYGEN_CRYPTO8"
do
if [ ! -z "$i" ]; then
if [ ! -z "$BTCPAY_CRYPTOS" ]; then
BTCPAY_CRYPTOS="$BTCPAY_CRYPTOS;"
fi
BTCPAY_CRYPTOS="$BTCPAY_CRYPTOS$i"
fi
done
BTCPAY_ANNOUNCEABLE_HOST=""
if [[ "$BTCPAY_HOST" != *.local ]] && [[ "$BTCPAY_HOST" != *.lan ]]; then
BTCPAY_ANNOUNCEABLE_HOST="$BTCPAY_HOST"
fi
}
# Set .env file
btcpay_update_docker_env() {
btcpay_expand_variables
touch $BTCPAY_ENV_FILE
echo "
BTCPAY_PROTOCOL=$BTCPAY_PROTOCOL
BTCPAY_HOST=$BTCPAY_HOST
BTCPAY_ANNOUNCEABLE_HOST=$BTCPAY_ANNOUNCEABLE_HOST
BTCPAY_IMAGE=$BTCPAY_IMAGE
ACME_CA_URI=$ACME_CA_URI
NBITCOIN_NETWORK=$NBITCOIN_NETWORK
LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL
LIGHTNING_ALIAS=$LIGHTNING_ALIAS
BTCPAY_SSHTRUSTEDFINGERPRINTS=$BTCPAY_SSHTRUSTEDFINGERPRINTS
BTCPAY_SSHKEYFILE=$BTCPAY_SSHKEYFILE
LIBREPATRON_HOST=$LIBREPATRON_HOST
BTCTRANSMUTER_HOST=$BTCTRANSMUTER_HOST
BTCPAY_CRYPTOS=$BTCPAY_CRYPTOS
WOOCOMMERCE_HOST=$WOOCOMMERCE_HOST" > $BTCPAY_ENV_FILE
}
Loading…
Cancel
Save