From 173a0feb4a3461fd52977dd7887642778d032045 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Fri, 13 Apr 2018 15:23:15 +0200 Subject: [PATCH] added package definition for Bitcoin Cash backend --- contrib/backends/Makefile | 2 +- contrib/backends/bcash/Makefile | 14 ++++++ contrib/backends/bcash/bch-testnet.conf | 13 ++++++ contrib/backends/bcash/bch.conf | 12 +++++ .../backends/bcash/debian/bcash-bch.conffiles | 1 + contrib/backends/bcash/debian/bcash-bch.dirs | 1 + .../backends/bcash/debian/bcash-bch.install | 2 + .../backends/bcash/debian/bcash-bch.logrotate | 10 +++++ .../backends/bcash/debian/bcash-bch.postinst | 20 +++++++++ .../backends/bcash/debian/bcash-bch.service | 44 +++++++++++++++++++ .../bcash/debian/bcash-testnet.conffiles | 1 + .../backends/bcash/debian/bcash-testnet.dirs | 1 + .../bcash/debian/bcash-testnet.install | 2 + .../bcash/debian/bcash-testnet.logrotate | 10 +++++ .../bcash/debian/bcash-testnet.postinst | 20 +++++++++ .../bcash/debian/bcash-testnet.service | 44 +++++++++++++++++++ contrib/backends/bcash/debian/changelog | 5 +++ contrib/backends/bcash/debian/compat | 1 + contrib/backends/bcash/debian/control | 16 +++++++ contrib/backends/bcash/debian/rules | 6 +++ 20 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 contrib/backends/bcash/Makefile create mode 100644 contrib/backends/bcash/bch-testnet.conf create mode 100644 contrib/backends/bcash/bch.conf create mode 100644 contrib/backends/bcash/debian/bcash-bch.conffiles create mode 100644 contrib/backends/bcash/debian/bcash-bch.dirs create mode 100644 contrib/backends/bcash/debian/bcash-bch.install create mode 100644 contrib/backends/bcash/debian/bcash-bch.logrotate create mode 100644 contrib/backends/bcash/debian/bcash-bch.postinst create mode 100644 contrib/backends/bcash/debian/bcash-bch.service create mode 100644 contrib/backends/bcash/debian/bcash-testnet.conffiles create mode 100644 contrib/backends/bcash/debian/bcash-testnet.dirs create mode 100644 contrib/backends/bcash/debian/bcash-testnet.install create mode 100644 contrib/backends/bcash/debian/bcash-testnet.logrotate create mode 100644 contrib/backends/bcash/debian/bcash-testnet.postinst create mode 100644 contrib/backends/bcash/debian/bcash-testnet.service create mode 100644 contrib/backends/bcash/debian/changelog create mode 100644 contrib/backends/bcash/debian/compat create mode 100644 contrib/backends/bcash/debian/control create mode 100755 contrib/backends/bcash/debian/rules diff --git a/contrib/backends/Makefile b/contrib/backends/Makefile index 1d3e964c..8331a7bf 100644 --- a/contrib/backends/Makefile +++ b/contrib/backends/Makefile @@ -1,4 +1,4 @@ -TARGETS = bitcoin zcash +TARGETS = bitcoin zcash bcash IMAGE = blockbook-backend-build-deb NO_CACHE = false diff --git a/contrib/backends/bcash/Makefile b/contrib/backends/bcash/Makefile new file mode 100644 index 00000000..5b958fdc --- /dev/null +++ b/contrib/backends/bcash/Makefile @@ -0,0 +1,14 @@ +BITCOINABC_VERSION := 0.17.0 + +all: + wget https://download.bitcoinabc.org/0.17.0/linux/bitcoin-abc-${BITCOINABC_VERSION}-x86_64-linux-gnu.tar.gz + tar -xf bitcoin-abc-${BITCOINABC_VERSION}-x86_64-linux-gnu.tar.gz + mv bitcoin-abc-${BITCOINABC_VERSION} bitcoin-abc + rm bitcoin-abc/bin/bitcoin-qt + rm bitcoin-abc/bin/bitcoin-tx + rm bitcoin-abc/bin/bitcoin-seeder + rm bitcoin-abc/bin/test_bitcoin + +clean: + rm -rf bitcoin-abc + rm -f bitcoin-abc-${BITCOINABC_VERSION}-x86_64-linux-gnu.tar.gz* diff --git a/contrib/backends/bcash/bch-testnet.conf b/contrib/backends/bcash/bch-testnet.conf new file mode 100644 index 00000000..a524d0d6 --- /dev/null +++ b/contrib/backends/bcash/bch-testnet.conf @@ -0,0 +1,13 @@ +daemon=1 +server=1 +testnet=1 +nolisten=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=18432 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:18434 +zmqpubhashblock=tcp://127.0.0.1:18434 +zmqpubrawblock=tcp://127.0.0.1:18434 +zmqpubrawtx=tcp://127.0.0.1:18434 diff --git a/contrib/backends/bcash/bch.conf b/contrib/backends/bcash/bch.conf new file mode 100644 index 00000000..718a68a8 --- /dev/null +++ b/contrib/backends/bcash/bch.conf @@ -0,0 +1,12 @@ +daemon=1 +server=1 +nolisten=1 +rpcuser=rpc +rpcpassword=rpc +rpcport=8432 +txindex=1 +rpcworkqueue=32 +zmqpubhashtx=tcp://127.0.0.1:8434 +zmqpubhashblock=tcp://127.0.0.1:8434 +zmqpubrawblock=tcp://127.0.0.1:8434 +zmqpubrawtx=tcp://127.0.0.1:8434 diff --git a/contrib/backends/bcash/debian/bcash-bch.conffiles b/contrib/backends/bcash/debian/bcash-bch.conffiles new file mode 100644 index 00000000..e8931283 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.conffiles @@ -0,0 +1 @@ +/opt/bitcoin/bch/bch.conf diff --git a/contrib/backends/bcash/debian/bcash-bch.dirs b/contrib/backends/bcash/debian/bcash-bch.dirs new file mode 100644 index 00000000..ad156456 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.dirs @@ -0,0 +1 @@ +/data/bch/bitcoin diff --git a/contrib/backends/bcash/debian/bcash-bch.install b/contrib/backends/bcash/debian/bcash-bch.install new file mode 100644 index 00000000..c002ed3e --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.install @@ -0,0 +1,2 @@ +bitcoin-abc/* /opt/bitcoin/bch +bch.conf /opt/bitcoin/bch diff --git a/contrib/backends/bcash/debian/bcash-bch.logrotate b/contrib/backends/bcash/debian/bcash-bch.logrotate new file mode 100644 index 00000000..130eb1dc --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.logrotate @@ -0,0 +1,10 @@ +/data/bch/bitcoin/debug.log +/data/bch/bitcoin/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bcash/debian/bcash-bch.postinst b/contrib/backends/bcash/debian/bcash-bch.postinst new file mode 100644 index 00000000..2f0885aa --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.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/bch/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bcash/debian/bcash-bch.service b/contrib/backends/bcash/debian/bcash-bch.service new file mode 100644 index 00000000..298e0d97 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-bch.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 bcash-bch.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /opt/bitcoin/bch/bch.conf + +[Unit] +Description=Bitcoin Cash daemon (mainnet) +After=network.target + +[Service] +ExecStart=/opt/bitcoin/bch/bin/bitcoind -datadir=/data/bch/bitcoin -conf=/opt/bitcoin/bch/bch.conf -pid=/run/bitcoind/bch.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/bch.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/bcash/debian/bcash-testnet.conffiles b/contrib/backends/bcash/debian/bcash-testnet.conffiles new file mode 100644 index 00000000..a1304926 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-testnet.conffiles @@ -0,0 +1 @@ +/opt/bitcoin/bch-testnet/bch-testnet.conf diff --git a/contrib/backends/bcash/debian/bcash-testnet.dirs b/contrib/backends/bcash/debian/bcash-testnet.dirs new file mode 100644 index 00000000..86472a15 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-testnet.dirs @@ -0,0 +1 @@ +/data/bch-testnet/bitcoin diff --git a/contrib/backends/bcash/debian/bcash-testnet.install b/contrib/backends/bcash/debian/bcash-testnet.install new file mode 100644 index 00000000..ce91977a --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-testnet.install @@ -0,0 +1,2 @@ +bitcoin-abc/* /opt/bitcoin/bch-testnet +bch-testnet.conf /opt/bitcoin/bch-testnet diff --git a/contrib/backends/bcash/debian/bcash-testnet.logrotate b/contrib/backends/bcash/debian/bcash-testnet.logrotate new file mode 100644 index 00000000..d009963f --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-testnet.logrotate @@ -0,0 +1,10 @@ +/data/bch-testnet/bitcoin/testnet3/debug.log +/data/bch-testnet/bitcoin/testnet3/db.log +{ + rotate 7 + daily + compress + missingok + notifempty + copytruncate +} diff --git a/contrib/backends/bcash/debian/bcash-testnet.postinst b/contrib/backends/bcash/debian/bcash-testnet.postinst new file mode 100644 index 00000000..33dec1ef --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-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/bch-testnet/bitcoin)" != "bitcoin" ] + then + chown bitcoin:bitcoin /data/bch-testnet/bitcoin + fi + ;; + +esac + +#DEBHELPER# diff --git a/contrib/backends/bcash/debian/bcash-testnet.service b/contrib/backends/bcash/debian/bcash-testnet.service new file mode 100644 index 00000000..56d8fc31 --- /dev/null +++ b/contrib/backends/bcash/debian/bcash-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 bcash-testnet.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /opt/bitcoin/bch-testnet/bch-testnet.conf + +[Unit] +Description=Bitcoin Cash daemon (testnet) +After=network.target + +[Service] +ExecStart=/opt/bitcoin/bch-testnet/bin/bitcoind -datadir=/data/bch-testnet/bitcoin -conf=/opt/bitcoin/bch-testnet/bch-testnet.conf -pid=/run/bitcoind/bch-testnet.pid +# Creates /run/bitcoind owned by bitcoin +RuntimeDirectory=bitcoind +User=bitcoin +Type=forking +PIDFile=/run/bitcoind/bch-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/bcash/debian/changelog b/contrib/backends/bcash/debian/changelog new file mode 100644 index 00000000..464f4c7d --- /dev/null +++ b/contrib/backends/bcash/debian/changelog @@ -0,0 +1,5 @@ +bcash (0.17.0-satoshilabs1) unstable; urgency=medium + + * Initial build + + -- Jakub Matys Fri, 13 Apr 2018 11:31:01 +0200 diff --git a/contrib/backends/bcash/debian/compat b/contrib/backends/bcash/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/contrib/backends/bcash/debian/compat @@ -0,0 +1 @@ +9 diff --git a/contrib/backends/bcash/debian/control b/contrib/backends/bcash/debian/control new file mode 100644 index 00000000..e7223d94 --- /dev/null +++ b/contrib/backends/bcash/debian/control @@ -0,0 +1,16 @@ +Source: bcash +Section: satoshilabs +Priority: optional +Maintainer: jakub.matys@satoshilabs.com +Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec +Standards-Version: 3.9.5 + +Package: bcash-bch +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate +Description: Satoshilabs packaged bitcoin-cash server + +Package: bcash-testnet +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate +Description: Satoshilabs packaged bitcoin-cash server diff --git a/contrib/backends/bcash/debian/rules b/contrib/backends/bcash/debian/rules new file mode 100755 index 00000000..e9b6951b --- /dev/null +++ b/contrib/backends/bcash/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +%: + dh $@ --with=systemd