diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2eafcb4..9217489 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -47,13 +47,13 @@ set_locale() init_config() { ## Write a default variables to dm config - sed -i -e "/\[main\]/,/\[/ s/^user\s*=.*/user=$UNAME/" \ - -e "/\[main\]/,/\[/ s/^group\s*=.*/group=$UNAME/" \ - -e "/\[main\]/,/\[/ s/^workers\s*=.*/workers=$(nproc)/" \ - -e "/\[module\/WebSocket\]/,/\[/ s/^enable\s*=.*/enable=true/" \ - -e "/\[daemon\]/,/\[/ s/^daemon\s*=.*/daemon=false/" \ - -e "/\[server\]/,/\[/ s/^listen\s*=.*/listen=0.0.0.0/" \ - -e "/\[server\]/,/\[/ s/^port\s*=.*/port=4999/" $CONF_FILES + sed -i -e "/\[main\]/,/\[/ s/^#*user=.*/user=$UNAME/" \ + -e "/\[main\]/,/\[/ s/^#*group=.*/group=$UNAME/" \ + -e "/\[main\]/,/\[/ s/^#*workers=.*/workers=$(nproc)/" \ + -e "/\[module\/WebSocket\]/,/\[/ s/^#*enable=.*/enable=true/" \ + -e "/\[daemon\]/,/\[/ s/^#*daemon=.*/daemon=false/" \ + -e "/\[server\]/,/\[/ s/^#*listen=.*/listen=0.0.0.0/" \ + -e "/\[server\]/,/\[/ s/^#*port=.*/port=4999/" $CONF_FILES ## Change dm Website config sed -i "s|dmHost:.*|dmHost: \"$DM_FORWEB\",|" $WEB_CONF_FILE @@ -81,30 +81,30 @@ init_config() sponge $WEB_CONF_SITES ## Write the PGP keys locations to dm config - sed -i "/\[pgp\]/,/\[/ s%^private\s*=.*%private=$PGP_SEC_FILE%" $CONF_FILES + sed -i "/\[pgp\]/,/\[/ s%^#*private=.*%private=$PGP_SEC_FILE%" $CONF_FILES if [ "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true ]; then - sed -i "/\[pgp\]/,/\[/ s%^public\s*=.*%public=$BITDEALS_TESTNET_PGP_FILE%" $CONF_FILES + sed -i "/\[pgp\]/,/\[/ s%^#*public=.*%public=$BITDEALS_TESTNET_PGP_FILE%" $CONF_FILES else - sed -i "/\[pgp\]/,/\[/ s%^public\s*=.*%public=$BITDEALS_PGP_FILE%" $CONF_FILES + sed -i "/\[pgp\]/,/\[/ s%^#*public=.*%public=$BITDEALS_PGP_FILE%" $CONF_FILES fi ## Write a user variables to the daemon config files. if [ "$DM_BITCOIN" ]; then - sed -i "/\[module\]/,/\[/ s/^address\s*=.*/address=$DM_BITCOIN/" $CONF_FILES + sed -i "/\[module\]/,/\[/ s/^#*address=.*/address=$DM_BITCOIN/" $CONF_FILES fi if [ "$DM_FEE" ]; then - sed -i "/\[module\]/,/\[/ s/^#\?fee\s*=.*/fee=$DM_FEE/" $CONF_FILES + sed -i "/\[module\]/,/\[/ s/^#*fee=.*/fee=$DM_FEE/" $CONF_FILES fi if [ "$DM_PGP_PASSWORD" ] ; then ## Escaping the '/' in password line for use it in `sed` DM_PGP_PASSWORD="$(echo $DM_PGP_PASSWORD | sed 's/\//\\\//g')" - sed -i "/\[pgp\]/,/\[/ s/^passphrase\s*=.*/passphrase=$DM_PGP_PASSWORD/" $CONF_FILES + sed -i "/\[pgp\]/,/\[/ s/^#*passphrase=.*/passphrase=$DM_PGP_PASSWORD/" $CONF_FILES fi if [ "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true ]; then - sed -i "/\[main\]/,/\[/ s/^testnet\s*=.*/testnet=true/" $CONF_FILES + sed -i "/\[main\]/,/\[/ s/^#*testnet=.*/testnet=true/" $CONF_FILES else - sed -i "/\[main\]/,/\[/ s/^testnet\s*=.*/testnet=false/" $CONF_FILES + sed -i "/\[main\]/,/\[/ s/^#*testnet=.*/testnet=false/" $CONF_FILES fi ## Write PGP key variables to files @@ -120,20 +120,20 @@ init_config() ## Setup testnet settings in libbitcoin-explorer config for new user bitcoin address generation [ "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true ] && \ - sed -i -e "/\[wallet\]/,/\[/ s/wif_version? \s*=.*/wif_version = 239/" \ - -e "/\[wallet\]/,/\[/ s/hd_public_version \s*=.*/hd_public_version = 70617039/" \ - -e "/\[wallet\]/,/\[/ s/hd_secret_version \s*=.*/hd_secret_version = 70615956/" \ - -e "/\[wallet\]/,/\[/ s/pay_to_public_key_hash_version \s*=.*/pay_to_public_key_hash_version = 111/" \ - -e "/\[wallet\]/,/\[/ s/pay_to_script_hash_version \s*=.*/pay_to_script_hash_version = 196/" \ - -e "/\[network\]/,/\[/ s/identifier \s*=.*/identifier = 118034699/" \ - -e "/seed = mainnet[0-9].libbitcoin.net:8333/ s/^/#/" \ - -e "/url = tcp:\/\/mainnet.libbitcoin.net:9091/ s/^/#/" \ - -e "/block_url = tcp:\/\/mainnet.libbitcoin.net:9093/ s/^/#/" \ - -e "/transaction_url = tcp:\/\/mainnet.libbitcoin.net:9094/ s/^/#/" \ - -e "/#seed = testnet[0-9].libbitcoin.net:18333/ s/^#//" \ - -e "/#url = tcp:\/\/testnet.libbitcoin.net:19091/ s/^#//" \ - -e "/#block_url = tcp:\/\/testnet.libbitcoin.net:19093/ s/^#//" \ - -e "/#transaction_url = tcp:\/\/testnet.libbitcoin.net:19094/ s/^#//" "$BX_CONF_FILE" + sed -i -e "/\[wallet\]/,/\[/ s/wif_version? =.*/wif_version = 239/" \ + -e "/\[wallet\]/,/\[/ s/hd_public_version =.*/hd_public_version = 70617039/" \ + -e "/\[wallet\]/,/\[/ s/hd_secret_version =.*/hd_secret_version = 70615956/" \ + -e "/\[wallet\]/,/\[/ s/pay_to_public_key_hash_version =.*/pay_to_public_key_hash_version = 111/" \ + -e "/\[wallet\]/,/\[/ s/pay_to_script_hash_version =.*/pay_to_script_hash_version = 196/" \ + -e "/\[network\]/,/\[/ s/identifier =.*/identifier = 118034699/" \ + -e "/seed = mainnet[0-9].libbitcoin.net:8333/ s/^#*/#/" \ + -e "/url = tcp:\/\/mainnet.libbitcoin.net:9091/ s/^#*/#/" \ + -e "/block_url = tcp:\/\/mainnet.libbitcoin.net:9093/ s/^#*/#/" \ + -e "/transaction_url = tcp:\/\/mainnet.libbitcoin.net:9094/ s/^#*/#/" \ + -e "/#seed = testnet[0-9].libbitcoin.net:18333/ s/^#*#//" \ + -e "/#url = tcp:\/\/testnet.libbitcoin.net:19091/ s/^#*#//" \ + -e "/#block_url = tcp:\/\/testnet.libbitcoin.net:19093/ s/^#*#//" \ + -e "/#transaction_url = tcp:\/\/testnet.libbitcoin.net:19094/ s/^#*#//" "$BX_CONF_FILE" } generate_pgp_key() @@ -182,7 +182,7 @@ EOF generate_btc_key() { ## Create new Bitcoin keys. If user address (_DM_BITCOIN var) is empty. - _DM_BITCOIN="$(sed -n '/^[ \t]*\[module\]/,/\[/s/^[ \t]*address[ \t]*=[ \t]*//p' $CONF_FILES)" + _DM_BITCOIN="$(sed -n '/^[ \t]*\[module\]/,/\[/s/^#*[ \t]*address[ \t]*=[ \t]*//p' $CONF_FILES)" B=$(tput bold ; tput setaf 1) N=$(tput sgr0) @@ -196,7 +196,7 @@ generate_btc_key() PRIVKEYWIF="$(bx ec-to-wif $PRIVKEY)" ## Write the bitcoin address to the daemon config - sed -i "/\[module\]/,/\[/ s/^address\s*=.*/address=$BITCOIN/" $CONF_FILES + sed -i "/\[module\]/,/\[/ s/^#*address=.*/address=$BITCOIN/" $CONF_FILES ## Show bitcoin key tee -a $BITCOIN_KEYS_BACKUP <<-EOF