#!/usr/bin/env bash # # Edit the values in this section, then run: # ./launch.sh # # Command-line arguments passed to this launcher are appended to the generated # command, so they can deliberately override a setting below when needed. set -euo pipefail # Required for the nginx/Let's Encrypt setup. LWD_HOSTNAME="" LETS_ENCRYPT_EMAIL="" ENABLE_LETS_ENCRYPT=true # Lightwalletd listener and data locations. GRPC_BIND_ADDR="127.0.0.1:9067" HTTP_BIND_ADDR="127.0.0.1:9068" DATA_DIR="/var/lib/lightwalletd" # Leave false for the normal all-CPU build behavior. Set true on a small VPS # if Pirate's C++ compiler is killed for lack of RAM. LOW_MEMORY=false # Optional Insight explorer. Leave blank to skip it. EXPLORER_HOSTNAME="" # Optional authoritative DNS seed. Fill in all three values to enable it. # The DNS seed can use the same VPS as lightwalletd, but should use its own # hostname/zone. DNSSEED_HOST is the zone queried by Pirate clients, while # DNSSEED_NS is the authoritative nameserver hostname for that zone. Example: # DNSSEED_HOST="dnsseed.example.com" # DNSSEED_NS="ns-dnsseed.example.com" # Create an A/AAAA record for DNSSEED_NS pointing to the VPS, then delegate # DNSSEED_HOST to it with an NS record at your DNS provider. DNSSEED_HOST="" DNSSEED_NS="" # DNSSEED_MBOX is the SOA responsible mailbox (RNAME), encoded as DNS text. # Replace the @ in an email with a dot: admin@example.com becomes # admin.example.com. Do not enter a literal email address here. DNSSEED_MBOX="" # Optional Pirate 6.0.3+ support for operator-managed blocknotify/alertnotify # commands. Leave false unless your PIRATE.conf intentionally uses either. ENABLE_SYSTEM_COMMAND=false # Add any less-common setup-arrr-lightwalletd.sh options here. Examples: # EXTRA_ARGS=(--dnsseed-port 5353 --p2p-port 45452) EXTRA_ARGS=() script_source="${BASH_SOURCE[0]:-$0}" script_dir=$(cd -- "$(dirname -- "$script_source")" && pwd) setup_script="$script_dir/setup-arrr-lightwalletd.sh" err() { printf 'ERROR: %s\n' "$*" >&2 exit 1 } is_boolean() { [ "$1" = true ] || [ "$1" = false ] } is_placeholder() { [[ "$1" == "<"*">" ]] } if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then exec "$setup_script" --help fi [ -x "$setup_script" ] || err "Installer not found or not executable: $setup_script" is_placeholder "$LWD_HOSTNAME" && err "Set LWD_HOSTNAME at the top of $0 before running it" is_placeholder "$LETS_ENCRYPT_EMAIL" && err "Set LETS_ENCRYPT_EMAIL at the top of $0 before running it" is_boolean "$ENABLE_LETS_ENCRYPT" || err "ENABLE_LETS_ENCRYPT must be true or false" is_boolean "$ENABLE_SYSTEM_COMMAND" || err "ENABLE_SYSTEM_COMMAND must be true or false" is_boolean "$LOW_MEMORY" || err "LOW_MEMORY must be true or false" if [ "$ENABLE_LETS_ENCRYPT" != true ]; then err "This launcher expects ENABLE_LETS_ENCRYPT=true; run the setup script directly for custom/direct TLS" fi if [ -n "$EXPLORER_HOSTNAME" ] && [ "$EXPLORER_HOSTNAME" = "$LWD_HOSTNAME" ]; then err "EXPLORER_HOSTNAME must differ from LWD_HOSTNAME" fi dnsseed_values=("$DNSSEED_HOST" "$DNSSEED_NS" "$DNSSEED_MBOX") dnsseed_values_present=0 for value in "${dnsseed_values[@]}"; do if [ -n "$value" ]; then ((dnsseed_values_present += 1)) fi done if [ "$dnsseed_values_present" -ne 0 ] && [ "$dnsseed_values_present" -ne 3 ]; then err "Set DNSSEED_HOST, DNSSEED_NS, and DNSSEED_MBOX together, or leave all three blank" fi if [[ "$DNSSEED_MBOX" == *"@"* ]]; then err "DNSSEED_MBOX is an SOA RNAME: use admin.example.com for admin@example.com" fi args=( --hostname "$LWD_HOSTNAME" --email "$LETS_ENCRYPT_EMAIL" --lets-encrypt --bind-addr "$GRPC_BIND_ADDR" --http-bind-addr "$HTTP_BIND_ADDR" --data-dir "$DATA_DIR" ) if [ -n "$EXPLORER_HOSTNAME" ]; then args+=(--explorer-hostname "$EXPLORER_HOSTNAME") fi if [ "$dnsseed_values_present" -eq 3 ]; then args+=( --dnsseed-host "$DNSSEED_HOST" --dnsseed-ns "$DNSSEED_NS" --dnsseed-mbox "$DNSSEED_MBOX" ) fi if [ "$ENABLE_SYSTEM_COMMAND" = true ]; then args+=(--enable-system-command) fi if [ "$LOW_MEMORY" = true ]; then args+=(--low-memory) fi printf 'Running: ' printf '%q ' "$setup_script" "${args[@]}" "${EXTRA_ARGS[@]}" "$@" echo exec "$setup_script" "${args[@]}" "${EXTRA_ARGS[@]}" "$@"