diff --git a/README.md b/README.md index 81c9a4dc1..562e9a135 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,9 @@ Available `BTCPAYGEN_ADDITIONAL_FRAGMENTS` currently are: * [opt-add-nostr-relay](docker-compose-generator/docker-fragments/opt-add-nostr-relay.yml) for [Nostr Relay](https://github.com/kukks/Nnostr). * [opt-add-cloudflared](docker-compose-generator/docker-fragments/opt-add-cloudflared.yml) to expose your local server on clearnet painlessly ([see documentation](docs/cloudflare-tunnel.md)). * [opt-add-torq](docker-compose-generator/docker-fragments/opt-add-torq.yml) to install [Torq](https://github.com/lncapital/torq) node management application. Requires LND. +* [opt-btc-permitbaremultisig](docker-compose-generator/docker-fragments/opt-btc-permitbaremultisig.yml) to set permitmultisig parameter to false. This prevents the Bitcoin node to accept bare multisig transactions, which are non-common multisig transactions and can be used as a spam attack. + + You can also create your own [custom fragments](#how-can-i-customize-the-generated-docker-compose-file). diff --git a/Tools/ManageFragments/README.md b/Tools/ManageFragments/README.md new file mode 100644 index 000000000..1921e8cd3 --- /dev/null +++ b/Tools/ManageFragments/README.md @@ -0,0 +1,12 @@ +## Interactive script to manage BTCPAYGEN_ADDITIONAL_FRAGMENTS in Docker setup ## + +The tool: +1. Shows the current active additional fragments for the BTCpay Docker +2. Asks the user what they want to do between: +
a. Enables one or more fragments without the ones active +
b. Enables one or more fragments in addition to the existing environment variables by choosing from the list of available fragments +
c. Disables one or more fragments from the list of the current active additional fragments +
d. Cancels and does nothing. + +4. Asks the user to confirm +5. Runs . ./btcpay-setup.sh diff --git a/Tools/ManageFragments/manage-additional-fragments.sh b/Tools/ManageFragments/manage-additional-fragments.sh new file mode 100644 index 000000000..18671e814 --- /dev/null +++ b/Tools/ManageFragments/manage-additional-fragments.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +cd "$(dirname "$0")/.." + +FRAGMENTS_DIR="docker-compose-generator/docker-fragments" +AVAILABLE=($(ls "$FRAGMENTS_DIR" | sort)) +AVAILABLE=($(cd "$FRAGMENTS_DIR" && ls *.yml | sed 's/\.yml$//' | sort)) +ACTIVE=() +IFS=";" read -ra ACTIVE <<< "$BTCPAYGEN_ADDITIONAL_FRAGMENTS" + +# Show current active fragments +echo "šŸ” Current active fragments:" +if [[ -z "$BTCPAYGEN_ADDITIONAL_FRAGMENTS" ]]; then + echo "(none)" +else + for frag in "${ACTIVE[@]}"; do + echo " - $frag" + done +fi +echo "" + +# Show options +echo "What would you like to do?" +echo "1. Enable one or more fragments without the current ones" +echo "2. Enable one or more fragments (add to current)" +echo "3. Disable one or more fragments (remove from current)" +echo "4. Cancel" +read -p "Enter your choice [1-4]: " choice + +if [[ "$choice" == "4" ]]; then + echo "āŒ Cancelled." + exit 0 +fi + +# Show available fragments with numbers +echo "" +echo "šŸ“¦ Available fragments:" +for i in "${!AVAILABLE[@]}"; do + printf "%2d. %s\n" $((i+1)) "${AVAILABLE[$i]}" +done + +read -p $'\nEnter the numbers (comma-separated): ' input +IFS=',' read -ra SELECTED <<< "$input" + +NEW_FRAGMENTS=() + +# Choice handling +case "$choice" in + 1) # Add new fragments without the current ones + for i in "${SELECTED[@]}"; do + idx=$((i-1)) + NEW_FRAGMENTS+=("${AVAILABLE[$idx]}") + done + ;; + 2) # Add selected fragments to the current ones + NEW_FRAGMENTS=("${ACTIVE[@]}") + for i in "${SELECTED[@]}"; do + idx=$((i-1)) + frag="${AVAILABLE[$idx]}" + [[ ! " ${NEW_FRAGMENTS[*]} " =~ " $frag " ]] && NEW_FRAGMENTS+=("$frag") + done + ;; + 3) # Remove selected fragments + REMOVE=() + for i in "${SELECTED[@]}"; do + idx=$((i-1)) + REMOVE+=("${AVAILABLE[$idx]}") + done + for frag in "${ACTIVE[@]}"; do + [[ ! " ${REMOVE[*]} " =~ " $frag " ]] && NEW_FRAGMENTS+=("$frag") + done + ;; + *) + echo "āŒ Invalid choice." + exit 1 + ;; +esac + +# Generate the final string value for BTCPAYGEN_ADDITIONAL_FRAGMENTS +FINAL_VALUE=$(IFS=";"; echo "${NEW_FRAGMENTS[*]}") +echo -e "\nāš™ļø New BTCPAYGEN_ADDITIONAL_FRAGMENTS value:\n$FINAL_VALUE" + +read -p $'\nProceed with this change and run btcpay-setup.sh? (y/N): ' confirm +if [[ "$confirm" =~ ^[Yy]$ ]]; then + echo "āœ… Running btcpay-setup.sh with updated fragments..." + + # Persist the changes to /etc/profile.d/btcpay-env.sh + echo "export BTCPAYGEN_ADDITIONAL_FRAGMENTS=\"$FINAL_VALUE\"" > /etc/profile.d/btcpay-env.sh + + # Create a temporary script to run btcpay-setup.sh with the updated fragments + TEMP_SCRIPT=$(mktemp) + cat > "$TEMP_SCRIPT" <