diff --git a/contrib/backends/Makefile b/contrib/backends/Makefile new file mode 100644 index 00000000..819b0d4a --- /dev/null +++ b/contrib/backends/Makefile @@ -0,0 +1,28 @@ +TARGETS = bitcoin zcash +IMAGE = blockbook-backend-build-deb +NO_CACHE = false + +.PHONY: $(TARGETS) + +all: $(TARGETS) + +$(TARGETS): .docker-image + docker run -t --rm -e PACKAGER="`id -u`:`id -g`" -v $(CURDIR)/$@:/deb/$@ $(IMAGE) $@ + mv $@/*.deb . + +build-image: + rm -f .docker-image + $(MAKE) .docker-image + +.docker-image: + docker build --no-cache=$(NO_CACHE)-t $(IMAGE) docker + @ docker images -q $(IMAGE) > $@ + +clean: clean-packages clean-image + +clean-packages: + rm -f *.deb + +clean-image: + - docker rmi $(IMAGE) + @ rm -f .docker-image diff --git a/contrib/backends/bitcoin/Makefile b/contrib/backends/bitcoin/Makefile new file mode 100644 index 00000000..1061ac82 --- /dev/null +++ b/contrib/backends/bitcoin/Makefile @@ -0,0 +1,13 @@ +BITCOIN_VERSION := 0.16.0 + +all: + wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz + tar -xf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz + mv bitcoin-${BITCOIN_VERSION} bitcoin + rm bitcoin/bin/bitcoin-qt + rm bitcoin/bin/bitcoin-tx + rm bitcoin/bin/test_bitcoin + +clean: + rm -rf bitcoin + rm -f bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz* diff --git a/contrib/backends/bitcoin/btc-testnet.conf b/contrib/backends/bitcoin/btc-testnet.conf new file mode 100644 index 00000000..cb3d8033 --- /dev/null +++ b/contrib/backends/bitcoin/btc-testnet.conf @@ -0,0 +1,12 @@ +daemon=1 +server=1 +testnet=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=18332 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:18334 +zmqpubhashblock=tcp://127.0.0.1:18334 +zmqpubrawblock=tcp://127.0.0.1:18334 +zmqpubrawtx=tcp://127.0.0.1:18334 diff --git a/contrib/backends/bitcoin/btc.conf b/contrib/backends/bitcoin/btc.conf new file mode 100644 index 00000000..faa23bbd --- /dev/null +++ b/contrib/backends/bitcoin/btc.conf @@ -0,0 +1,11 @@ +daemon=1 +server=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=8332 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:8334 +zmqpubhashblock=tcp://127.0.0.1:8334 +zmqpubrawblock=tcp://127.0.0.1:8334 +zmqpubrawtx=tcp://127.0.0.1:8334 diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles b/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles new file mode 100644 index 00000000..186137f2 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.conffiles @@ -0,0 +1 @@ +/data/btc/bitcoin/btc.conf diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.dirs b/contrib/backends/bitcoin/debian/bitcoin-btc.dirs new file mode 100644 index 00000000..4195abd8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.dirs @@ -0,0 +1 @@ +/data/btc/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.install b/contrib/backends/bitcoin/debian/bitcoin-btc.install new file mode 100644 index 00000000..4d959fa5 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.install @@ -0,0 +1 @@ +btc.conf /data/btc/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate b/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate new file mode 100644 index 00000000..9f8bd435 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.logrotate @@ -0,0 +1,10 @@ +/data/btc/bitcoin/debug.log +/data/btc/bitcoin/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.postinst b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst new file mode 100644 index 00000000..e22a02e6 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u bitcoin &> /dev/null + then + useradd --system -M -U bitcoin + fi + + if [ "$(stat -c '%U' /data/btc/bitcoin)" != "bitcoin" ] + then + chown bitcoin:bitcoin /data/btc/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.service b/contrib/backends/bitcoin/debian/bitcoin-btc.service new file mode 100644 index 00000000..a8011f6e --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.service @@ -0,0 +1,44 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit bitcoin-btc.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /data/btc/bitcoin/bitcoin.conf + +[Unit] +Description=Bitcoin daemon (mainnet) +After=network.target + +[Service] +ExecStart=/opt/satoshilabs/bitcoin/bin/bitcoind -datadir=/data/btc/bitcoin -conf=/data/btc/bitcoin/btc.conf -pid=/run/bitcoind/btc.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/btc.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles b/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles new file mode 100644 index 00000000..773374c9 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.conffiles @@ -0,0 +1 @@ +/data/btc-testnet/bitcoin/btc-testnet.conf diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs b/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs new file mode 100644 index 00000000..26b686f8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.dirs @@ -0,0 +1 @@ +/data/btc-testnet/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.install b/contrib/backends/bitcoin/debian/bitcoin-testnet.install new file mode 100644 index 00000000..f86f4a4b --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.install @@ -0,0 +1 @@ +btc-testnet.conf /data/btc-testnet/bitcoin diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate b/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate new file mode 100644 index 00000000..f718ec24 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.logrotate @@ -0,0 +1,10 @@ +/data/btc-testnet/bitcoin/testnet3/debug.log +/data/btc-testnet/bitcoin/testnet3/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst new file mode 100644 index 00000000..ebadd9ae --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u bitcoin &> /dev/null + then + useradd --system -M -U bitcoin + fi + + if [ "$(stat -c '%U' /data/btc-testnet/bitcoin)" != "bitcoin" ] + then + chown bitcoin:bitcoin /data/btc-testnet/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.service b/contrib/backends/bitcoin/debian/bitcoin-testnet.service new file mode 100644 index 00000000..0f4080b2 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.service @@ -0,0 +1,44 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit bitcoin-testnet.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /data/btc-testnet/bitcoin/bitcoin.conf + +[Unit] +Description=Bitcoin daemon (testnet) +After=network.target + +[Service] +ExecStart=/opt/satoshilabs/bitcoin/bin/bitcoind -datadir=/data/btc-testnet/bitcoin -conf=/data/btc-testnet/bitcoin/btc-testnet.conf -pid=/run/bitcoind/testnet.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/testnet.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/bitcoin/debian/bitcoin.install b/contrib/backends/bitcoin/debian/bitcoin.install new file mode 100644 index 00000000..204eafa1 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin.install @@ -0,0 +1 @@ +bitcoin /opt/satoshilabs diff --git a/contrib/backends/bitcoin/debian/bitcoin.links b/contrib/backends/bitcoin/debian/bitcoin.links new file mode 100644 index 00000000..a8af3c05 --- /dev/null +++ b/contrib/backends/bitcoin/debian/bitcoin.links @@ -0,0 +1,2 @@ +/opt/satoshilabs/bitcoin/bin/bitcoind /usr/bin/bitcoind +/opt/satoshilabs/bitcoin/bin/bitcoin-cli /usr/bin/bitcoin-cli diff --git a/contrib/backends/bitcoin/debian/changelog b/contrib/backends/bitcoin/debian/changelog new file mode 100644 index 00000000..cdfa9ad8 --- /dev/null +++ b/contrib/backends/bitcoin/debian/changelog @@ -0,0 +1,5 @@ +bitcoin (0.16.0-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Thu, 05 Apr 2018 08:40:39 +0200 diff --git a/contrib/backends/bitcoin/debian/compat b/contrib/backends/bitcoin/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/contrib/backends/bitcoin/debian/compat @@ -0,0 +1 @@ +9 diff --git a/contrib/backends/bitcoin/debian/control b/contrib/backends/bitcoin/debian/control new file mode 100644 index 00000000..d1f7f143 --- /dev/null +++ b/contrib/backends/bitcoin/debian/control @@ -0,0 +1,21 @@ +Source: bitcoin +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd +Standards-Version: 3.9.5 + +Package: bitcoin +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Satoshilabs packaged bitcoin server (binaries) + +Package: bitcoin-btc +Architecture: all +Depends: bitcoin (= ${binary:Version}), logrotate +Description: Satoshilabs packaged bitcoin server (configuration) + +Package: bitcoin-testnet +Architecture: all +Depends: bitcoin (= ${binary:Version}), logrotate +Description: Satoshilabs packaged bitcoin server (configuration) diff --git a/contrib/backends/bitcoin/debian/rules b/contrib/backends/bitcoin/debian/rules new file mode 100755 index 00000000..e9b6951b --- /dev/null +++ b/contrib/backends/bitcoin/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd diff --git a/contrib/backends/docker/Dockerfile b/contrib/backends/docker/Dockerfile new file mode 100644 index 00000000..75e94805 --- /dev/null +++ b/contrib/backends/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:9 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && \ + apt-get install -y devscripts debhelper wget tar gzip make dh-systemd && \ + apt-get clean + +ADD build.sh /deb/build.sh + +WORKDIR /deb + +ENTRYPOINT ["/deb/build.sh"] diff --git a/contrib/backends/docker/build.sh b/contrib/backends/docker/build.sh new file mode 100755 index 00000000..8402eb7e --- /dev/null +++ b/contrib/backends/docker/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +if [ $# -ne 1 ] +then + echo "Usage: $(basename $0) target" > /dev/stderr + exit 1 +fi + +cd $1 + +mk-build-deps -ir -t "apt-get -qq --no-install-recommends" +dpkg-buildpackage -us -uc +mv ../*.deb . +chown $PACKAGER *.deb diff --git a/contrib/backends/zcash/Makefile b/contrib/backends/zcash/Makefile new file mode 100644 index 00000000..02b06991 --- /dev/null +++ b/contrib/backends/zcash/Makefile @@ -0,0 +1,11 @@ +ZCASH_VERSION := 1.0.15 + +all: + wget https://z.cash/downloads/zcash-${ZCASH_VERSION}-linux64.tar.gz + tar -xf zcash-${ZCASH_VERSION}-linux64.tar.gz + mv zcash-${ZCASH_VERSION} zcash + rm zcash/bin/zcash-tx + +clean: + rm -rf zcash + rm -f zcash-${ZCASH_VERSION}-linux64.tar.gz* diff --git a/contrib/backends/zcash/debian/changelog b/contrib/backends/zcash/debian/changelog new file mode 100644 index 00000000..6f9495d0 --- /dev/null +++ b/contrib/backends/zcash/debian/changelog @@ -0,0 +1,5 @@ +zcash (1.0.15-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Thu, 05 Apr 2018 08:40:39 +0200 diff --git a/contrib/backends/zcash/debian/compat b/contrib/backends/zcash/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/contrib/backends/zcash/debian/compat @@ -0,0 +1 @@ +9 diff --git a/contrib/backends/zcash/debian/control b/contrib/backends/zcash/debian/control new file mode 100644 index 00000000..1352372f --- /dev/null +++ b/contrib/backends/zcash/debian/control @@ -0,0 +1,16 @@ +Source: zcash +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd +Standards-Version: 3.9.5 + +Package: zcash +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Satoshilabs packaged zcash server (binaries) + +Package: zcash-zec +Architecture: all +Depends: zcash (= ${binary:Version}), logrotate +Description: Satoshilabs packaged zcash server (configuration) diff --git a/contrib/backends/zcash/debian/rules b/contrib/backends/zcash/debian/rules new file mode 100755 index 00000000..e9b6951b --- /dev/null +++ b/contrib/backends/zcash/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd diff --git a/contrib/backends/zcash/debian/zcash-zec.conffiles b/contrib/backends/zcash/debian/zcash-zec.conffiles new file mode 100644 index 00000000..e8d03862 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.conffiles @@ -0,0 +1 @@ +/data/zec/zcash/zec.conf diff --git a/contrib/backends/zcash/debian/zcash-zec.dirs b/contrib/backends/zcash/debian/zcash-zec.dirs new file mode 100644 index 00000000..5f8be1f2 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.dirs @@ -0,0 +1 @@ +/data/zec/zcash diff --git a/contrib/backends/zcash/debian/zcash-zec.install b/contrib/backends/zcash/debian/zcash-zec.install new file mode 100644 index 00000000..60fa4360 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.install @@ -0,0 +1 @@ +zec.conf /data/zec/zcash diff --git a/contrib/backends/zcash/debian/zcash-zec.logrotate b/contrib/backends/zcash/debian/zcash-zec.logrotate new file mode 100644 index 00000000..536cdeab --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.logrotate @@ -0,0 +1,10 @@ +/data/zec/zcash/debug.log +/data/zec/zcash/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/zcash/debian/zcash-zec.postinst b/contrib/backends/zcash/debian/zcash-zec.postinst new file mode 100644 index 00000000..144fec21 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.postinst @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +case "$1" in + + configure) + if ! id -u zcash &> /dev/null + then + useradd --system -M -U zcash + fi + + if [ "$(stat -c '%U' /data/zec/zcash)" != "zcash" ] + then + chown zcash:zcash /data/zec/zcash + fi + + HOME=/data/zec/zcash /opt/satoshilabs/zcash/bin/zcash-fetch-params + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/zcash/debian/zcash-zec.service b/contrib/backends/zcash/debian/zcash-zec.service new file mode 100644 index 00000000..6eb81110 --- /dev/null +++ b/contrib/backends/zcash/debian/zcash-zec.service @@ -0,0 +1,44 @@ +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit zcash-zec.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /data/zec/zcash/zcash.conf + +[Unit] +Description=ZCash daemon (mainnet) +After=network.target + +[Service] +ExecStart=/opt/satoshilabs/zcash/bin/zcashd -datadir=/data/zec/zcash -conf=/data/zec/zcash/zec.conf -pid=/run/zcashd/zec.pid +# Creates /run/zcashd owned by zcash +RuntimeDirectory=zcashd +User=zcash +Type=forking +PIDFile=/run/zcashd/zec.pid +Restart=on-failure + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/contrib/backends/zcash/debian/zcash.install b/contrib/backends/zcash/debian/zcash.install new file mode 100644 index 00000000..f1f0f6bc --- /dev/null +++ b/contrib/backends/zcash/debian/zcash.install @@ -0,0 +1 @@ +zcash /opt/satoshilabs diff --git a/contrib/backends/zcash/debian/zcash.links b/contrib/backends/zcash/debian/zcash.links new file mode 100644 index 00000000..9a1efd8d --- /dev/null +++ b/contrib/backends/zcash/debian/zcash.links @@ -0,0 +1,2 @@ +/opt/satoshilabs/zcash/bin/zcashd /usr/bin/zcashd +/opt/satoshilabs/zcash/bin/zcash-cli /usr/bin/zcash-cli diff --git a/contrib/backends/zcash/zec.conf b/contrib/backends/zcash/zec.conf new file mode 100644 index 00000000..7498f754 --- /dev/null +++ b/contrib/backends/zcash/zec.conf @@ -0,0 +1,13 @@ +daemon=1 +server=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=8232 +txindex=1 +mainnet=1 +addnode=mainnet.z.cash +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:8234 +zmqpubhashblock=tcp://127.0.0.1:8234 +zmqpubrawblock=tcp://127.0.0.1:8234 +zmqpubrawtx=tcp://127.0.0.1:8234