forked from dogecoin/dogecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dogecoin#3549 from GaloisField2718/master
Add gen-dogecoin-conf.sh from bitcoin core github
- Loading branch information
Showing
2 changed files
with
540 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2021 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
export LC_ALL=C | ||
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} | ||
BUILDDIR=${BUILDDIR:-$TOPDIR} | ||
BINDIR=${BINDIR:-$BUILDDIR/src} | ||
DOGECOIND=${DOGECOIND:-$BINDIR/dogecoind} | ||
SHARE_DIR=${SHARE_DIR:-$TOPDIR/share} | ||
EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_DIR/dogecoin.conf} | ||
|
||
[ ! -x "$DOGECOIND" ] && echo "$DOGECOIND not found or not executable." && exit 1 | ||
|
||
DIRTY="" | ||
VERSION_OUTPUT=$($DOGECOIND --version) | ||
if [[ $VERSION_OUTPUT == *"dirty"* ]]; then | ||
DIRTY="${DIRTY}${DOGECOIND}\n" | ||
fi | ||
|
||
if [ -n "$DIRTY" ] | ||
then | ||
echo -e "WARNING: $DOGECOIND was built from a dirty tree.\n" | ||
echo -e "To safely generate a dogecoin.conf file, please commit your changes to $DOGECOIND, rebuild, then run this script again.\n" | ||
fi | ||
|
||
echo 'Generating example dogecoin.conf file in share/' | ||
|
||
# create the directory, if it doesn't exist | ||
mkdir -p "${SHARE_DIR}" | ||
|
||
# create the header text | ||
cat > "${EXAMPLE_CONF_FILE}" << 'EOF' | ||
## | ||
## dogecoin.conf configuration file. | ||
## Generated by contrib/devtools/gen-dogecoin-conf.sh. | ||
## | ||
## Lines beginning with # are comments. | ||
## All possible configuration options are provided. To use, copy this file | ||
## to your data directory (default or specified by -datadir), uncomment | ||
## options you would like to change, and save the file. | ||
## | ||
### Options | ||
EOF | ||
|
||
# parse the output from dogecoind --help | ||
# adding newlines is a bit funky to ensure portability for BSD | ||
# see here for more details: https://stackoverflow.com/a/24575385 | ||
${DOGECOIND} --help \ | ||
| sed '1,/Print this help message and exit/d' \ | ||
| sed -E 's/^[[:space:]]{2}\-/#/' \ | ||
| sed -E 's/^[[:space:]]{7}/# /' \ | ||
| sed -E '/[=[:space:]]/!s/#.*$/&=1/' \ | ||
| awk '/^#[a-z]/{x=$0;next}{if (NF==0) print x"\n",x="";else print}' \ | ||
| sed 's,\(^[[:upper:]].*\)\:$,\ | ||
### \1,' \ | ||
| sed 's/[[:space:]]*$//' >> "${EXAMPLE_CONF_FILE}" | ||
|
||
# create the footer text | ||
cat >> "${EXAMPLE_CONF_FILE}" << 'EOF' | ||
# [Sections] | ||
# Most options will apply to all networks. To confine an option to a specific | ||
# network, add it under the relevant section below. | ||
# | ||
# Note: If not specified under a network section, the options addnode, connect, | ||
# port, bind, rpcport, rpcbind, and wallet will only apply to mainnet. | ||
# Options for mainnet | ||
[main] | ||
# Options for testnet | ||
[test] | ||
# Options for regtest | ||
[regtest] | ||
EOF |
Oops, something went wrong.