From ff23c419bcb5e960a6172627413eeb695793938d Mon Sep 17 00:00:00 2001 From: jash Date: Mon, 8 Oct 2018 14:09:40 +0200 Subject: [PATCH] bump :-( --- install/.gitignore | 1 + .../generators/app/prompters/000_proxy.js | 2 +- .../generators/app/prompters/999_installer | 16 +++- .../app/templates/installer/config.sh | 5 + .../templates/installer/docker-compose.yaml | 93 +++++++++++++++++++ .../app/templates/proxy/env.properties | 19 ---- install/script/configure.sh | 20 +--- install/script/cyphernodeconf.sh | 12 --- install/script/docker.sh | 4 +- install/script/install.sh | 12 ++- install/script/install_docker.sh | 34 +++++++ install/script/install_lunanode.sh | 3 + install/script/setup.sh | 30 +++++- setup.sh | 2 +- 14 files changed, 193 insertions(+), 60 deletions(-) create mode 100644 install/.gitignore create mode 100644 install/generator-cyphernode/generators/app/templates/installer/config.sh create mode 100644 install/generator-cyphernode/generators/app/templates/installer/docker-compose.yaml delete mode 100644 install/generator-cyphernode/generators/app/templates/proxy/env.properties delete mode 100644 install/script/cyphernodeconf.sh create mode 100644 install/script/install_docker.sh create mode 100644 install/script/install_lunanode.sh diff --git a/install/.gitignore b/install/.gitignore new file mode 100644 index 0000000..6320cd2 --- /dev/null +++ b/install/.gitignore @@ -0,0 +1 @@ +data \ No newline at end of file diff --git a/install/generator-cyphernode/generators/app/prompters/000_proxy.js b/install/generator-cyphernode/generators/app/prompters/000_proxy.js index a0142a1..70d6954 100644 --- a/install/generator-cyphernode/generators/app/prompters/000_proxy.js +++ b/install/generator-cyphernode/generators/app/prompters/000_proxy.js @@ -42,6 +42,6 @@ module.exports = { }]; }, templates: function( props ) { - return [ 'env.properties' ]; + return []; } }; \ No newline at end of file diff --git a/install/generator-cyphernode/generators/app/prompters/999_installer b/install/generator-cyphernode/generators/app/prompters/999_installer index 5e9f2ed..59bd215 100644 --- a/install/generator-cyphernode/generators/app/prompters/999_installer +++ b/install/generator-cyphernode/generators/app/prompters/999_installer @@ -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']; } }; \ No newline at end of file diff --git a/install/generator-cyphernode/generators/app/templates/installer/config.sh b/install/generator-cyphernode/generators/app/templates/installer/config.sh new file mode 100644 index 0000000..555817f --- /dev/null +++ b/install/generator-cyphernode/generators/app/templates/installer/config.sh @@ -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' %> diff --git a/install/generator-cyphernode/generators/app/templates/installer/docker-compose.yaml b/install/generator-cyphernode/generators/app/templates/installer/docker-compose.yaml new file mode 100644 index 0000000..0f1df01 --- /dev/null +++ b/install/generator-cyphernode/generators/app/templates/installer/docker-compose.yaml @@ -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 diff --git a/install/generator-cyphernode/generators/app/templates/proxy/env.properties b/install/generator-cyphernode/generators/app/templates/proxy/env.properties deleted file mode 100644 index 5ed7afa..0000000 --- a/install/generator-cyphernode/generators/app/templates/proxy/env.properties +++ /dev/null @@ -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' %> diff --git a/install/script/configure.sh b/install/script/configure.sh index 9d335c5..d284a55 100644 --- a/install/script/configure.sh +++ b/install/script/configure.sh @@ -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 } diff --git a/install/script/cyphernodeconf.sh b/install/script/cyphernodeconf.sh deleted file mode 100644 index 036cb11..0000000 --- a/install/script/cyphernodeconf.sh +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/install/script/docker.sh b/install/script/docker.sh index 4d30004..70ff264 100644 --- a/install/script/docker.sh +++ b/install/script/docker.sh @@ -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 } diff --git a/install/script/install.sh b/install/script/install.sh index eac781d..b4a662a 100644 --- a/install/script/install.sh +++ b/install/script/install.sh @@ -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 } \ No newline at end of file diff --git a/install/script/install_docker.sh b/install/script/install_docker.sh new file mode 100644 index 0000000..f13eb4a --- /dev/null +++ b/install/script/install_docker.sh @@ -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 +} \ No newline at end of file diff --git a/install/script/install_lunanode.sh b/install/script/install_lunanode.sh new file mode 100644 index 0000000..b2d708e --- /dev/null +++ b/install/script/install_lunanode.sh @@ -0,0 +1,3 @@ +install_lunanode() { + trace "Lunanode installation not implemented" +} \ No newline at end of file diff --git a/install/script/setup.sh b/install/script/setup.sh index 806a90e..44f0699 100755 --- a/install/script/setup.sh +++ b/install/script/setup.sh @@ -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 \ No newline at end of file +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 diff --git a/setup.sh b/setup.sh index c8831d7..3d88e55 100755 --- a/setup.sh +++ b/setup.sh @@ -1,3 +1,3 @@ #!/bin/sh -(cd install/script && TRACING=1 ./setup.sh) \ No newline at end of file +(cd install/script && TRACING=1 ./setup.sh $@) \ No newline at end of file