This commit is contained in:
jash
2018-10-08 14:09:40 +02:00
committed by kexkey
parent 7479433f4a
commit ff23c419bc
14 changed files with 193 additions and 60 deletions

1
install/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
data

View File

@@ -42,6 +42,6 @@ module.exports = {
}];
},
templates: function( props ) {
return [ 'env.properties' ];
return [];
}
};

View File

@@ -16,15 +16,20 @@ module.exports = {
prompts: function( utils ) {
return [{
type: 'list',
name: 'installer',
default: utils._getDefault( 'installer' ),
name: 'installer_mode',
default: utils._getDefault( 'installer_mode' ),
message: chalk.red('Where do you want to install cyphernode?')+'\n',
choices: [{
name: "Docker",
value: "docker"
},{
},
{
name: "Lunanode (not implemented)",
value: "lunanode"
},
{
name: "No installation. Just create config files",
value: "none"
}]
},
{
@@ -44,6 +49,9 @@ module.exports = {
];
},
templates: function( props ) {
return [];
if( props.installer_mode === 'docker' ) {
return ['config.sh','docker-compose.yaml'];
}
return ['config.sh'];
}
};

View File

@@ -0,0 +1,5 @@
INSTALLER_MODE=<%= installer_mode %>
BITCOIN_INTERNAL=<%= (bitcoin_mode==="internal"?'true':'false') %>
FEATURE_LIGHTNING=<%= (features.indexOf('lightning') != -1)?'true':'false' %>
FEATURE_OPENTIMESTAMPS=<%= (features.indexOf('opentimestamps') != -1)?'true':'false' %>
FEATURE_ELECTRUM=<%= (features.indexOf('electrum') != -1)?'true':'false' %>

View File

@@ -0,0 +1,93 @@
version: "3"
services:
proxy:
# Bitcoin Mini Proxy
env:
"TRACING":"1"
"WATCHER_BTC_NODE_RPC_URL":"bitcoin:<%= (net === 'mainnet')?'8332':'18332' %>/wallet/watching01.dat"
"WATCHER_BTC_NODE_RPC_USER":"<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
"WATCHER_BTC_NODE_RPC_CFG":"/proxyuser/watcher_btcnode_curlcfg.properties"
"SPENDER_BTC_NODE_RPC_URL":"bitcoin:<%= (net === 'mainnet')?'8332':'18332' %>/wallet/spending01.dat"
"SPENDER_BTC_NODE_RPC_USER":"<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
"SPENDER_BTC_NODE_RPC_CFG":"/proxyuser/sender_btcnode_curlcfg.properties"
"PROXY_LISTENING_PORT":"8888"
"DB_PATH":"/proxyuser/db"
"DB_FILE":"/proxyuser/db/proxydb"
"PYCOIN_CONTAINER":"pycoin:7777"
"OTS_CONTAINER":"opentimestamps:6666"
"DERIVATION_PUB32":"<%= xpub %>"
"DERIVATION_PATH":"<%= derivation_path %>"
"WATCHER_BTC_NODE_PRUNED":"<%= bitcoin_prune?'true':'false' %>"
image: cyphernode/proxy
# ports:
# - "8888:8888"
volumes:
# Variable substitutions don't work
# Match with DB_PATH in proxy_docker/env.properties
- "~/btcproxydb:/proxyuser/db"
- "~/.lightning:/proxyuser/.lightning"
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
proxycron:
# Async jobs
env:
"PROXY_URL":"proxy:8888/executecallbacks"
image: cyphernode/proxycron
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
pycoin:
# Pycoin
image: cyphernode/pycoin
env:
"TRACING":"1"
"PYCOIN_LISTENING_PORT":"7777"
# ports:
# - "7777:7777"
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
<% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %>
lightning:
# c-lightning lightning network node
image: cyphernode/clightning
ports:
- "9735:9735"
volumes:
- "~/.lightning:/lnuser/.lightning"
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
<% } else if( features.indexOf('lightning') !== -1 && lightning_implementation === 'lnd' ) { %>
# TODO: add lnd support
<% } %>
<% if( bitcoin_mode === 'internal' ) { %>
bitcoin:
# Bitcoin node
image: cyphernode/bitcoin
# ports:
# - "18333:18333"
# - "18332:18332"
# - "29000:29000"
# - "8333:8333"
# - "8332:8332"
volumes:
- "~/.bitcoin:/bitcoinuser/.bitcoin"
networks:
- cyphernodenet
<% } %>
networks:
cyphernodenet:
external: true

View File

@@ -1,19 +0,0 @@
TRACING=1
WATCHER_BTC_NODE_RPC_URL=btcnode:<%= (net === 'mainnet')?'8332':'18332' %>/wallet/watching01.dat
WATCHER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>
WATCHER_BTC_NODE_RPC_CFG=/proxyuser/watcher_btcnode_curlcfg.properties
SPENDER_BTC_NODE_RPC_URL=btcnode:<%= (net === 'mainnet')?'8332':'18332' %>/wallet/spending01.dat
SPENDER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>
SPENDER_BTC_NODE_RPC_CFG=/proxyuser/sender_btcnode_curlcfg.properties
PROXY_LISTENING_PORT=8888
# Variable substitutions don't work
DB_PATH=/proxyuser/db
DB_FILE=/proxyuser/db/proxydb
# Pycoin container
PYCOIN_CONTAINER=pycoinnode:7777
# OTS container
OTS_CONTAINER=otsnode:6666
DERIVATION_PUB32=<%= xpub %>
DERIVATION_PATH=<%= derivation_path %>
WATCHER_BTC_NODE_PRUNED=<%= bitcoin_prune?'true':'false' %>

View File

@@ -1,25 +1,13 @@
. ./docker.sh
. ./cyphernodeconf.sh
configure() {
trace "Updating SatoshiPortal dockers"
#git submodule update --recursive --remote
#
## build SatoshiPortal images
#local arch=x86_64
#build_docker_image ../SatoshiPortal/dockers/$arch/bitcoin-core btcnode
#build_docker_image ../SatoshiPortal/dockers/$arch/LN/c-lightning clnimg
#
## build cyphernode images
#build_docker_image ../../cron_docker/ proxycronimg
build_docker_image ../../proxy_docker/ btcproxyimg
#build_docker_image ../../pycoin_docker/ pycoinimg
#
local current_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
## build setup docker image
build_docker_image ../ cyphernodeconf && clear && echo "Thinking..."
# configure features of cyphernode
cyphernodeconf_configure
docker run -v $current_path/../data:/data \
--log-driver=none\
--rm -it cyphernodeconf:latest
#docker image rm cyphernodeconf:latest
}

View File

@@ -1,12 +0,0 @@
# this will run configure.sh of the specified package inside a
# cyphernodeconf container. This way we ensure we have the right
# environment and do not pollute the host machine with utility
# commands not needed for runtime
cyphernodeconf_configure() {
local current_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
docker run -v $current_path/../data:/data \
--log-driver=none\
--rm -it cyphernodeconf:latest
}

View File

@@ -1,6 +1,6 @@
build_docker_image() {
trace "building docker image: $1 with tag $2:latest"
docker build $1 -t $2:latest
trace "building docker image: $2:latest"
docker build -q $1 -t $2:latest > /dev/null
}

View File

@@ -1,3 +1,13 @@
. ./install_docker.sh
. ./install_lunanode.sh
install() {
echo "Installation phase not implemented yet"
. ../data/installer/config.sh
if [[ ''$INSTALLER_MODE == 'none' ]]; then
echo "Skipping installation phase"
elif [[ ''$INSTALLER_MODE == 'docker' ]]; then
install_docker
elif [[ ''$INSTALLER_MODE == 'lunanode' ]]; then
install_lunanode
fi
}

View File

@@ -0,0 +1,34 @@
install_docker() {
echo
if [[ $BITCOIN_INTERAL == true || $FEATURE_LIGHTNING == true ]]; then
trace "Updating SatoshiPortal repos"
git submodule update --recursive --remote
fi
# build SatoshiPortal images
local arch=$(uname -m) #x86_64
if [[ $BITCOIN_INTERNAL == true ]]; then
build_docker_image ../SatoshiPortal/dockers/$arch/bitcoin-core cyphernode/bitcoin
fi
if [[ $FEATURE_LIGHTNING == true ]]; then
build_docker_image ../SatoshiPortal/dockers/$arch/LN/c-lightning cyphernode/clightning
fi
if [[ $FEATURE_OPENTIMESTAMPS == true ]]; then
trace "Opentimestamps support not implemented"
fi
# build cyphernode images
trace "Creating cyphernode dockers"
build_docker_image ../../proxy_docker/ cyphernode/proxy
build_docker_image ../../cron_docker/ cyphernode/proxycron
build_docker_image ../../pycoin_docker/ cyphernode/pycoin
trace "Creating cyphernode network"
docker network create cyphernodenet > /dev/null 2>&1
}

View File

@@ -0,0 +1,3 @@
install_lunanode() {
trace "Lunanode installation not implemented"
}

View File

@@ -3,9 +3,31 @@
. ./trace.sh
. ./configure.sh
. ./install.sh
. ./docker.sh
echo "Starting configuration phase"
configure
CONFIGURE=0
INSTALL=0
echo "Starting installation phase"
install
while getopts ":ci" opt; do
case $opt in
c)
CONFIGURE=1
;;
i)
INSTALL=1
;;
\?)
echo "Invalid option: -$OPTARG. Use -c to configure and -i to install" >&2
;;
esac
done
if [[ $CONFIGURE == 1 ]]; then
echo "Starting configuration phase"
configure
fi
if [[ $INSTALL == 1 ]]; then
echo "Starting installation phase"
install
fi

View File

@@ -1,3 +1,3 @@
#!/bin/sh
(cd install/script && TRACING=1 ./setup.sh)
(cd install/script && TRACING=1 ./setup.sh $@)