mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 09:52:14 +01:00
1637 lines
62 KiB
Bash
Executable File
1637 lines
62 KiB
Bash
Executable File
#!/usr/bin/env zsh
|
|
set -e
|
|
echo -n "Initializing..."
|
|
|
|
case `uname -s` in
|
|
|
|
FreeBSD)
|
|
OS=FreeBSD
|
|
NPROC=$(sysctl hw.ncpu | awk '{print $2}')
|
|
;;
|
|
|
|
Linux)
|
|
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
|
|
OS=Debian
|
|
NPROC=$(nproc --all)
|
|
else
|
|
echo "Your distribution of Linux is not yet supported by this installation script"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo "Unsupported OS"
|
|
exit 1
|
|
;;
|
|
|
|
esac
|
|
|
|
########################################
|
|
##### mempool installation options #####
|
|
########################################
|
|
|
|
# tor onion and clearnet hostname
|
|
TOR_INSTALL=ON
|
|
CERTBOT_INSTALL=ON
|
|
|
|
# install 3 network daemons
|
|
BITCOIN_INSTALL=ON
|
|
BISQ_INSTALL=ON
|
|
ELEMENTS_INSTALL=ON
|
|
|
|
# configure 4 network instances
|
|
BITCOIN_MAINNET_ENABLE=ON
|
|
BITCOIN_MAINNET_MINFEE_ENABLE=ON
|
|
BITCOIN_TESTNET_ENABLE=ON
|
|
BITCOIN_SIGNET_ENABLE=ON
|
|
BISQ_MAINNET_ENABLE=ON
|
|
ELEMENTS_LIQUID_ENABLE=ON
|
|
ELEMENTS_LIQUIDTESTNET_ENABLE=ON
|
|
|
|
# enable lightmode and disable compaction to fit on 1TB SSD drive
|
|
BITCOIN_ELECTRS_LIGHT_MODE=ON
|
|
BITCOIN_ELECTRS_COMPACTION=OFF
|
|
ELEMENTS_ELECTRS_LIGHT_MODE=ON
|
|
ELEMENTS_ELECTRS_COMPACTION=OFF
|
|
|
|
# automaitcally configure firewall
|
|
FIREWALL_CONFIGURE=ON
|
|
|
|
############
|
|
# probe OS #
|
|
############
|
|
|
|
HOSTNAME=$(hostname)
|
|
|
|
# get newest zpool if using zfs
|
|
ZPOOL=""
|
|
[ "${OS}" = FreeBSD ] && ZPOOL=$(zpool list -H|head -1|cut -f 1)
|
|
|
|
MD5=md5sum
|
|
[ "${OS}" = FreeBSD ] && MD5=md5
|
|
|
|
##################################################
|
|
##### P2P / RPC / HTTP network communication #####
|
|
##################################################
|
|
|
|
# used for bisq and firewall configuration
|
|
BITCOIN_MAINNET_P2P_HOST=127.0.0.1
|
|
BITCOIN_MAINNET_P2P_PORT=8333
|
|
# used for RPC communication
|
|
BITCOIN_MAINNET_RPC_HOST=127.0.0.1
|
|
BITCOIN_MAINNET_RPC_PORT=8332
|
|
# generate random hex string
|
|
BITCOIN_RPC_USER=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
BITCOIN_RPC_PASS=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
|
|
# used for firewall configuration
|
|
BITCOIN_TESTNET_P2P_HOST=127.0.0.1
|
|
BITCOIN_TESTNET_P2P_PORT=18333
|
|
# used for RPC communication
|
|
BITCOIN_TESTNET_RPC_HOST=127.0.0.1
|
|
BITCOIN_TESTNET_RPC_PORT=18332
|
|
|
|
# used for firewall configuration
|
|
BITCOIN_SIGNET_P2P_HOST=127.0.0.1
|
|
BITCOIN_SIGNET_P2P_PORT=18333
|
|
# used for RPC communication
|
|
BITCOIN_SIGNET_RPC_HOST=127.0.0.1
|
|
BITCOIN_SIGNET_RPC_PORT=18332
|
|
# generate random hex string
|
|
BITCOIN_SIGNET_RPC_USER=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
BITCOIN_SIGNET_RPC_PASS=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
|
|
# used by bisq to receive notifications from bitcoin about new blocks
|
|
BISQ_BLOCKNOTIFY_HOST=127.0.0.1
|
|
BISQ_BLOCKNOTIFY_PORT=5120
|
|
|
|
# used for firewall configuration
|
|
ELEMENTS_LIQUID_P2P_HOST=127.0.0.1
|
|
ELEMENTS_LIQUID_P2P_PORT=7042
|
|
# used for RPC communication
|
|
ELEMENTS_LIQUID_RPC_HOST=127.0.0.1
|
|
ELEMENTS_LIQUID_RPC_PORT=7041
|
|
# generate random hex string
|
|
ELEMENTS_RPC_USER=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
ELEMENTS_RPC_PASS=$(head -150 /dev/urandom | ${MD5} | awk '{print $1}')
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#ELECTRS_MAINNET_HTTP_SOCK=/tmp/bitcoin.mainnet.electrs
|
|
ELECTRS_MAINNET_HTTP_HOST=127.0.0.1
|
|
ELECTRS_MAINNET_HTTP_PORT=3000
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#ELECTRS_LIQUID_HTTP_SOCK=/tmp/elements.liquid.electrs
|
|
ELECTRS_LIQUID_HTTP_HOST=127.0.0.1
|
|
ELECTRS_LIQUID_HTTP_PORT=3001
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#ELECTRS_TESTNET_HTTP_SOCK=/tmp/bitcoin.testnet.electrs
|
|
ELECTRS_TESTNET_HTTP_HOST=127.0.0.1
|
|
ELECTRS_TESTNET_HTTP_PORT=3002
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#ELECTRS_SIGNET_HTTP_SOCK=/tmp/bitcoin.testnet.electrs
|
|
ELECTRS_SIGNET_HTTP_HOST=127.0.0.1
|
|
ELECTRS_SIGNET_HTTP_PORT=3003
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#ELECTRS_LIQUIDTESTNET_HTTP_SOCK=/tmp/bitcoin.testnet.electrs
|
|
ELECTRS_LIQUIDTESTNET_HTTP_HOST=127.0.0.1
|
|
ELECTRS_LIQUIDTESTNET_HTTP_PORT=3004
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_MAINNET_HTTP_SOCK=/tmp/bitcoin.mainnet.mempool
|
|
MEMPOOL_MAINNET_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_MAINNET_HTTP_PORT=8999
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_LIQUID_HTTP_SOCK=/tmp/elements.liquid.mempool
|
|
MEMPOOL_LIQUID_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_LIQUID_HTTP_PORT=8998
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_TESTNET_HTTP_SOCK=/tmp/bitcoin.testnet.mempool
|
|
MEMPOOL_TESTNET_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_TESTNET_HTTP_PORT=8997
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_BISQ_HTTP_SOCK=/tmp/bitcoin.bisq.mempool
|
|
MEMPOOL_BISQ_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_BISQ_HTTP_PORT=8996
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_SIGNET_HTTP_SOCK=/tmp/bitcoin.bisq.mempool
|
|
MEMPOOL_SIGNET_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_SIGNET_HTTP_PORT=8995
|
|
|
|
# set either socket or TCP host/port, not both
|
|
#MEMPOOL_LIQUIDTESTNET_HTTP_SOCK=/tmp/bitcoin.bisq.mempool
|
|
MEMPOOL_LIQUIDTESTNET_HTTP_HOST=127.0.0.1
|
|
MEMPOOL_LIQUIDTESTNET_HTTP_PORT=8994
|
|
|
|
##### OS options, should be automatically detected
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
ROOT_USER=root
|
|
ROOT_GROUP=wheel
|
|
ROOT_HOME=/root
|
|
TOR_HOME=/var/db/tor
|
|
TOR_CONFIGURATION=/usr/local/etc/tor/torrc
|
|
TOR_RESOURCES=/var/db/tor
|
|
TOR_PKG=tor
|
|
TOR_USER=_tor
|
|
TOR_GROUP=_tor
|
|
CERTBOT_PKG=py39-certbot
|
|
;;
|
|
|
|
Debian)
|
|
ROOT_USER=root
|
|
ROOT_GROUP=root
|
|
ROOT_HOME=/root
|
|
TOR_HOME=/etc/tor
|
|
TOR_CONFIGURATION=/etc/tor/torrc
|
|
TOR_RESOURCES=/var/lib/tor
|
|
TOR_PKG=tor
|
|
TOR_USER=debian-tor
|
|
TOR_GROUP=debian-tor
|
|
CERTBOT_PKG=python3-certbot-nginx
|
|
NGINX_CONFIGURATION=/etc/nginx/nginx.conf
|
|
;;
|
|
esac
|
|
|
|
# where systemd services get installed
|
|
DEBIAN_SERVICE_HOME=/etc/systemd/system
|
|
# where environment variables for services are set
|
|
DEBIAN_ENV_HOME=/etc/default
|
|
# where rc.d scripts live
|
|
FREEBSD_SERVICE_HOME=/usr/local/etc/rc.d
|
|
|
|
# mysql data folder and user/group
|
|
MYSQL_HOME=/mysql
|
|
MYSQL_USER=mysql
|
|
MYSQL_GROUP=mysql
|
|
|
|
# mempool data folder and user/group
|
|
MEMPOOL_HOME=/mempool
|
|
MEMPOOL_USER=mempool
|
|
MEMPOOL_GROUP=mempool
|
|
# name of Tor hidden service in torrc
|
|
MEMPOOL_TOR_HS=mempool
|
|
|
|
# bitcoin user/group
|
|
BITCOIN_USER=bitcoin
|
|
BITCOIN_GROUP=bitcoin
|
|
# bitcoin core data folder, needs about 300GB
|
|
BITCOIN_HOME=/bitcoin
|
|
|
|
# bitcoin testnet data
|
|
BITCOIN_TESTNET_DATA=${BITCOIN_HOME}/testnet3
|
|
# bitcoin testnet data
|
|
BITCOIN_SIGNET_DATA=${BITCOIN_HOME}/signet
|
|
|
|
# bitcoin electrs source/binaries
|
|
BITCOIN_ELECTRS_HOME=${BITCOIN_HOME}/electrs
|
|
|
|
# electrs database root
|
|
ELECTRS_DATA_ROOT=/electrs
|
|
# bitcoin electrs data, needs about 350GB, and uses double that during compaction
|
|
ELECTRS_MAINNET_ZPOOL=${ZPOOL}
|
|
ELECTRS_MAINNET_DATA=${ELECTRS_DATA_ROOT}/mainnet
|
|
# bitcoin testnet electrs database, only a few GB
|
|
ELECTRS_TESTNET_ZPOOL=${ZPOOL}
|
|
ELECTRS_TESTNET_DATA=${ELECTRS_DATA_ROOT}/testnet
|
|
# bitcoin signet electrs database, only a few GB
|
|
ELECTRS_SIGNET_ZPOOL=${ZPOOL}
|
|
ELECTRS_SIGNET_DATA=${ELECTRS_DATA_ROOT}/signet
|
|
# liquid electrs data, needs about 5GB
|
|
ELECTRS_LIQUID_ZPOOL=${ZPOOL}
|
|
ELECTRS_LIQUID_DATA=${ELECTRS_DATA_ROOT}/liquid
|
|
# liquid electrs data, needs about 5GB
|
|
ELECTRS_LIQUIDTESTNET_ZPOOL=${ZPOOL}
|
|
ELECTRS_LIQUIDTESTNET_DATA=${ELECTRS_DATA_ROOT}/liquidtestnet
|
|
|
|
# bisq user/group
|
|
BISQ_USER=bisq
|
|
BISQ_GROUP=bisq
|
|
# bisq home folder, needs about 1GB
|
|
BISQ_HOME=/bisq
|
|
|
|
# liquid user/group
|
|
ELEMENTS_USER=elements
|
|
ELEMENTS_GROUP=elements
|
|
# liquid home/data/blockchain folder, needs about 10GB
|
|
ELEMENTS_HOME=/elements
|
|
# electrs db top-level
|
|
ELECTRS_HOME=/electrs
|
|
# elements electrs source/binaries
|
|
ELEMENTS_ELECTRS_HOME=${ELEMENTS_HOME}/electrs
|
|
|
|
# minfee user/group
|
|
MINFEE_USER=minfee
|
|
MINFEE_GROUP=minfee
|
|
# minfee core data folder, needs about 30GB
|
|
MINFEE_HOME=/minfee
|
|
|
|
##### git repo settings, shouldn't need changing
|
|
|
|
MEMPOOL_REPO_URL=https://github.com/mempool/mempool
|
|
MEMPOOL_REPO_NAME=mempool
|
|
MEMPOOL_REPO_BRANCH=master
|
|
MEMPOOL_LATEST_RELEASE=master
|
|
|
|
BITCOIN_REPO_URL=https://github.com/bitcoin/bitcoin
|
|
BITCOIN_REPO_NAME=bitcoin
|
|
BITCOIN_REPO_BRANCH=master
|
|
#BITCOIN_LATEST_RELEASE=$(curl -s https://api.github.com/repos/bitcoin/bitcoin/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
|
|
BITCOIN_LATEST_RELEASE=v23.0
|
|
echo -n '.'
|
|
|
|
BISQ_REPO_URL=https://github.com/bisq-network/bisq
|
|
BISQ_REPO_NAME=bisq
|
|
BISQ_REPO_BRANCH=master
|
|
#BISQ_LATEST_RELEASE=$(curl -s https://api.github.com/repos/bisq-network/bisq/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
|
|
BISQ_LATEST_RELEASE=master
|
|
echo -n '.'
|
|
|
|
ELEMENTS_REPO_URL=https://github.com/ElementsProject/elements
|
|
ELEMENTS_REPO_NAME=elements
|
|
ELEMENTS_REPO_BRANCH=master
|
|
#ELEMENTS_LATEST_RELEASE=$(curl -s https://api.github.com/repos/ElementsProject/elements/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
|
|
ELEMENTS_LATEST_RELEASE=elements-0.21.0.2
|
|
echo -n '.'
|
|
|
|
BITCOIN_ELECTRS_REPO_URL=https://github.com/blockstream/electrs
|
|
BITCOIN_ELECTRS_REPO_NAME=electrs
|
|
BITCOIN_ELECTRS_REPO_BRANCH=new-index
|
|
BITCOIN_ELECTRS_LATEST_RELEASE=new-index
|
|
|
|
ELEMENTS_ELECTRS_REPO_URL=https://github.com/blockstream/electrs
|
|
ELEMENTS_ELECTRS_REPO_NAME=electrs
|
|
ELEMENTS_ELECTRS_REPO_BRANCH=new-index
|
|
ELEMENTS_ELECTRS_LATEST_RELEASE=new-index
|
|
|
|
LIQUID_ASSET_REGISTRY_DB_URL=https://github.com/blockstream/asset_registry_db
|
|
LIQUID_ASSET_REGISTRY_DB_NAME=asset_registry_db
|
|
LIQUIDTESTNET_ASSET_REGISTRY_DB_URL=https://github.com/blockstream/asset_registry_testnet_db
|
|
LIQUIDTESTNET_ASSET_REGISTRY_DB_NAME=asset_registry_testnet_db
|
|
|
|
#######################
|
|
##### OS packages #####
|
|
#######################
|
|
|
|
# packages needed for mempool ecosystem
|
|
DEBIAN_PKG=()
|
|
DEBIAN_PKG+=(zsh vim curl screen openssl python3 dialog cron)
|
|
DEBIAN_PKG+=(build-essential git git-lfs clang cmake jq)
|
|
DEBIAN_PKG+=(autotools-dev autoconf automake pkg-config bsdmainutils)
|
|
DEBIAN_PKG+=(libevent-dev libdb-dev libssl-dev libtool autotools-dev)
|
|
DEBIAN_PKG+=(libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev)
|
|
DEBIAN_PKG+=(nodejs npm mariadb-server nginx-core python3-certbot-nginx rsync ufw)
|
|
|
|
# packages needed for mempool ecosystem
|
|
FREEBSD_PKG=()
|
|
FREEBSD_PKG+=(zsh sudo git screen curl wget calc neovim)
|
|
FREEBSD_PKG+=(openssh-portable py39-pip rust llvm90 jq base64 libzmq4)
|
|
FREEBSD_PKG+=(boost-libs autoconf automake gmake gcc libevent libtool pkgconf)
|
|
FREEBSD_PKG+=(nginx rsync py39-certbot-nginx mariadb105-server keybase)
|
|
|
|
#############################
|
|
##### utility functions #####
|
|
#############################
|
|
|
|
osSudo()
|
|
{
|
|
SUDO_USER=$1
|
|
shift
|
|
case $OS in
|
|
FreeBSD)
|
|
sudo -H -i -u "${SUDO_USER}" $*
|
|
;;
|
|
Debian)
|
|
sudo -H -i -u "${SUDO_USER}" $*
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osPackageUpdate()
|
|
{
|
|
echo "[*] Updating OS sources"
|
|
case $OS in
|
|
FreeBSD)
|
|
pkg update
|
|
;;
|
|
Debian)
|
|
osSudo "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get update -q
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osPackageUpgrade()
|
|
{
|
|
echo "[*] Upgrading OS packages $*"
|
|
case $OS in
|
|
FreeBSD)
|
|
pkg upgrade -y $*
|
|
;;
|
|
Debian)
|
|
osSudo "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get upgrade -qq -y $*
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osPackageInstall()
|
|
{
|
|
echo "[*] Installing OS packages $*"
|
|
case $OS in
|
|
FreeBSD)
|
|
pkg install -y $*
|
|
;;
|
|
Debian)
|
|
osSudo "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get install -qq -y $*
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osPackageInstallAll()
|
|
{
|
|
case $OS in
|
|
FreeBSD)
|
|
osPackageInstall ${FREEBSD_PKG[@]}
|
|
;;
|
|
Debian)
|
|
osPackageInstall ${DEBIAN_PKG[@]}
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# osUserCreate username home_directory main_groupname [additional_group]
|
|
osUserCreate()
|
|
{
|
|
case $OS in
|
|
FreeBSD)
|
|
# pw useradd -d /mempool -g mempool [-G additional_group] -n mampool
|
|
if [ $# -eq 3 ] ; then
|
|
osSudo "${ROOT_USER}" pw useradd -d "$2" -g "$3" -n "$1"
|
|
elif [ $# -eq 4 ]; then
|
|
osSudo "${ROOT_USER}" pw useradd -d "$2" -g "$3" -G "$4" -n "$1"
|
|
else
|
|
echo "Illegal number of parameters"
|
|
exit 1
|
|
fi
|
|
;;
|
|
Debian)
|
|
# useradd -d /mempool -g mempool [-G additional_group] mempool
|
|
if [ $# -eq 3 ] ; then
|
|
osSudo "${ROOT_USER}" useradd -d "$2" -g "$3" "$1"
|
|
elif [ $# -eq 4 ]; then
|
|
osSudo "${ROOT_USER}" useradd -d "$2" -g "$3" -G "$4" "$1"
|
|
else
|
|
echo "Illegal number of parameters"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osGroupCreate()
|
|
{
|
|
case $OS in
|
|
FreeBSD)
|
|
osSudo "${ROOT_USER}" pw groupadd $*
|
|
;;
|
|
Debian)
|
|
osSudo "${ROOT_USER}" groupadd $*
|
|
;;
|
|
esac
|
|
}
|
|
|
|
osCertbotDryRun()
|
|
{
|
|
if [ ! -z "${HOSTNAME}" ];then
|
|
case $OS in
|
|
FreeBSD)
|
|
osPackageInstall "${FREEBSD_PKG_CERTBOT}"
|
|
;;
|
|
Debian)
|
|
osPackageInstall "${DEBIAN_PKG_CERTBOT}"
|
|
;;
|
|
esac
|
|
|
|
certbot certonly --dry-run --standalone --agree-tos --register-unsafely-without-email -d "${HOSTNAME}"
|
|
fi
|
|
}
|
|
|
|
zfsCreateFilesystems()
|
|
{
|
|
zfs create -o "mountpoint=/backup" "${ZPOOL}/backup"
|
|
|
|
zfs create -o "mountpoint=${ELEMENTS_HOME}" "${ZPOOL}/elements"
|
|
zfs create -o "mountpoint=${BITCOIN_HOME}" "${ZPOOL}/bitcoin"
|
|
zfs create -o "mountpoint=${MINFEE_HOME}" "${ZPOOL}/minfee"
|
|
zfs create -o "mountpoint=${ELECTRS_HOME}" "${ZPOOL}/electrs"
|
|
zfs create -o "mountpoint=${MEMPOOL_HOME}" "${ZPOOL}/mempool"
|
|
zfs create -o "mountpoint=${MYSQL_HOME}" "${ZPOOL}/mysql"
|
|
|
|
zfs create -o "mountpoint=${BITCOIN_ELECTRS_HOME}" "${ZPOOL}/bitcoin/electrs"
|
|
|
|
zfs create -o "mountpoint=${ELEMENTS_HOME}/liquidv1" "${ZPOOL}/elements/liquidv1"
|
|
zfs create -o "mountpoint=${ELEMENTS_ELECTRS_HOME}" "${ZPOOL}/elements/electrs"
|
|
|
|
# Bitcoin Mainnet
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
zfs create -o "mountpoint=${BITCOIN_HOME}/${folder}" "${ZPOOL}/bitcoin/${folder}"
|
|
done
|
|
fi
|
|
|
|
# Bitcoin Testnet
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${BITCOIN_TESTNET_DATA}" "${ZPOOL}/bitcoin/testnet"
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
zfs create -o "mountpoint=${BITCOIN_TESTNET_DATA}/${folder}" "${ZPOOL}/bitcoin/testnet/${folder}"
|
|
done
|
|
fi
|
|
|
|
# Bitcoin Signet
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${BITCOIN_SIGNET_DATA}" "${ZPOOL}/bitcoin/signet"
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
zfs create -o "mountpoint=${BITCOIN_SIGNET_DATA}/${folder}" "${ZPOOL}/bitcoin/signet/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs mainnet data
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${ELECTRS_MAINNET_DATA}" "${ELECTRS_MAINNET_ZPOOL}/electrs/mainnet"
|
|
for folder in cache history txstore
|
|
do
|
|
zfs create -o "mountpoint=${ELECTRS_MAINNET_DATA}/newindex/${folder}" "${ELECTRS_MAINNET_ZPOOL}/electrs/mainnet/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs testnet data
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${ELECTRS_TESTNET_DATA}" "${ELECTRS_TESTNET_ZPOOL}/electrs/testnet"
|
|
for folder in cache history txstore
|
|
do
|
|
zfs create -o "mountpoint=${ELECTRS_TESTNET_DATA}/newindex/${folder}" "${ELECTRS_TESTNET_ZPOOL}/electrs/testnet/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs signet data
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${ELECTRS_SIGNET_DATA}" "${ELECTRS_SIGNET_ZPOOL}/electrs/signet"
|
|
for folder in cache history txstore
|
|
do
|
|
zfs create -o "mountpoint=${ELECTRS_SIGNET_DATA}/newindex/${folder}" "${ELECTRS_SIGNET_ZPOOL}/electrs/signet/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs liquid data
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${ELECTRS_LIQUID_DATA}" "${ELECTRS_LIQUID_ZPOOL}/electrs/liquid"
|
|
for folder in cache history txstore
|
|
do
|
|
zfs create -o "mountpoint=${ELECTRS_LIQUID_DATA}/newindex/${folder}" "${ELECTRS_LIQUID_ZPOOL}/electrs/liquid/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs liquidtestnet data
|
|
if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then
|
|
zfs create -o "mountpoint=${ELECTRS_LIQUIDTESTNET_DATA}" "${ELECTRS_LIQUIDTESTNET_ZPOOL}/electrs/liquidtestnet"
|
|
for folder in cache history txstore
|
|
do
|
|
zfs create -o "mountpoint=${ELECTRS_LIQUIDTESTNET_DATA}/newindex/${folder}" "${ELECTRS_LIQUIDTESTNET_ZPOOL}/electrs/liquidtestnet/${folder}"
|
|
done
|
|
fi
|
|
|
|
if [ "${BISQ_INSTALL}" = ON ];then
|
|
zfs create -o "mountpoint=${BISQ_HOME}" "${ZPOOL}/bisq"
|
|
fi
|
|
}
|
|
|
|
ext4CreateDir()
|
|
{
|
|
mkdir -p "/backup" "${ELEMENTS_HOME}" "${BITCOIN_HOME}" "${MINFEE_HOME}" "${ELECTRS_HOME}" "${MEMPOOL_HOME}" "${MYSQL_HOME}" "${BITCOIN_ELECTRS_HOME}" "${ELEMENTS_HOME}/liquidv1" "${ELEMENTS_ELECTRS_HOME}"
|
|
# Bitcoin Mainnet
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
mkdir -p "${BITCOIN_HOME}/${folder}"
|
|
done
|
|
fi
|
|
|
|
# Bitcoin Testnet
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
mkdir -p "${BITCOIN_TESTNET_DATA}"
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
mkdir -p "${BITCOIN_TESTNET_DATA}/${folder}"
|
|
done
|
|
fi
|
|
|
|
# Bitcoin Signet
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
mkdir -p "${BITCOIN_SIGNET_DATA}"
|
|
for folder in chainstate indexes blocks
|
|
do
|
|
mkdir -p "${BITCOIN_SIGNET_DATA}/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs mainnet data
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
mkdir -p "${ELECTRS_MAINNET_DATA}"
|
|
for folder in cache history txstore
|
|
do
|
|
mkdir -p "${ELECTRS_MAINNET_DATA}/newindex/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs testnet data
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
mkdir -p "${ELECTRS_TESTNET_DATA}"
|
|
for folder in cache history txstore
|
|
do
|
|
mkdir -p "${ELECTRS_TESTNET_DATA}/newindex/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs signet data
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
mkdir -p "${ELECTRS_SIGNET_DATA}"
|
|
for folder in cache history txstore
|
|
do
|
|
mkdir -p "${ELECTRS_SIGNET_DATA}/newindex/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs liquid data
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
mkdir -p "${ELECTRS_LIQUID_DATA}"
|
|
for folder in cache history txstore
|
|
do
|
|
mkdir -p "${ELECTRS_LIQUID_DATA}/newindex/${folder}"
|
|
done
|
|
fi
|
|
|
|
# electrs liquidtestnet data
|
|
if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then
|
|
mkdir -p "${ELECTRS_LIQUIDTESTNET_DATA}"
|
|
for folder in cache history txstore
|
|
do
|
|
mkdir -p "${ELECTRS_LIQUIDTESTNET_DATA}/newindex/${folder}"
|
|
done
|
|
fi
|
|
|
|
if [ "${BISQ_INSTALL}" = ON ];then
|
|
mkdir -p "${BISQ_HOME}"
|
|
fi
|
|
}
|
|
|
|
|
|
##### Perform sanity checks before trying anything
|
|
|
|
# what OS running, what FS partitions, etc.
|
|
# how much free disk space available?
|
|
# is something listening on port 80 already?
|
|
# is nginx or apache running?
|
|
|
|
##### Determine what actually needs to be installed
|
|
|
|
# does bitcoin exist?
|
|
|
|
##########
|
|
# dialog #
|
|
##########
|
|
|
|
: ${DIALOG=dialog}
|
|
|
|
: ${DIALOG_OK=0}
|
|
: ${DIALOG_CANCEL=1}
|
|
: ${DIALOG_HELP=2}
|
|
: ${DIALOG_EXTRA=3}
|
|
: ${DIALOG_ITEM_HELP=4}
|
|
: ${DIALOG_ESC=255}
|
|
|
|
: ${SIG_OFFNE=0}
|
|
: ${SIG_HUP=1}
|
|
: ${SIG_INT=2}
|
|
: ${SIG_QUIT=3}
|
|
: ${SIG_KILL=9}
|
|
: ${SIG_TERM=15}
|
|
|
|
input=`tempfile 2>/dev/null` || input=/tmp/input$$
|
|
output=`tempfile 2>/dev/null` || output=/tmp/test$$
|
|
trap "rm -f $input $output" $SIG_OFFNE $SIG_HUP $SIG_INT $SIG_TRAP $SIG_TERM
|
|
|
|
DIALOG_ERROR=254
|
|
export DIALOG_ERROR
|
|
|
|
backtitle="Mempool Fullnode Installer"
|
|
title="Mempool Fullnode Installer"
|
|
returncode=0
|
|
|
|
#################
|
|
# dialog part 1 #
|
|
#################
|
|
|
|
$CUT >$input <<-EOF
|
|
Tor:Enable Tor v3 HS Onion:ON
|
|
Certbot:Enable HTTPS using Certbot:ON
|
|
Mainnet:Enable Bitcoin Mainnet:ON
|
|
Mainnet-Minfee:Enable Bitcoin Mainnet Minfee:ON
|
|
Testnet:Enable Bitcoin Testnet:ON
|
|
Liquid:Enable Elements Liquid:ON
|
|
Bisq:Enable Bisq:ON
|
|
Lightmode:Enable Electrs Lightmode to save disk space:ON
|
|
Smalldisk:Disable Electrs Compaction to save disk space:ON
|
|
Firewall:Enable Firewall:ON
|
|
EOF
|
|
|
|
cat $input | sed -e 's/^/"/' -e 's/:/" "/g' -e 's/$/"/' >$output
|
|
cat $output >$input
|
|
|
|
$DIALOG --backtitle "${backtitle}" \
|
|
--title "${title}" "$@" \
|
|
--checklist "Toggle the features below to configure your fullnode:\n" \
|
|
20 80 10 \
|
|
--file $input 2> $output
|
|
|
|
retval=$?
|
|
|
|
tempfile=$output
|
|
if [ $retval != $DIALOG_OK ];then
|
|
echo "Installation aborted."
|
|
exit 1
|
|
fi
|
|
|
|
if grep Tor $tempfile >/dev/null 2>&1;then
|
|
TOR_INSTALL=ON
|
|
else
|
|
TOR_INSTALL=OFF
|
|
fi
|
|
|
|
if grep Certbot $tempfile >/dev/null 2>&1;then
|
|
CERTBOT_INSTALL=ON
|
|
else
|
|
CERTBOT_INSTALL=OFF
|
|
fi
|
|
|
|
if grep Mainnet $tempfile >/dev/null 2>&1;then
|
|
BITCOIN_MAINNET_ENABLE=ON
|
|
else
|
|
BITCOIN_MAINNET_ENABLE=OFF
|
|
fi
|
|
|
|
if grep Mainnet-Minfee $tempfile >/dev/null 2>&1;then
|
|
BITCOIN_MAINNET_MINFEE_ENABLE=ON
|
|
else
|
|
BITCOIN_MAINNET_MINFEE_ENABLE=OFF
|
|
fi
|
|
|
|
if grep Testnet $tempfile >/dev/null 2>&1;then
|
|
BITCOIN_TESTNET_ENABLE=ON
|
|
else
|
|
BITCOIN_TESTNET_ENABLE=OFF
|
|
fi
|
|
|
|
if grep Liquid $tempfile >/dev/null 2>&1;then
|
|
ELEMENTS_INSTALL=ON
|
|
ELEMENTS_LIQUID_ENABLE=ON
|
|
else
|
|
ELEMENTS_INSTALL=OFF
|
|
ELEMENTS_LIQUID_ENABLE=OFF
|
|
fi
|
|
|
|
if grep Bisq $tempfile >/dev/null 2>&1;then
|
|
BISQ_INSTALL=ON
|
|
BISQ_MAINNET_ENABLE=ON
|
|
else
|
|
BISQ_INSTALL=OFF
|
|
BISQ_MAINNET_ENABLE=OFF
|
|
fi
|
|
|
|
if grep Lightmode $tempfile >/dev/null 2>&1;then
|
|
BITCOIN_ELECTRS_LIGHT_MODE=ON
|
|
else
|
|
BITCOIN_ELECTRS_LIGHT_MODE=OFF
|
|
fi
|
|
|
|
if grep Smalldisk $tempfile >/dev/null 2>&1;then
|
|
BITCOIN_ELECTRS_LIGHT_MODE=ON
|
|
else
|
|
BITCOIN_ELECTRS_LIGHT_MODE=OFF
|
|
fi
|
|
|
|
#################
|
|
# dialog part 2 #
|
|
#################
|
|
|
|
$DIALOG --cr-wrap \
|
|
--title "INPUT BOX" --clear \
|
|
--inputbox "$@" \
|
|
"Enter the FQDN hostname for obtaining an SSL certificate using Certbot:" 0 0 "${HOSTNAME}" 2> $tempfile
|
|
HOSTNAME=$(cat $tempfile)
|
|
|
|
#################
|
|
# dialog part 3 #
|
|
#################
|
|
|
|
# --form text height width formheight
|
|
# [ label y x item y x flen ilen ]
|
|
#"BISQ_BLOCKNOTIFY_HOST" 0 1 "${BISQ_BLOCKNOTIFY_HOST}" 0 30 0 0 \
|
|
|
|
$DIALOG --ok-label "Submit" \
|
|
--backtitle "$backtitle" "$@" \
|
|
--form "Your fullnode will be installed as follows:" 0 0 0 \
|
|
"BISQ_LATEST_RELEASE" 1 1 "${BISQ_LATEST_RELEASE}" 1 35 35 0 \
|
|
"BISQ_REPO_BRANCH" 2 1 "${BISQ_REPO_BRANCH}" 2 35 35 0 \
|
|
"BISQ_REPO_NAME" 3 1 "${BISQ_REPO_NAME}" 3 35 35 0 \
|
|
"BISQ_REPO_URL" 4 1 "${BISQ_REPO_URL}" 4 35 35 0 \
|
|
"BITCOIN_ELECTRS_LATEST_RELEASE" 5 1 "${BITCOIN_ELECTRS_LATEST_RELEASE}" 5 35 35 0 \
|
|
"BITCOIN_ELECTRS_LIGHT_MODE" 6 1 "${BITCOIN_ELECTRS_LIGHT_MODE}" 6 35 35 0 \
|
|
"BITCOIN_ELECTRS_REPO_BRANCH" 7 1 "${BITCOIN_ELECTRS_REPO_BRANCH}" 7 35 35 0 \
|
|
"BITCOIN_ELECTRS_REPO_NAME" 8 1 "${BITCOIN_ELECTRS_REPO_NAME}" 8 35 35 0 \
|
|
"BITCOIN_ELECTRS_REPO_URL" 9 1 "${BITCOIN_ELECTRS_REPO_URL}" 9 35 35 0 \
|
|
"BITCOIN_LATEST_RELEASE" 10 1 "${BITCOIN_LATEST_RELEASE}" 10 35 35 0 \
|
|
"BITCOIN_MAINNET_ENABLE" 11 1 "${BITCOIN_MAINNET_ENABLE}" 11 35 35 0 \
|
|
"BITCOIN_REPO_BRANCH" 12 1 "${BITCOIN_REPO_BRANCH}" 12 35 35 0 \
|
|
"BITCOIN_REPO_NAME" 13 1 "${BITCOIN_REPO_NAME}" 13 35 35 0 \
|
|
"BITCOIN_REPO_URL" 14 1 "${BITCOIN_REPO_URL}" 14 35 35 0 \
|
|
"BITCOIN_TESTNET_ENABLE" 15 1 "${BITCOIN_TESTNET_ENABLE}" 15 35 35 0 \
|
|
"ELEMENTS_INSTALL" 16 1 "${ELEMENTS_INSTALL}" 16 35 35 0 \
|
|
"ELEMENTS_LATEST_RELEASE" 17 1 "${ELEMENTS_LATEST_RELEASE}" 17 35 35 0 \
|
|
"ELEMENTS_LIQUID_ENABLE" 18 1 "${ELEMENTS_LIQUID_ENABLE}" 18 35 35 0 \
|
|
"ELEMENTS_REPO_BRANCH" 19 1 "${ELEMENTS_REPO_BRANCH}" 19 35 35 0 \
|
|
"ELEMENTS_REPO_NAME" 20 1 "${ELEMENTS_REPO_NAME}" 20 35 35 0 \
|
|
"ELEMENTS_REPO_URL" 21 1 "${ELEMENTS_REPO_URL}" 21 35 35 0 \
|
|
"MEMPOOL_LATEST_RELEASE" 22 1 "${MEMPOOL_LATEST_RELEASE}" 22 35 35 0 \
|
|
"MEMPOOL_LIQUID_HTTP_HOST" 23 1 "${MEMPOOL_LIQUID_HTTP_HOST}" 23 35 35 0 \
|
|
"MEMPOOL_LIQUID_HTTP_PORT" 24 1 "${MEMPOOL_LIQUID_HTTP_PORT}" 24 35 35 0 \
|
|
"MEMPOOL_MAINNET_HTTP_HOST" 25 1 "${MEMPOOL_MAINNET_HTTP_HOST}" 25 35 35 0 \
|
|
"MEMPOOL_MAINNET_HTTP_PORT" 26 1 "${MEMPOOL_MAINNET_HTTP_PORT}" 26 35 35 0 \
|
|
"MEMPOOL_REPO_BRANCH" 27 1 "${MEMPOOL_REPO_BRANCH}" 27 35 35 0 \
|
|
"MEMPOOL_REPO_NAME" 28 1 "${MEMPOOL_REPO_NAME}" 28 35 35 0 \
|
|
"MEMPOOL_REPO_URL" 29 1 "${MEMPOOL_REPO_URL}" 29 35 35 0 \
|
|
"MEMPOOL_TESTNET_HTTP_HOST" 30 1 "${MEMPOOL_TESTNET_HTTP_HOST}" 30 35 35 0 \
|
|
"MEMPOOL_TESTNET_HTTP_PORT" 31 1 "${MEMPOOL_TESTNET_HTTP_PORT}" 31 35 35 0 \
|
|
"MEMPOOL_TOR_HS" 32 1 "${MEMPOOL_TOR_HS}" 32 35 35 0 \
|
|
"HOSTNAME" 33 1 "${HOSTNAME}" 33 35 35 0 \
|
|
"TOR_INSTALL" 34 1 "${TOR_INSTALL}" 34 35 35 0 \
|
|
"CERTBOT_INSTALL" 35 1 "${CERTBOT_INSTALL}" 35 35 35 0 \
|
|
2> $tempfile
|
|
|
|
retval=$?
|
|
|
|
if [ $retval != $DIALOG_OK ];then
|
|
echo "Installation aborted."
|
|
exit 1
|
|
fi
|
|
|
|
############################
|
|
# START DOING ACTUAL STUFF #
|
|
############################
|
|
|
|
date
|
|
echo "[*] Mempool installation script for ${OS}"
|
|
|
|
set -x
|
|
|
|
###################################
|
|
# create filesystems if necessary #
|
|
###################################
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
zfsCreateFilesystems
|
|
;;
|
|
Debian)
|
|
ext4CreateDir
|
|
;;
|
|
esac
|
|
|
|
###############################
|
|
# Install all the OS packages #
|
|
###############################
|
|
|
|
osPackageUpdate
|
|
osPackageUpgrade
|
|
osPackageInstallAll
|
|
|
|
##########################
|
|
# Mempool top-level repo #
|
|
##########################
|
|
|
|
echo "[*] Creating Mempool user with Tor access"
|
|
osGroupCreate "${MEMPOOL_GROUP}"
|
|
osUserCreate "${MEMPOOL_USER}" "${MEMPOOL_HOME}" "${MEMPOOL_GROUP}"
|
|
osSudo "${ROOT_USER}" chsh -s `which zsh` "${MEMPOOL_USER}"
|
|
id "${MEMPOOL_USER}"
|
|
|
|
echo "[*] Creating Mempool data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${MEMPOOL_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${MEMPOOL_USER}:${MEMPOOL_GROUP}" "${MEMPOOL_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${MEMPOOL_USER}:${MEMPOOL_GROUP}" /backup
|
|
osSudo "${MEMPOOL_USER}" touch "${MEMPOOL_HOME}/.zshrc"
|
|
|
|
echo "[*] Cloning Mempool repo from ${MEMPOOL_REPO_URL}"
|
|
osSudo "${MEMPOOL_USER}" git config --global pull.rebase true
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}"
|
|
osSudo "${MEMPOOL_USER}" ln -s mempool/production/mempool-build-all upgrade
|
|
osSudo "${MEMPOOL_USER}" ln -s mempool/production/mempool-kill-all stop
|
|
osSudo "${MEMPOOL_USER}" ln -s mempool/production/mempool-start-all start
|
|
osSudo "${MEMPOOL_USER}" ln -s mempool/production/mempool-restart-all restart
|
|
|
|
echo "[*] Installing syslog configuration"
|
|
osSudo "${ROOT_USER}" mkdir -p /usr/local/etc/syslog.d
|
|
osSudo "${ROOT_USER}" install -c -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/mempool-logger" /usr/local/bin/mempool-logger
|
|
osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/syslog.conf" /usr/local/etc/syslog.d/mempool.conf
|
|
|
|
echo "[*] Installing newsyslog configuration"
|
|
osSudo "${ROOT_USER}" mkdir -p /usr/local/etc/newsyslog.conf.d
|
|
osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/newsyslog-mempool-backend.conf" /usr/local/etc/syslog.d/newsyslog-mempool-backend.conf
|
|
osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/newsyslog-mempool-nginx.conf" /usr/local/etc/syslog.d/newsyslog-mempool-nginx.conf
|
|
|
|
echo "[*] Installing Mempool crontab"
|
|
osSudo "${ROOT_USER}" crontab -u "${MEMPOOL_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/mempool.crontab"
|
|
|
|
echo "[*] Installing nvm.sh from GitHub"
|
|
osSudo "${MEMPOOL_USER}" sh -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh'
|
|
|
|
echo "[*] Building NodeJS via nvm.sh"
|
|
osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm install v16.15.0'
|
|
|
|
####################
|
|
# Tor installation #
|
|
####################
|
|
|
|
if [ "${TOR_INSTALL}" = ON ];then
|
|
|
|
echo "[*] Installing Tor package"
|
|
osPackageInstall "${TOR_PKG}"
|
|
|
|
echo "[*] Installing Tor base configuration"
|
|
osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/torrc" "${TOR_HOME}/torrc"
|
|
|
|
echo "[*] Adding Tor HS configuration"
|
|
if ! grep "${MEMPOOL_TOR_HS}" /etc/tor/torrc >/dev/null 2>&1;then
|
|
osSudo "${ROOT_USER}" /bin/sh -c "echo HiddenServiceDir ${TOR_RESOURCES}/${MEMPOOL_TOR_HS}/ >> ${TOR_CONFIGURATION}"
|
|
osSudo "${ROOT_USER}" /bin/sh -c "echo HiddenServicePort 80 127.0.0.1:81 >> ${TOR_CONFIGURATION}"
|
|
osSudo "${ROOT_USER}" /bin/sh -c "echo HiddenServiceVersion 3 >> ${TOR_CONFIGURATION}"
|
|
fi
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
echo net.inet.ip.random_id=1 >> /etc/sysctl.conf
|
|
sysctl net.inet.ip.random_id=1
|
|
;;
|
|
esac
|
|
|
|
# start tor now so it can bootstrap in time for bitcoin starting a few mins later
|
|
echo "[*] Starting Tor service"
|
|
osSudo "${ROOT_USER}" service tor start
|
|
fi
|
|
|
|
########################
|
|
# Bitcoin installation #
|
|
########################
|
|
|
|
if [ "${BITCOIN_INSTALL}" = ON ];then
|
|
|
|
echo "[*] Creating Bitcoin user with Tor access"
|
|
osGroupCreate "${BITCOIN_GROUP}"
|
|
osUserCreate "${BITCOIN_USER}" "${BITCOIN_HOME}" "${BITCOIN_GROUP}" "${TOR_GROUP}"
|
|
osSudo "${ROOT_USER}" chsh -s `which zsh` "${BITCOIN_USER}"
|
|
|
|
echo "[*] Creating Bitcoin minfee user with Tor access"
|
|
osGroupCreate "${MINFEE_GROUP}"
|
|
osUserCreate "${MINFEE_USER}" "${MINFEE_HOME}" "${MINFEE_GROUP}" "${TOR_GROUP}"
|
|
osSudo "${ROOT_USER}" chown -R "${MINFEE_USER}:${MINFEE_GROUP}" "${MINFEE_HOME}"
|
|
osSudo "${ROOT_USER}" chsh -s `which zsh` "${MINFEE_USER}"
|
|
osSudo "${MINFEE_USER}" touch "${MINFEE_HOME}/.zshrc"
|
|
osSudo "${MINFEE_USER}" ln -s . .bitcoin
|
|
|
|
echo "[*] Creating Bitcoin data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${BITCOIN_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${BITCOIN_USER}:${BITCOIN_GROUP}" "${BITCOIN_HOME}"
|
|
osSudo "${BITCOIN_USER}" touch "${BITCOIN_HOME}/.zshrc"
|
|
osSudo "${BITCOIN_USER}" ln -s . .bitcoin
|
|
|
|
echo "[*] Cloning Bitcoin repo from ${BITCOIN_REPO_URL}"
|
|
osSudo "${BITCOIN_USER}" git config --global advice.detachedHead false
|
|
osSudo "${BITCOIN_USER}" git clone --branch "${BITCOIN_REPO_BRANCH}" "${BITCOIN_REPO_URL}" "${BITCOIN_HOME}/${BITCOIN_REPO_NAME}"
|
|
|
|
echo "[*] Checking out Bitcoin ${BITCOIN_LATEST_RELEASE}"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_HOME}/${BITCOIN_REPO_NAME} && git checkout ${BITCOIN_LATEST_RELEASE}"
|
|
|
|
echo "[*] Building Bitcoin from source repo"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_REPO_NAME} && ./autogen.sh --quiet"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_REPO_NAME} && MAKE=gmake CC=cc CXX=c++ CPPFLAGS=-I/usr/local/include ./configure --with-gui=no --disable-wallet --disable-tests"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_REPO_NAME} && gmake -j${NPROC}"
|
|
|
|
echo "[*] Installing Bitcoin binaries into OS"
|
|
osSudo "${ROOT_USER}" sh -c "cd ${BITCOIN_HOME}/${BITCOIN_REPO_NAME} && gmake install"
|
|
|
|
echo "[*] Installing Bitcoin configuration"
|
|
osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.conf" "${BITCOIN_HOME}/bitcoin.conf"
|
|
|
|
echo "[*] Installing Bitcoin minfee configuration"
|
|
osSudo "${ROOT_USER}" install -c -o "${MINFEE_USER}" -g "${MINFEE_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.minfee.conf" "${MINFEE_HOME}/bitcoin.conf"
|
|
|
|
echo "[*] Installing Bitcoin RPC credentials"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_HOME}/bitcoin.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_HOME}/bitcoin.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${MINFEE_HOME}/bitcoin.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${MINFEE_HOME}/bitcoin.conf"
|
|
fi
|
|
|
|
#########################
|
|
# Elements installation #
|
|
#########################
|
|
|
|
if [ "${ELEMENTS_INSTALL}" = ON ];then
|
|
|
|
echo "[*] Creating Elements user with Tor access"
|
|
osGroupCreate "${ELEMENTS_GROUP}"
|
|
osUserCreate "${ELEMENTS_USER}" "${ELEMENTS_HOME}" "${ELEMENTS_GROUP}" "${TOR_GROUP}"
|
|
osSudo "${ROOT_USER}" chsh -s `which zsh` "${ELEMENTS_USER}"
|
|
|
|
echo "[*] Creating Elements data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${ELEMENTS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${ELEMENTS_USER}:${ELEMENTS_GROUP}" "${ELEMENTS_HOME}"
|
|
osSudo "${ELEMENTS_USER}" touch "${ELEMENTS_HOME}/.zshrc"
|
|
osSudo "${ELEMENTS_USER}" ln -s . .elements
|
|
|
|
echo "[*] Cloning Elements repo from ${ELEMENTS_REPO_URL}"
|
|
osSudo "${ELEMENTS_USER}" git config --global advice.detachedHead false
|
|
osSudo "${ELEMENTS_USER}" git clone --branch "${ELEMENTS_REPO_BRANCH}" "${ELEMENTS_REPO_URL}" "${ELEMENTS_HOME}/${ELEMENTS_REPO_NAME}"
|
|
|
|
echo "[*] Checking out Elements ${ELEMENTS_LATEST_RELEASE}"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_HOME}/${ELEMENTS_REPO_NAME} && git checkout ${ELEMENTS_LATEST_RELEASE}"
|
|
|
|
echo "[*] Building Elements from source repo"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_REPO_NAME} && ./autogen.sh --quiet"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_REPO_NAME} && MAKE=gmake CC=cc CXX=c++ CPPFLAGS=-I/usr/local/include ./configure --with-gui=no --disable-wallet --disable-tests"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_REPO_NAME} && gmake -j${NPROC}"
|
|
|
|
echo "[*] Installing Elements binaries into OS"
|
|
osSudo "${ROOT_USER}" sh -c "cd ${ELEMENTS_HOME}/${ELEMENTS_REPO_NAME} && gmake install"
|
|
|
|
echo "[*] Installing Elements configuration"
|
|
osSudo "${ROOT_USER}" install -c -o "${ELEMENTS_USER}" -g "${ELEMENTS_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/elements.conf" "${ELEMENTS_HOME}/elements.conf"
|
|
|
|
echo "[*] Configuring Elements Liquid RPC credentials in elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_USER__/${ELEMENTS_RPC_USER}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_PASS__/${ELEMENTS_RPC_PASS}/" "${ELEMENTS_HOME}/elements.conf"
|
|
fi
|
|
|
|
###################################
|
|
# Bitcoin -> Electrs installation #
|
|
###################################
|
|
|
|
echo "[*] Creating Bitcoin Electrs data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${BITCOIN_ELECTRS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${BITCOIN_USER}:${BITCOIN_GROUP}" "${BITCOIN_ELECTRS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${BITCOIN_USER}:${BITCOIN_GROUP}" "${ELECTRS_MAINNET_DATA}"
|
|
osSudo "${ROOT_USER}" chown -R "${BITCOIN_USER}:${BITCOIN_GROUP}" "${ELECTRS_TESTNET_DATA}"
|
|
osSudo "${ROOT_USER}" chown -R "${BITCOIN_USER}:${BITCOIN_GROUP}" "${ELECTRS_SIGNET_DATA}"
|
|
|
|
echo "[*] Cloning Bitcoin Electrs repo from ${BITCOIN_ELECTRS_REPO_URL}"
|
|
osSudo "${BITCOIN_USER}" git config --global advice.detachedHead false
|
|
osSudo "${BITCOIN_USER}" git clone --branch "${BITCOIN_ELECTRS_REPO_BRANCH}" "${BITCOIN_ELECTRS_REPO_URL}" "${BITCOIN_HOME}/${BITCOIN_ELECTRS_REPO_NAME}"
|
|
|
|
echo "[*] Checking out Electrs ${BITCOIN_ELECTRS_LATEST_RELEASE}"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_HOME}/${BITCOIN_ELECTRS_REPO_NAME} && git checkout ${BITCOIN_ELECTRS_LATEST_RELEASE}"
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
echo "[*] Installing Rust from pkg install"
|
|
;;
|
|
Debian)
|
|
echo "[*] Installing Rust from rustup.rs"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_ELECTRS_HOME} && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
|
|
;;
|
|
esac
|
|
|
|
echo "[*] Building Bitcoin Electrs release binary"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_ELECTRS_HOME} && cargo run --release --bin electrs -- --version" || true
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
echo "[*] Patching Bitcoin Electrs code for FreeBSD"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd \"${BITCOIN_HOME}/.cargo/registry/src/github.com-1ecc6299db9ec823/sysconf-0.3.4\" && patch -p1 < \"${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/freebsd/sysconf.patch\""
|
|
osSudo "${BITCOIN_USER}" sh -c "cd \"${BITCOIN_ELECTRS_HOME}/src/new_index/\" && sed -i.bak -e s/Snappy/None/ db.rs && rm db.rs.bak"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd \"${BITCOIN_ELECTRS_HOME}/src/bin/\" && sed -i.bak -e 's/from_secs(5)/from_secs(1)/' electrs.rs && rm electrs.rs.bak"
|
|
;;
|
|
Debian)
|
|
;;
|
|
esac
|
|
|
|
echo "[*] Building Bitcoin Electrs release binary"
|
|
osSudo "${BITCOIN_USER}" sh -c "cd ${BITCOIN_ELECTRS_HOME} && cargo run --release --bin electrs -- --version"
|
|
|
|
##################################
|
|
# Liquid -> Electrs installation #
|
|
##################################
|
|
|
|
echo "[*] Creating Liquid Electrs data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${ELEMENTS_ELECTRS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${ELEMENTS_USER}:${ELEMENTS_GROUP}" "${ELEMENTS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${ELEMENTS_USER}:${ELEMENTS_GROUP}" "${ELEMENTS_ELECTRS_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${ELEMENTS_USER}:${ELEMENTS_GROUP}" "${ELECTRS_LIQUID_DATA}"
|
|
osSudo "${ROOT_USER}" chown -R "${ELEMENTS_USER}:${ELEMENTS_GROUP}" "${ELECTRS_LIQUIDTESTNET_DATA}"
|
|
|
|
echo "[*] Cloning Liquid Electrs repo from ${ELEMENTS_ELECTRS_REPO_URL}"
|
|
osSudo "${ELEMENTS_USER}" git config --global advice.detachedHead false
|
|
osSudo "${ELEMENTS_USER}" git clone --branch "${ELEMENTS_ELECTRS_REPO_BRANCH}" "${ELEMENTS_ELECTRS_REPO_URL}" "${ELEMENTS_HOME}/${ELEMENTS_ELECTRS_REPO_NAME}"
|
|
|
|
echo "[*] Checking out Liquid Electrs ${ELEMENTS_ELECTRS_LATEST_RELEASE}"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_HOME}/${ELEMENTS_ELECTRS_REPO_NAME} && git checkout ${ELEMENTS_ELECTRS_LATEST_RELEASE}"
|
|
|
|
echo "[*] Cloning Liquid Asset Registry repo from ${LIQUID_ASSET_REGISTRY_DB_URL}"
|
|
osSudo "${ELEMENTS_USER}" git config --global advice.detachedHead false
|
|
osSudo "${ELEMENTS_USER}" git clone "${LIQUID_ASSET_REGISTRY_DB_URL}" "${ELEMENTS_HOME}/${LIQUID_ASSET_REGISTRY_DB_NAME}"
|
|
|
|
echo "[*] Cloning Liquid Asset Registry testnet repo from ${LIQUIDTESTNET_ASSET_REGISTRY_DB_URL}"
|
|
osSudo "${ELEMENTS_USER}" git config --global advice.detachedHead false
|
|
osSudo "${ELEMENTS_USER}" git clone "${LIQUIDTESTNET_ASSET_REGISTRY_DB_URL}" "${ELEMENTS_HOME}/${LIQUIDTESTNET_ASSET_REGISTRY_DB_NAME}"
|
|
|
|
echo "[*] Building Liquid Electrs release binary"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_ELECTRS_HOME} && cargo run --release --features liquid --bin electrs -- --network liquid --version" || true
|
|
|
|
case $OS in
|
|
FreeBSD)
|
|
echo "[*] Patching Liquid Electrs code for FreeBSD"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd \"${ELEMENTS_HOME}/.cargo/registry/src/github.com-1ecc6299db9ec823/sysconf-0.3.4\" && patch -p1 < \"${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/freebsd/sysconf.patch\""
|
|
;;
|
|
Debian)
|
|
;;
|
|
esac
|
|
|
|
echo "[*] Building Liquid Electrs release binary"
|
|
osSudo "${ELEMENTS_USER}" sh -c "cd ${ELEMENTS_ELECTRS_HOME} && cargo run --release --features liquid --bin electrs -- --network liquid --version" || true
|
|
|
|
#####################
|
|
# Bisq installation #
|
|
#####################
|
|
|
|
if [ "${BISQ_INSTALL}" = ON ];then
|
|
|
|
echo "[*] Creating Bisq user with Tor access"
|
|
osGroupCreate "${BISQ_GROUP}"
|
|
osUserCreate "${BISQ_USER}" "${BISQ_HOME}" "${BISQ_GROUP}" "${TOR_GROUP}"
|
|
osSudo "${ROOT_USER}" chsh -s `which zsh` "${BISQ_USER}"
|
|
|
|
echo "[*] Creating Bisq data folder"
|
|
osSudo "${ROOT_USER}" mkdir -p "${BISQ_HOME}"
|
|
osSudo "${ROOT_USER}" chown -R "${BISQ_USER}:${BISQ_GROUP}" "${BISQ_HOME}"
|
|
osSudo "${BISQ_USER}" touch "${BISQ_HOME}/.zshrc"
|
|
|
|
echo "[*] Building Bisq"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bisq must be installed manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
echo "[*] Cloning Bisq top-level repo"
|
|
osSudo "${BISQ_USER}" git clone --branch "${BISQ_REPO_BRANCH}" "${BISQ_REPO_URL}" "${BISQ_HOME}/${BISQ_REPO_NAME}"
|
|
|
|
echo "[*] Installing OpenJDK from Bisq install_java_linux.sh script"
|
|
osSudo "${ROOT_USER}" "${BISQ_HOME}/${BISQ_REPO_NAME}/scripts/install_java_linux.sh"
|
|
|
|
echo "[*] Checking out Bisq ${BISQ_LATEST_RELEASE}"
|
|
osSudo "${BISQ_USER}" sh -c "cd ${BISQ_HOME}/${BISQ_REPO_NAME} && git checkout ${BISQ_LATEST_RELEASE}"
|
|
|
|
echo "[*] Performing Git LFS pull"
|
|
osSudo "${BISQ_USER}" sh -c "cd ${BISQ_HOME}/${BISQ_REPO_NAME} && git lfs pull"
|
|
|
|
echo "[*] Building Bisq from source"
|
|
osSudo "${BISQ_USER}" sh -c "cd ${BISQ_HOME}/${BISQ_REPO_NAME} && ./gradlew build -x test < /dev/null" # redirect from /dev/null is necessary to workaround gradlew non-interactive shell hanging issue
|
|
|
|
;;
|
|
esac
|
|
|
|
echo "[*] Configuring Bisq"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bisq must be configured manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq.service" "${DEBIAN_SERVICE_HOME}/bisq.service"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/#Requires=bitcoin.service/Requires=bitcoin.service/" "${DEBIAN_SERVICE_HOME}/bisq.service"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/#BindsTo=bitcoin.service/BindsTo=bitcoin.service/" "${DEBIAN_SERVICE_HOME}/bisq.service"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BISQ_REPO_NAME__/${BISQ_REPO_NAME}/" "${DEBIAN_SERVICE_HOME}/bisq.service"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__BISQ_HOME__!${BISQ_HOME}!" "${DEBIAN_SERVICE_HOME}/bisq.service"
|
|
|
|
echo "[*] Installing Bisq environment file"
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq.env" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__BISQ_APP_NAME__!${BISQ_APP_NAME}!" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__BISQ_HOME__!${BISQ_HOME}!" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
|
|
echo "[*] Configuring Bisq environment file with Bitcoin RPC credentials"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_P2P_HOST__/${BITCOIN_MAINNET_P2P_HOST}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_P2P_PORT__/${BITCOIN_MAINNET_P2P_PORT}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_HOST__/${BITCOIN_MAINNET_RPC_HOST}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PORT__/${BITCOIN_MAINNET_RPC_PORT}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${DEBIAN_ENV_HOME}/bisq.env"
|
|
|
|
#echo "[*] Updating Bitcoin configuration for Bisq"
|
|
#osSudo "${ROOT_USER}" sed -i.orig "s/#blocknotify/blocknotify/" "${BITCOIN_HOME}/bitcoin.conf"
|
|
#osSudo "${BITCOIN_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/blocknotify.sh" "${BITCOIN_HOME}/blocknotify.sh"
|
|
;;
|
|
|
|
esac
|
|
fi
|
|
|
|
################################
|
|
# Bitcoin instance for Mainnet #
|
|
################################
|
|
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Mainnet service"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/freebsd/rc.d/bitcoin" "${FREEBSD_SERVICE_HOME}"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/bitcoin.service" "${DEBIAN_SERVICE_HOME}"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
#######################################
|
|
# Bitcoin instance for Mainnet Minfee #
|
|
#######################################
|
|
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Minfee service"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bitcoin Minfee service must be installed manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/bitcoin-minfee.service" "${DEBIAN_SERVICE_HOME}"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
################################
|
|
# Bitcoin instance for Testnet #
|
|
################################
|
|
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Testnet service"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bitcoin Testnet service must be installed manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/bitcoin-testnet.service" "${DEBIAN_SERVICE_HOME}"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
###############################
|
|
# Bitcoin instance for Signet #
|
|
###############################
|
|
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Signet service"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bitcoin Signet service must be installed manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/bitcoin-signet.service" "${DEBIAN_SERVICE_HOME}"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
###############################
|
|
# Bitcoin instance for Liquid #
|
|
###############################
|
|
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Liquid service"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: Bitcoin Liquid service must be installed manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/liquid.service" "${DEBIAN_SERVICE_HOME}"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
########################################
|
|
# Electrs instance for Bitcoin Mainnet #
|
|
########################################
|
|
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Mainnet electrs start script"
|
|
osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-mainnet" "${BITCOIN_ELECTRS_HOME}"
|
|
|
|
echo "[*] Configuring Bitcoin Mainnet RPC credentials in electrs start script"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-mainnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-mainnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__ELECTRS_DATA_ROOT__!${ELECTRS_DATA_ROOT}!" "${BITCOIN_ELECTRS_HOME}/electrs-start-mainnet"
|
|
fi
|
|
|
|
########################################
|
|
# Electrs instance for Bitcoin Testnet #
|
|
########################################
|
|
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Testnet electrs start script"
|
|
osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-testnet" "${BITCOIN_ELECTRS_HOME}"
|
|
|
|
echo "[*] Configuring Bitcoin Testnet RPC credentials in electrs start script"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-testnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-testnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__ELECTRS_DATA_ROOT__!${ELECTRS_DATA_ROOT}!" "${BITCOIN_ELECTRS_HOME}/electrs-start-testnet"
|
|
fi
|
|
|
|
#######################################
|
|
# Electrs instance for Bitcoin Signet #
|
|
#######################################
|
|
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Bitcoin Signet electrs start script"
|
|
osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-signet" "${BITCOIN_ELECTRS_HOME}"
|
|
|
|
echo "[*] Configuring Bitcoin Signet RPC credentials in electrs start script"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-signet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-signet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__ELECTRS_DATA_ROOT__!${ELECTRS_DATA_ROOT}!" "${BITCOIN_ELECTRS_HOME}/electrs-start-signet"
|
|
fi
|
|
|
|
########################################
|
|
# Electrs instance for Elements Liquid #
|
|
########################################
|
|
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
echo "[*] Installing Elements Liquid electrs start script"
|
|
osSudo "${ROOT_USER}" install -c -o "${ELEMENTS_USER}" -g "${ELEMENTS_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-liquid" "${ELEMENTS_ELECTRS_HOME}"
|
|
|
|
echo "[*] Installing Elements crontab"
|
|
case $OS in
|
|
FreeBSD)
|
|
echo [*] FIXME: must only crontab enabled daemons
|
|
osSudo "${ROOT_USER}" crontab -u "${ELEMENTS_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/elements.crontab"
|
|
;;
|
|
esac
|
|
|
|
echo "[*] Configuring Elements Liquid RPC credentials in electrs start script"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_USER__/${ELEMENTS_RPC_USER}/" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquid"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_PASS__/${ELEMENTS_RPC_PASS}/" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquid"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__ELECTRS_DATA_ROOT__!${ELECTRS_DATA_ROOT}!" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquid"
|
|
fi
|
|
|
|
################################################
|
|
# Electrs instance for Elements Liquid Testnet #
|
|
################################################
|
|
|
|
if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Installing Elements Liquid Testnet electrs start script"
|
|
osSudo "${ROOT_USER}" install -c -o "${ELEMENTS_USER}" -g "${ELEMENTS_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-liquidtestnet" "${ELEMENTS_ELECTRS_HOME}"
|
|
|
|
echo "[*] Installing Elements Liquid Testnet RPC credentials"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_USER__/${ELEMENTS_RPC_USER}/" "${ELEMENTS_HOME}/elements.conf"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_PASS__/${ELEMENTS_RPC_PASS}/" "${ELEMENTS_HOME}/elements.conf"
|
|
|
|
echo "[*] Configuring Elements LiquidTestnet RPC credentials in electrs start script"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_USER__/${ELEMENTS_RPC_USER}/" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquidtestnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_PASS__/${ELEMENTS_RPC_PASS}/" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquidtestnet"
|
|
osSudo "${ROOT_USER}" sed -i.orig "s!__ELECTRS_DATA_ROOT__!${ELECTRS_DATA_ROOT}!" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquidtestnet"
|
|
fi
|
|
|
|
################################
|
|
# Install all Electrs Cronjobs #
|
|
################################
|
|
echo "[*] Installing crontabs"
|
|
case $OS in
|
|
FreeBSD)
|
|
echo [*] FIXME: must only crontab enabled daemons
|
|
osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.crontab"
|
|
osSudo "${ROOT_USER}" crontab -u "${MINFEE_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/minfee.crontab"
|
|
;;
|
|
Debian)
|
|
crontab_bitcoin=()
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
echo [*] Installing Electrs Mainnet Cronjob
|
|
crontab_bitcoin+="@reboot sleep 30 ; screen -dmS mainnet /bitcoin/electrs/electrs-start-mainnet\n"
|
|
fi
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
echo [*] Installing Electrs Testnet Cronjob
|
|
crontab_bitcoin+="@reboot sleep 70 ; screen -dmS testnet /bitcoin/electrs/electrs-start-testnet\n"
|
|
fi
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
echo [*] Installing Electrs Signet Cronjob
|
|
crontab_bitcoin+="@reboot sleep 90 ; screen -dmS signet /bitcoin/electrs/electrs-start-signet\n"
|
|
fi
|
|
echo "${crontab_bitcoin}" | crontab -u "${BITCOIN_USER}" -
|
|
|
|
crontab_elements=()
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
echo [*] Installing Liquid Asset Mainnet Cronjob
|
|
crontab_elements+="6 * * * * cd $HOME/asset_registry_db && git pull origin master >/dev/null 2>&1\n"
|
|
fi
|
|
if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then
|
|
echo [*] Installing Liquid Asset Testnet Cronjob
|
|
crontab_elements+="6 * * * * cd $HOME/asset_registry_testnet_db && git pull origin master >/dev/null 2>&1\n"
|
|
fi
|
|
echo "${crontab_elements}" | crontab -u "${ELEMENTS_USER}" -
|
|
;;
|
|
esac
|
|
|
|
#####################################
|
|
# Bisq instance for Bitcoin Mainnet #
|
|
#####################################
|
|
|
|
if [ "${BISQ_MAINNET_ENABLE}" = ON ];then
|
|
fi
|
|
|
|
##### Mempool -> Bitcoin Mainnet instance
|
|
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Bitcoin Mainnet"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/mainnet"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Bitcoin Mainnet"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Bitcoin Testnet"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/testnet"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Bitcoin Testnet"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Bitcoin Signet"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/signet"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Bitcoin Signet"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Liquid"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/liquid"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Liquid"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Liquid Testnet"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/liquidtestnet"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Liquid Testnet"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
if [ "${BISQ_INSTALL}" = ON ];then
|
|
echo "[*] Creating Mempool instance for Bisq"
|
|
osSudo "${MEMPOOL_USER}" git config --global advice.detachedHead false
|
|
osSudo "${MEMPOOL_USER}" git clone --branch "${MEMPOOL_REPO_BRANCH}" "${MEMPOOL_REPO_URL}" "${MEMPOOL_HOME}/bisq"
|
|
|
|
echo "[*] Checking out Mempool ${MEMPOOL_LATEST_RELEASE} for Bisq"
|
|
osSudo "${MEMPOOL_USER}" sh -c "cd ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME} && git checkout ${MEMPOOL_LATEST_RELEASE}"
|
|
fi
|
|
|
|
##### mariadb
|
|
|
|
echo "[*] Adding MySQL configuration"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
osSudo "${ROOT_USER}" service mysql-server start
|
|
;;
|
|
Debian)
|
|
osSudo "${ROOT_USER}" service mysql start
|
|
;;
|
|
esac
|
|
|
|
mysql << _EOF_
|
|
create database mempool;
|
|
grant all on mempool.* to 'mempool'@'localhost' identified by 'mempool';
|
|
|
|
create database mempool_testnet;
|
|
grant all on mempool_testnet.* to 'mempool_testnet'@'localhost' identified by 'mempool_testnet';
|
|
|
|
create database mempool_signet;
|
|
grant all on mempool_signet.* to 'mempool_signet'@'localhost' identified by 'mempool_signet';
|
|
|
|
create database mempool_liquid;
|
|
grant all on mempool_liquid.* to 'mempool_liquid'@'localhost' identified by 'mempool_liquid';
|
|
|
|
create database mempool_liquidtestnet;
|
|
grant all on mempool_liquidtestnet.* to 'mempool_liquidtestnet'@'localhost' identified by 'mempool_liquidtestnet';
|
|
|
|
create database mempool_bisq;
|
|
grant all on mempool_bisq.* to 'mempool_bisq'@'localhost' identified by 'mempool_bisq';
|
|
_EOF_
|
|
|
|
##### nginx
|
|
|
|
echo "[*] Adding Nginx configuration"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
echo "[*] FIXME: nginx must be configured manually on FreeBSD"
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/nginx/nginx.conf" "${NGINX_CONFIGURATION}"
|
|
#echo "[*] Restarting Nginx"
|
|
#osSudo "${ROOT_USER}" service nginx restart
|
|
;;
|
|
esac
|
|
|
|
##### OS systemd
|
|
|
|
echo "[*] Updating systemd daemon configuration"
|
|
case $OS in
|
|
|
|
FreeBSD)
|
|
;;
|
|
|
|
Debian)
|
|
osSudo "${ROOT_USER}" systemctl daemon-reload
|
|
if [ "${TOR_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable tor.service
|
|
fi
|
|
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable bitcoin.service
|
|
fi
|
|
if [ "${BITCOIN_MAINNET_MINFEE_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable bitcoin-minfee.service
|
|
fi
|
|
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable bitcoin-testnet.service
|
|
fi
|
|
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable bitcoin-signet.service
|
|
fi
|
|
if [ "${BISQ_MAINNET_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable bisq.service
|
|
fi
|
|
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
osSudo "${ROOT_USER}" systemctl enable liquid.service
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
##### OS services
|
|
|
|
#if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
|
|
# echo "[*] Starting Bitcoin Mainnet"
|
|
# case $OS in
|
|
#
|
|
# FreeBSD)
|
|
# osSudo "${ROOT_USER}" service bitcoin onestart
|
|
# osSudo "${BITCOIN_USER}" sh -c "grep @reboot ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.crontab|cut -d ';' -f2|zsh"
|
|
# ;;
|
|
#
|
|
# Debian)
|
|
# osSudo "${ROOT_USER}" systemctl start bitcoin
|
|
# osSudo "${ROOT_USER}" systemctl start electrs
|
|
# osSudo "${ROOT_USER}" journalctl --no-pager --unit bitcoin
|
|
# ;;
|
|
# esac
|
|
#fi
|
|
#
|
|
#if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
|
|
# echo "[*] Starting Bitcoin Mainnet"
|
|
# case $OS in
|
|
#
|
|
# FreeBSD)
|
|
# ;;
|
|
#
|
|
# Debian)
|
|
# echo "[*] Starting Bitcoin Testnet"
|
|
# osSudo "${ROOT_USER}" systemctl start bitcoin-testnet
|
|
# osSudo "${ROOT_USER}" systemctl start electrs-testnet
|
|
# osSudo "${ROOT_USER}" journalctl --no-pager --unit bitcoin-testnet
|
|
# esac
|
|
#fi
|
|
#if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
|
|
# case $OS in
|
|
#
|
|
# FreeBSD)
|
|
# echo "[*] Starting Elements Liquid"
|
|
# osSudo "${ELEMENTS_USER}" sh -c "grep @reboot ${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/elements.crontab|cut -d ';' -f2|zsh"
|
|
# ;;
|
|
#
|
|
# Debian)
|
|
# echo "[*] Starting Elements Liquid"
|
|
# osSudo "${ROOT_USER}" systemctl start liquid
|
|
# osSudo "${ROOT_USER}" systemctl start electrs-liquid
|
|
# osSudo "${ROOT_USER}" journalctl --no-pager --unit liquid
|
|
# esac
|
|
#fi
|
|
|
|
#osSudo "${ROOT_USER}" tail "${BITCOIN_HOME}/debug.log"
|
|
|
|
##### OS notes
|
|
|
|
#echo "[*] Adding notes to motd"
|
|
#osSudo "${ROOT_USER}" sh -c 'echo " " >> /etc/motd'
|
|
|
|
##### OS firewall
|
|
|
|
#case $OS in
|
|
#
|
|
# FreeBSD)
|
|
# ;;
|
|
#
|
|
# Debian)
|
|
# echo "[*] Preparing firewall"
|
|
# osSudo "${ROOT_USER}" ufw default deny incoming
|
|
# osSudo "${ROOT_USER}" ufw default allow outgoing
|
|
# osSudo "${ROOT_USER}" ufw allow from any to any port ${BITCOIN_MAINNET_P2P_PORT} proto tcp
|
|
# osSudo "${ROOT_USER}" ufw allow from any to any port ${BITCOIN_TESTNET_P2P_PORT} proto tcp
|
|
# osSudo "${ROOT_USER}" ufw allow from any to any port ${ELEMENTS_LIQUID_P2P_PORT} proto tcp
|
|
# ;;
|
|
#esac
|
|
|
|
##### finish
|
|
|
|
echo '[*] Done!'
|
|
|
|
exit 0
|