Dockerfile

This commit is contained in:
2022-05-24 20:06:29 +05:30
parent a41422528f
commit 885ae699e8
4 changed files with 152 additions and 85 deletions

View File

@@ -16,7 +16,7 @@ EXPOSE 4999 80
## Debian update; install dependencies for GPG
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update ; \
RUN apt-get update -y ; \
apt-get upgrade -y ; \
apt-get -y install --no-install-recommends gpg gpg-agent ; \
apt-get clean ; \
@@ -31,7 +31,7 @@ FROM updated-debian AS development
## Debian update; install dependencies for: C++ compiler; OpenPGP; Libbitcoin
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get -y update
RUN apt-get -y install --no-install-recommends build-essential libssl-dev libcurl4-openssl-dev make cmake gcc g++ git
RUN apt-get -y install --no-install-recommends libgmp-dev libbz2-dev libzip-dev
RUN apt-get -y install --no-install-recommends autoconf automake libtool pkg-config wget
@@ -67,7 +67,7 @@ RUN su -l --shell /bin/bash $UNAME -c 'wget https://raw.githubusercontent.com/li
sed -i '/wget / s/wget.*$/while true; do & \&\& break; done/' install.sh ; \
./install.sh --build-boost --build-zmq --disable-shared
## Install BitDeals dm
## Install BitDeals module (apostol-dm)
RUN su -l --shell /bin/bash $UNAME -c 'cd '$UHOME' ; \
git clone https://bitbucket.org/bitdeals/apostol-dm.git ; \
cd apostol-dm ; \
@@ -79,6 +79,8 @@ RUN su -l --shell /bin/bash $UNAME -c 'cd '$UHOME' ; \
FROM updated-debian
ARG UNAME
COPY --from=development /usr/local/ /usr/local/
COPY --from=development /etc/dm/ /etc/dm/
COPY --from=development /usr/sbin/dm /usr/sbin/dm
@@ -87,10 +89,15 @@ COPY --from=development /etc/init.d/dm /etc/init.d/dm
#dm: error while loading shared libraries: libOpenPGP.so: cannot open shared object file: No such file or directory
RUN ldconfig
## Copy BitDeals PGP key
#ADD --chown=$UNAME:$UNAME https://www.example.com/bitdeals.asc /etc/dm/bitdeals.asc
COPY --chown=$UNAME:$UNAME ./bitdeals.asc /etc/dm/bitdeals.asc
COPY --chown=$UNAME:$UNAME ./bitdeals-test.asc /etc/dm/bitdeals-test.asc
## Copy configuration helper script
#ADD https://bitbucket.org/bitdeals/apostol-dm/raw/master/docker/entrypoint.sh /entrypoint.sh
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 755 /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

View File

@@ -1,14 +1,14 @@
# Intro
Deal Module (dm) - the BitDeals daemon that provides a special interfaces for creating and modifying user accounts and deals.
Deal Module (dm) - the Bitdeals daemon that provides a special interfaces for creating and modifying user accounts and deals.
# Running DM docker container
On first run the initialization script will create and save a new bitcoin and PGP keys and start the daemon.
On first run the initialization script will create, if empty, a new bitcoin and PGP keys and start the daemon.
`docker run -i -t --rm --mount src=bitdeals-conf,dest=/etc/dm -p 127.0.0.1:4977:4977 -p 127.0.0.1:80:80 bitdeals/dm`
`docker run -i -t --rm --mount src=bitdeals-conf,dest=/etc/dm -p 127.0.0.1:4999:4999 -p 127.0.0.1:80:80 bitdeals/apostol-dm`
Daemon settings which may specified by an environment variables are saved to the daemon config file on the Docker Volume.
Daemon settings which may specified by an environment variables are saved to the daemon config files on the Docker Volume.
To use the BitDeals API you should register an user account on a BitDeals site and get a "client_id", "client_secret" at the account dashboard.
@@ -16,49 +16,47 @@ To use the BitDeals API you should register an user account on a BitDeals site a
Here are some example snippets to help you get started creating a container.
## docker-compose [(recommended, click here for more info)](https://docs.linuxserver.io/general/docker-compose)
## docker-compose
```yaml
version: "3"
services:
bitdeals-module:
image: bitdeals/apostol-dm
container_name: bitdeals-dm
environment:
- TESTNET=1 #optional
- BITCOIN=<address> #optional
- FEE=<0.1%> #optional
- PGP_PUB=<key> #optional
- PGP_SEC=<key> #optional
- PASSWORD=<password> #optional
- ACCOUNT_URL=<http[s]://example.com> #optional
- CLIENT_ID=<id> #optional
- CLIENT_SECRET=<id> #optional
- DM_TESTNET=0
- DM_BITCOIN=<address>
- DM_FEE=<0.1%>
- DM_CLIENT_ID=<id>
- DM_CLIENT_SECRET=<id>
- DM_PGP_PASSWORD=<password>
- |
DM_PGP_SEC=
-----BEGIN PGP PRIVATE KEY BLOCK-----
<key>
-----END PGP PRIVATE KEY BLOCK-----
volumes:
- bitdeals-conf:/etc/dm
ports:
- 4977:4977
- 4999:4999
- 80:80
restart: unless-stopped
```
## docker cli [(click here for more info)](https://docs.docker.com/engine/reference/commandline/cli/)
## docker cli
```sh
docker run -d \
--name=bitdeals-dm \
-e TESTNET=1 `#optional` \
-e BITCOIN=<address> `#optional` \
-e FEE=<0.1%> `#optional` \
-e PGP_PUB=$(gpg2 --armor --export Account_URL) `#optional` \
-e PGP_SEC=$(gpg2 --armor --export-secret-key Account_URL) `#optional` \
-e PASSWORD=<pgp key password> `#optional` \
-e ACCOUNT_URL=<http[s]://example.com> `#optional` \
-e CLIENT_ID=<user-id> `#optional` \
-e CLIENT_SECRET=<secret> `#optional` \
-p 127.0.0.1:4977:4977 \
-e DM_TESTNET=0 \
-e DM_BITCOIN=<address> \
-e DM_FEE=0.1% \
-e DM_PGP_SEC="$(gpg2 --armor --export-secret-key Account_URL)" \
-e DM_PGP_PASSWORD=<pgp key password> \
-e DM_CLIENT_ID=<user-id> \
-e DM_CLIENT_SECRET=<secret> \
-p 127.0.0.1:4999:4999 \
-p 127.0.0.1:80:80 \
-v bitdeals-conf:/etc/dm \
-v ./bitdeals-conf/:/etc/dm \
bitdeals/apostol-dm
```
@@ -69,14 +67,12 @@ Container images are configured using parameters passed at runtime.
|Parameter|Function|
|:--------|:-------|
|-p 80|WebUI port TCP|
|-p 4977|Module API port TCP [(API documentation)](https://bitbucket.org/bitdeals/apostol-dm)|
|-e ACCOUNT_URL=|User site address to provide a deal service. On first run the initialization script will create and save a new PGP keys with this Account_URL in key details.|
|-e TESTNET=|Enable bitcoin testnet mode.|
|-e BITCOIN=|User account bitcoin address.|
|-e FEE=|User fee for created deals.|
|-e PGP_PUB=|Variable with ASCII armored PGP public key.|
|-e PGP_SEC=|Variable with ASCII armored PGP secret key.|
|-e PASSWORD=|User PGP key password.|
|-e CLIENT_ID=|API access credentials (get it on a BitDeals site at User dashboard).|
|-e CLIENT_SECRET=|API access credentials (get it on a BitDeals site at User dashboard).|
|-p 4999|Module API port TCP [(API documentation)](https://bitbucket.org/bitdeals/apostol-dm)|
|-e DM_TESTNET=|Enable bitcoin testnet mode. Default: `0`|
|-e DM_BITCOIN=|User account bitcoin address. If empty, the initialization script will create and save a new bitcoin key.|
|-e DM_FEE=|User fee for created deals. You MUST indicate the sign “%” for a percentage of the deal amount or FIXED value in satoshi. Default: `0.1%`|
|-e DM_PGP_SEC=|Variable with ASCII armored PGP user secret key. If empty, the initialization script will create and save a new PGP key with Account_URL in the key details.|
|-e DM_PGP_PASSWORD=|User PGP key password.|
|-e DM_CLIENT_ID=|BitDeals API access credentials (get it on a BitDeals site at User dashboard).|
|-e DM_CLIENT_SECRET=|BitDeals API access credentials (get it on a BitDeals site at User dashboard).|

41
docker/bitdeals-test.asc Normal file
View File

@@ -0,0 +1,41 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mI0EXgvhAAEEAMfgNWd+bs3F02ktGv8aDN0ORvoaSQ/0stGek3HrLQvAQpl+wKsX
IN2UmM2S/SvHGVToq9VQi383Fs9HSR8qK1D6DgYOPM95LmTVk7wkzfWIIJk6L50/
smRCZzGA97fNMClqC39zAMQYo29mDmt5o9WDDpaoekDw49mwq/p6v3nPABEBAAG0
DUJpdERlYWxzLXRlc3SIzgQTAQoAOBYhBCZm9kMAZKZSw6u+89rDPk0/qkSTBQJe
C+EAAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJENrDPk0/qkST2dED/juh
fexKCN7LMAYsYA0dnuNyZYkM51Bl2/F4ZqjjdLDzxkdD/x9hJ+tfLKKjkF+zhV/a
80R17OCmOPbWrgg9kh9JgHlWc3ETZrK3rAB4NWOarbY1wabYrrlBjVAqXXbDDcW2
uXHZb49s+v3XiLIk3fnX4ICJ2T8rHQ1FoVhR5DqbtEJCTS0yY1g4eTl1OXlFaTNm
ZHFRZm5keDlGNk5kUjVIdjc5YWRkIChodHRwOi8vOTUuMjE3LjI1MS4xNTM6NDk3
NymIzgQTAQgAOBYhBCZm9kMAZKZSw6u+89rDPk0/qkSTBQJeC+EAAhsDBQsJCAcC
BhUKCQgLAgQWAgMBAh4BAheAAAoJENrDPk0/qkSTrO0D/2mOzNZ2RixpEIWeo5C/
H/L8RCoa5Q+RGdCQjOn2J2fa/8g6TKso4Up+242e/TDKyAZ2syr0tPPbyfyngc3L
5oBvJXcWpIS3DoBp/yUNcgUwnwZvqhCXw/BNRziFxRNneN+03hBLn2m73DrwAYnQ
G6Id9ShxbZL8Qqu9bi6QVodAtFFCaXRjb2luX2tleTEgKDAyNDUyZGRhZmNkYjkz
NzkzYmI1MGE3OTdjNWQ1OGVkZjkwNzRhOWIxYTk4ZDU5NTFmYjZkYTg3MTk3ZDhk
N2MyNCmIzgQTAQgAOBYhBCZm9kMAZKZSw6u+89rDPk0/qkSTBQJeC+EAAhsDBQsJ
CAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJENrDPk0/qkSTojcD/icHG3SRdNU3/ZK+
vPBy57UByskXhji6Vzx5njMFYkplzz40zjKnOme3Bp6WM+1ZyA2iu8r1SQp6IahF
cbZ385k0+LC5Jt31Ct2U90QwctaEgQojK6eQrFS2FFtckSjovZEc3aiF+S/hwd8S
ho+++E6f3F7Reh1pxY/fhTdz593rtFFCaXRjb2luX2tleTIgKDAyZDdmN2VhNWJl
ZGZjMjI5ZDc4OWVjZDVhYWI3NjZmY2I5ZWU2OTk3YWJlZmUxMzRlNzQyYmMzOWM3
ZDJhMjBmNimIzgQTAQgAOBYhBCZm9kMAZKZSw6u+89rDPk0/qkSTBQJeC+EAAhsD
BQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJENrDPk0/qkSTYD4EAItzyW7ECTGq
SEQbwkvQtKjeGsXoG0vBcTOYKiFSRlVU6AHBziLje60bkmfcEiOou/E1SYJpXMRR
0fKF233H+37luIwVNnqn4kJpgUBsNw2jg1ilxMbjgjhrdG3K9UgqIBkSxlfxx7j5
uehnZtqLXZWRYhcBGw9O5P5zYpNdSr4PuI0EXgvhAAEEAJ2+Gbs8bREv7RjlPnxv
cLIH/Fz0vCR/bhFP75DTqVfas4Skyl8SthoQM27KUbY9pfzVlW+vjrgDlagf851v
h2hHjEfuW2+KbnAWEBYSxrm4YRUlx3r6zDucv8eK9nnSzXv1wjjeaKzDxV+Mv7DU
q7sKEwqAH9fvy5YMKEy9JJ3BABEBAAGJAWsEGAEIACAWIQQmZvZDAGSmUsOrvvPa
wz5NP6pEkwUCXgvhAAIbAgC/CRDawz5NP6pEk7QgBBkBCAAdFiEEdgm8GHZwtu+6
5M317IjR20JBizcFAl4L4QAACgkQ7IjR20JBizegqwQAhgcJ+VaU44tl78F9sUu0
tirbN/cM0mYUeJ6FzraJTvLDWp5GsVBkWvBcQnv23PIyABFsvPoaYIkPMGMT3jN4
Tjaldn6KvaIlr9i6mtV7kQUCogVrQaQ05FSewGIjipDkpP/ziww8Plbl1lkDGXJi
0yd2sMMOhSji/zQ7Q53LGHK3jAP/Rat/kNT3RvmKiIrKsZqE5zGHtoyHpKNYNzti
sluC+Izs7BwRbOin633XzRFFENcj9zsEWn3NjF2Pm5UxgCJgH0034LmKDCXvg1mF
vdgrGH32BAHHdwwtFTLh6B1jnmWeJmT2akya5LKnI3f1g8xMvlb8EIMcLKkqNNF4
JpqcNKY=
=WxTf
-----END PGP PUBLIC KEY BLOCK-----

View File

@@ -6,43 +6,67 @@
## And can generate a Bitcoing and PGP key filies at first start.
##
## Uncomment this to receive the key from keyserver
#BITDEALS_KEY_FPR="7CAB360151502F5A1E14E22BF263C9207A1CC3B3"
DM_TESTNET=${DM_TESTNET:-0}
## Daemon config files
DM_CONF_FILES=$(find /etc/dm/ -name "*.conf")
CONF_FILES=$(find /etc/dm/ -type f -name "*.conf" -not -name "default.conf")
OAUTH_CONF_FILE="/etc/dm/oauth2/default.json"
PGP_PUB_FILE="/etc/dm/pgp.pub"
BITDEALS_ASC_FILE="/etc/dm/bitdeals.asc"
BITDEALS_TEST_ASC_FILE="/etc/dm/bitdeals-test.asc"
PGP_SEC_FILE="/etc/dm/pgp.sec"
BX_CONF_FILE="/usr/local/etc/libbitcoin/bx.cfg"
#tput variable for color output
export TERM=xterm
## Write a variables to config file
sed -i "/\[main\]/,/\[/ s/.*user=.*/user=module/" $DM_CONF_FILES
sed -i "/\[main\]/,/\[/ s/.*group=.*/group=module/" $DM_CONF_FILES
sed -i "/\[daemon\]/,/\[/ s/.*daemon=.*/daemon=false/" $DM_CONF_FILES
sed -i "/\[server\]/,/\[/ s/.*listen=.*/listen=0.0.0.0/" $DM_CONF_FILES
sed -i "/\[main\]/,/\[/ s/.*user=.*/user=module/" $CONF_FILES
sed -i "/\[main\]/,/\[/ s/.*group=.*/group=module/" $CONF_FILES
sed -i "/\[daemon\]/,/\[/ s/.*daemon=.*/daemon=false/" $CONF_FILES
sed -i "/\[server\]/,/\[/ s/.*listen=.*/listen=0.0.0.0/" $CONF_FILES
sed -i "/\[server\]/,/\[/ s/.*port=.*/port=4999/" $CONF_FILES
## Write the PGP keys locations to the config
sed -i "/\[pgp\]/,/\[/ s%^private=.*%private=$PGP_SEC_FILE%" $DM_CONF_FILES
sed -i "/\[pgp\]/,/\[/ s%^public=.*%public=$PGP_PUB_FILE%" $DM_CONF_FILES
sed -i "/\[pgp\]/,/\[/ s%^private=.*%private=$PGP_SEC_FILE%" $CONF_FILES
test "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true \
&& sed -i "/\[pgp\]/,/\[/ s%^public=.*%public=$BITDEALS_TEST_ASC_FILE%" $CONF_FILES \
|| sed -i "/\[pgp\]/,/\[/ s%^public=.*%public=$BITDEALS_ASC_FILE%" $CONF_FILES
## Write a user variables to the daemon config files.
## This code removes '/' from user variables to sanitize `sed` code injections.
test -z "$BITCOIN" || sed -i "/\[module\]/,/\[/ s/^address=.*/address=${BITCOIN//\/}/" $DM_CONF_FILES
test -z "$FEE" || sed -i "/\[module\]/,/\[/ s/^fee=.*/fee=${FEE//\/}/" $DM_CONF_FILES
test -z "$PASSWORD" || sed -i "/\[pgp\]/,/\[/ s/^passphrase=.*/passphrase=${PASSWORD//\/}/" $DM_CONF_FILES
test -z "$CLIENT_ID" || sed -i "/\"web\": {/,/}/ s/\"client_id\".*/\"client_id\": \"${CLIENT_ID//\/}\",/" "$OAUTH_CONF_FILE"
test -z "$CLIENT_SECRET" || sed -i "/\"web\": {/,/}/ s/\"client_secret\".*/\"client_secret\": \"${CLIENT_SECRET//\/}\",/" "$OAUTH_CONF_FILE"
test -z "$PGP_PUB" || echo "$PGP_PUB" > "$PGP_PUB_FILE"
test -z "$PGP_SEC" || echo "$PGP_SEC" > "$PGP_SEC_FILE"
test "$TESTNET" = 1 -o "$TESTNET" = true && sed -i "/\[main\]/,/\[/ s/.*testnet=.*/testnet=true/" $DM_CONF_FILES
test -z "$DM_BITCOIN" || sed -i "/\[module\]/,/\[/ s/^address=.*/address=${DM_BITCOIN//\/}/" $CONF_FILES
test -z "$DM_FEE" || sed -i "/\[module\]/,/\[/ s/^#\?fee=.*/fee=${DM_FEE//\/}/" $CONF_FILES
test -z "$DM_PGP_PASSWORD" || sed -i "/\[pgp\]/,/\[/ s/^passphrase=.*/passphrase=${DM_PASSWORD//\/}/" $CONF_FILES
test -z "$DM_CLIENT_ID" || sed -i "/\"web\": {/,/}/ s/\"client_id\".*/\"client_id\": \"${DM_CLIENT_ID//\/}\",/" "$OAUTH_CONF_FILE"
test -z "$DM_CLIENT_SECRET" || sed -i "/\"web\": {/,/}/ s/\"client_secret\".*/\"client_secret\": \"${DM_CLIENT_SECRET//\/}\",/" "$OAUTH_CONF_FILE"
test "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true && sed -i "/\[main\]/,/\[/ s/.*testnet=.*/testnet=true/" $CONF_FILES
test -z "$BITDEALS_ASC" || echo "$BITDEALS_ASC" > "$BITDEALS_ASC_FILE"
test -z "$BITDEALS_TEST_ASC" || echo "$BITDEALS_TEST_ASC" > "$BITDEALS_TEST_ASC_FILE"
test -z "$DM_PGP_SEC" || echo "$PGP_SEC" > "$PGP_SEC_FILE"
## Get BitDeals PGP key by fingerprint
if ! [ -z $BITDEALS_KEY_FPR ]
then
test "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true && i="$BITDEALS_TEST_ASC_FILE" || i="$BITDEALS_ASC_FILE"
gpg --keyserver keyserver.ubuntu.com --recv-keys "$BITDEALS_KEY_FPR" && \
gpg --armor --export "$BITDEALS_KEY_FPR" | tee "$i"
gpgconf --kill all
fi
## Create new PGP keys. If PGP file is empty.
if [ ! -e "$PGP_SEC_FILE" ]
then
echo -e "\nThe PGP key is empty. Generating new PGP key...\n"
test -z "$ACCOUNT_URL" && { echo -n "Please enter your site URL like https://example.com : " ; read ACCOUNT_URL ;}
test -z "$DM_ACCOUNT_URL" && { echo -n "Please enter your site URL like https://example.com : " ; read DM_ACCOUNT_URL ;}
#GNUPGHOME="$(mktemp -d)" ;#- works for gpg2
gpg --faked-system-time $(TZ=UTC date --date=$(date +'%Y-%m-%d') +%s) \
--pinentry-mode loopback --passphrase "$PASSWORD" \
--pinentry-mode loopback --passphrase "$DM_PGP_PASSWORD" \
--batch --gen-key 2>/dev/null <<-EOF
Key-Type: RSA
Key-Usage: cert,sign
@@ -51,34 +75,30 @@ then
Subkey-Usage: encr
Subkey-Length: 1024
Name-Real: Account_URL
Name-Comment: ${ACCOUNT_URL:-https://example-$RANDOM.com}
Name-Comment: ${DM_ACCOUNT_URL:-https://example-$RANDOM.com}
Expire-Date: 0
EOF
echo
tput setaf 7
#tput setaf 7
#cat $GNUPGHOME/openpgp-revocs.d/*.rev
cat /root/.gnupg/openpgp-revocs.d/*.rev | sed -e "/^pub/,+2 { s/.*/$(tput sgr0)$(tput bold)&$(tput sgr0)$(tput setaf 7)/; }"
tput setaf 3
gpg --armor --export --passphrase "$PASSWORD" | tee "$PGP_PUB_FILE"
tput setaf 4
gpg --armor --export-secret-keys --passphrase "$PASSWORD" | tee "$PGP_SEC_FILE"
#cat /root/.gnupg/openpgp-revocs.d/*.rev | sed -e "/^pub/,+2 { s/.*/$(tput sgr0)$(tput bold)&$(tput sgr0)$(tput setaf 7)/; }"
#gpg -k --keyid-format long | grep -A4 -E "^pub"
gpg -k --keyid-format long 2>/dev/null | tail -n5
tput setaf 2
gpg --armor --export-secret-keys --passphrase "$DM_PGP_PASSWORD" | tee "$PGP_SEC_FILE"
tput sgr0
pkill gpg-agent 2>/dev/null
gpgconf --kill all
else
echo -e "\nNOTE:Your PGP keyfiles location: $(dirname $PGP_PUB_FILE)"
echo -e "NOTE:Your PGP key location: $PGP_SEC_FILE"
fi
## Change PGP keyfiles owner
test -e "$PGP_PUB_FILE" && chown module:module "$PGP_PUB_FILE"
test -e "$BITDEALS_ASC_FILE" && chown module:module "$BITDEALS_ASC_FILE"
test -e "$PGP_SEC_FILE" && chown module:module "$PGP_SEC_FILE"
test -e "$PGP_SEC_FILE" && chmod 600 "$PGP_SEC_FILE"
## Get bitcoin address from the daemon config
DM_BITCOIN="$(sed -n '/^[ \t]*\[module\]/,/\[/s/^[ \t]*address[ \t]*=[ \t]*//p' $DM_CONF_FILE)"
## Setup testnet settings in libbitcoin-explorer config
test "$TESTNET" = 1 -o "$TESTNET" = true && \
test "$DM_TESTNET" = 1 -o "$DM_TESTNET" = true && \
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/" \
@@ -94,12 +114,15 @@ test "$TESTNET" = 1 -o "$TESTNET" = true && \
-e "/#block_url = tcp:\/\/testnet.libbitcoin.net:19093/ s/^#//" \
-e "/#transaction_url = tcp:\/\/testnet.libbitcoin.net:19094/ s/^#//" "$BX_CONF_FILE"
## Get bitcoin address from the daemon config
DM_BITCOIN_="$(sed -n '/^[ \t]*\[module\]/,/\[/s/^[ \t]*address[ \t]*=[ \t]*//p' $CONF_FILES)"
## Create new Bitcoin keys. If address is empty.
if [ -z "$DM_BITCOIN" ]
if [ -z "$DM_BITCOIN_" ]
then
echo -e "\nThe Bitcoin key is empty. Generating new Bitcoin key...\n"
B=$(tput bold)
B=$(tput bold ; tput setaf 1)
N=$(tput sgr0)
## Generate bitcoin keys
@@ -109,7 +132,7 @@ then
PRIVKEYWIF="$(bx ec-to-wif $PRIVKEY)"
## Write the bitcoin address to the daemon config
sed -i "/\[module\]/,/\[/ s/^address=.*/address=$BITCOIN/" $DM_CONF_FILES
sed -i "/\[module\]/,/\[/ s/^address=.*/address=$BITCOIN/" $CONF_FILES
## Show bitcoin keys
echo -e "Please backup these\t${B}BITCOIN KEYS:${N}"
@@ -120,11 +143,11 @@ then
fi
## Password notice
echo "$PASSWORD" | grep -q "/" && \
( echo -n -e "\n$(tput bold)WARN:$(tput sgr0)Please, write your 'passphrase=$PASSWORD'" | grep --color=auto -z -E "/" ; echo -n -e " to $DM_CONF_FILE manually." )
echo "$DM_PGP_PASSWORD" | grep -q "/" && \
( echo -n -e "\n$(tput bold)WARN:$(tput sgr0)Please, write your 'passphrase=$DM_PGP_PASSWORD'" | grep --color=auto -z -E "/" ; echo -n -e " to $DM_CONF_FILE manually." )
## API credentials notice
test -z "$CLIENT_ID" -o -z "$CLIENT_SECRET" && \
echo -e "NOTE:Please visit a BitDeals site to get your API credentials: $(tput smul)\$CLIENT_ID$(tput rmul) and $(tput smul)\$CLIENT_SECRET$(tput rmul).\n"
echo -e "\nNOTE:Please visit a BitDeals site to get your API credentials: $(tput smul)\$CLIENT_ID$(tput rmul) and $(tput smul)\$CLIENT_SECRET$(tput rmul).\n"
## Run the daemon
exec /usr/sbin/dm -p /etc/dm -c /etc/dm/dm.conf $@