Additional tweaks to seednode installation script for new use cases (#3944)

* Add seednode service option to enable dumping Bisq Markets data

* Add seednode service setting for DAO fullnode true/false

* Add seednode installer feature to use existing btcnode P2P/RPC config

* Rename to generic "bisq" service, set entrypoint as conf variable
This commit is contained in:
wiz 2020-02-07 22:41:35 +09:00 committed by GitHub
parent 9590905ad5
commit d3f30b8b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 67 deletions

View File

@ -40,10 +40,10 @@ After installation, watch the Bitcoin blockchain sync progress
sudo tail -f /bitcoin/debug.log
```
After Bitcoin is fully synced, start the bisq-seednode service
After Bitcoin is fully synced, start the bisq service
```bash
sudo systemctl start bisq-seednode
sudo journalctl --unit bisq-seednode --follow
sudo systemctl start bisq
sudo journalctl --unit bisq --follow
```
After Bisq is fully synced, check your Bitcoin and Bisq onion hostnames:
@ -54,7 +54,7 @@ sudo cat /bisq/bisq-seednode/btc_mainnet/tor/hiddenservice/hostname
### Testing
After your Bisq seednode is ready, test it by connecting to your new btcnode and bisq-seednode!
After your Bisq seednode is ready, test it by connecting to your new btcnode and bisq!
macOS:
```bash
@ -72,8 +72,8 @@ git checkout v1.2.5 # new tag
./gradlew clean
./gradlew build -x test
exit
sudo service bisq-seednode restart
sudo journalctl --unit bisq-seednode --follow
sudo service bisq restart
sudo journalctl --unit bisq --follow
```
### Uninstall

View File

@ -1,5 +1,5 @@
# env for bisq-seednode service
# install in /etc/default/bisq-seednode
# configuration for bisq service
# install in /etc/default/bisq.env
# java home, set to openjdk 10
JAVA_HOME=/usr/lib/jvm/openjdk-10.0.2
@ -8,28 +8,35 @@ JAVA_HOME=/usr/lib/jvm/openjdk-10.0.2
JAVA_OPTS="-Xms4096M -Xmx4096M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jmxremote.rmi.port=6969 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# bitcoin rpc credentials
BITCOIN_RPC_USERNAME=__BITCOIN_RPC_USER__
BITCOIN_RPC_PASSWORD=__BITCOIN_RPC_PASS__
BITCOIN_RPC_USER=__BITCOIN_RPC_USER__
BITCOIN_RPC_PASS=__BITCOIN_RPC_PASS__
# bitcoin p2p settings
BITCOIN_P2P_HOST=127.0.0.1
BITCOIN_P2P_PORT=8333
BITCOIN_P2P_HOST=__BITCOIN_P2P_HOST__
BITCOIN_P2P_PORT=__BITCOIN_P2P_PORT__
# bitcoind rpc ports
BITCOIN_RPC_HOST=127.0.0.1
BITCOIN_RPC_PORT=8332
BITCOIN_RPC_HOST=__BITCOIN_RPC_HOST__
BITCOIN_RPC_PORT=__BITCOIN_RPC_PORT__
BITCOIN_RPC_BLOCKNOTIFY_HOST=127.0.0.1
BITCOIN_RPC_BLOCKNOTIFY_PORT=5120
# bisq seednode pathnames
# bisq pathnames
BISQ_HOME=__BISQ_HOME__
BISQ_APP_NAME=bisq-seednode
BISQ_ENTRYPOINT=bisq-seednode
BISQ_BASE_CURRENCY=btc_mainnet
# bisq seednode settings
# bisq node settings
BISQ_NODE_PORT=8000
BISQ_MAX_CONNECTIONS=50
BISQ_MAX_MEMORY=4000
# set to true for BSQ seednode
BISQ_DAO_FULLNODE=true
# set to true for BSQ explorer
BISQ_DUMP_BLOCKCHAIN=false
# set to true for BSQ markets
BISQ_DUMP_STATISTICS=false

View File

@ -1,16 +1,16 @@
# install in /etc/systemd/system/bisq-seednode.service
# install in /etc/systemd/system/bisq.service
[Unit]
Description=Bisq Seed Node
Description=Bisq Node
After=bitcoin.service
Requires=bitcoin.service
BindsTo=bitcoin.service
#Requires=bitcoin.service
#BindsTo=bitcoin.service
[Service]
EnvironmentFile=/etc/default/bisq-seednode.env
EnvironmentFile=/etc/default/bisq.env
ExecStart=__BISQ_HOME__/__BISQ_REPO_NAME__/bisq-seednode \
--fullDaoNode=true \
ExecStart=/bin/sh __BISQ_HOME__/__BISQ_REPO_NAME__/${BISQ_ENTRYPOINT} \
--fullDaoNode=${BISQ_DAO_FULLNODE} \
--userDataDir=${BISQ_HOME} \
--appName=${BISQ_APP_NAME} \
--baseCurrencyNetwork=${BISQ_BASE_CURRENCY} \
@ -22,9 +22,10 @@ ExecStart=__BISQ_HOME__/__BISQ_REPO_NAME__/bisq-seednode \
--rpcBlockNotificationPort=${BITCOIN_RPC_BLOCKNOTIFY_PORT} \
--rpcHost=${BITCOIN_RPC_HOST} \
--rpcPort=${BITCOIN_RPC_PORT} \
--rpcUser=${BITCOIN_RPC_USERNAME} \
--rpcPassword=${BITCOIN_RPC_PASSWORD} \
--rpcUser=${BITCOIN_RPC_USER} \
--rpcPassword=${BITCOIN_RPC_PASS} \
--dumpBlockchainData=${BISQ_DUMP_BLOCKCHAIN} \
--dumpStatistics=${BISQ_DUMP_STATISTICS} \
ExecStop=/bin/kill -9 ${MAINPID}
Restart=on-failure

View File

@ -20,6 +20,9 @@ BISQ_LATEST_RELEASE=$(curl -s https://api.github.com/repos/bisq-network/bisq/rel
BISQ_HOME=/bisq
BISQ_USER=bisq
# by default, this script will build and setup bitcoin fullnode
# if you want to use an existing bitcoin fullnode, see next section
BITCOIN_INSTALL=true
BITCOIN_REPO_URL=https://github.com/bitcoin/bitcoin
BITCOIN_REPO_NAME=bitcoin
BITCOIN_REPO_TAG=$(curl -s https://api.github.com/repos/bitcoin/bitcoin/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
@ -27,6 +30,19 @@ BITCOIN_HOME=/bitcoin
BITCOIN_USER=bitcoin
BITCOIN_GROUP=bitcoin
BITCOIN_PKG="libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb-dev libssl-dev"
BITCOIN_P2P_HOST=127.0.0.1
BITCOIN_P2P_PORT=8333
BITCOIN_RPC_HOST=127.0.0.1
BITCOIN_RPC_PORT=8332
# set below settings to use existing bitcoin node
#BITCOIN_INSTALL=false
#BITCOIN_P2P_HOST=192.168.1.1
#BITCOIN_P2P_PORT=8333
#BITCOIN_RPC_HOST=192.168.1.1
#BITCOIN_RPC_PORT=8332
#BITCOIN_RPC_USER=foo
#BITCOIN_RPC_PASS=bar
TOR_PKG="tor"
TOR_USER=debian-tor
@ -54,39 +70,43 @@ sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get install -qq
echo "[*] Installing Tor configuration"
sudo -H -i -u "${ROOT_USER}" install -c -m 644 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/torrc" "${TOR_HOME}/torrc"
echo "[*] Creating Bitcoin user with Tor access"
sudo -H -i -u "${ROOT_USER}" useradd -d "${BITCOIN_HOME}" -G "${TOR_GROUP}" "${BITCOIN_USER}"
if [ "${BITCOIN_INSTALL}" = true ];then
echo "[*] Installing Bitcoin build dependencies"
sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get install -qq -y ${BITCOIN_PKG}
echo "[*] Creating Bitcoin user with Tor access"
sudo -H -i -u "${ROOT_USER}" useradd -d "${BITCOIN_HOME}" -G "${TOR_GROUP}" "${BITCOIN_USER}"
echo "[*] Creating Bitcoin homedir"
sudo -H -i -u "${ROOT_USER}" mkdir "${BITCOIN_HOME}"
sudo -H -i -u "${ROOT_USER}" chown "${BITCOIN_USER}":"${BITCOIN_GROUP}" ${BITCOIN_HOME}
sudo -H -i -u "${BITCOIN_USER}" ln -s . .bitcoin
echo "[*] Installing Bitcoin build dependencies"
sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get install -qq -y ${BITCOIN_PKG}
echo "[*] Cloning Bitcoin repo"
sudo -H -i -u "${BITCOIN_USER}" git config --global advice.detachedHead false
sudo -H -i -u "${BITCOIN_USER}" git clone --branch "${BITCOIN_REPO_TAG}" "${BITCOIN_REPO_URL}" "${BITCOIN_HOME}/${BITCOIN_REPO_NAME}"
echo "[*] Creating Bitcoin homedir"
sudo -H -i -u "${ROOT_USER}" mkdir "${BITCOIN_HOME}"
sudo -H -i -u "${ROOT_USER}" chown "${BITCOIN_USER}":"${BITCOIN_GROUP}" ${BITCOIN_HOME}
sudo -H -i -u "${BITCOIN_USER}" ln -s . .bitcoin
echo "[*] Building Bitcoin from source"
sudo -H -i -u "${BITCOIN_USER}" sh -c "cd ${BITCOIN_REPO_NAME} && ./autogen.sh --quiet && ./configure --quiet --disable-wallet --with-incompatible-bdb && make -j9"
echo "[*] Cloning Bitcoin repo"
sudo -H -i -u "${BITCOIN_USER}" git config --global advice.detachedHead false
sudo -H -i -u "${BITCOIN_USER}" git clone --branch "${BITCOIN_REPO_TAG}" "${BITCOIN_REPO_URL}" "${BITCOIN_HOME}/${BITCOIN_REPO_NAME}"
echo "[*] Installing Bitcoin into OS"
sudo -H -i -u "${ROOT_USER}" sh -c "cd ${BITCOIN_HOME}/${BITCOIN_REPO_NAME} && make install >/dev/null"
echo "[*] Building Bitcoin from source"
sudo -H -i -u "${BITCOIN_USER}" sh -c "cd ${BITCOIN_REPO_NAME} && ./autogen.sh --quiet && ./configure --quiet --disable-wallet --with-incompatible-bdb && make -j9"
echo "[*] Installing Bitcoin configuration"
sudo -H -i -u "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 644 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/bitcoin.conf" "${BITCOIN_HOME}/bitcoin.conf"
sudo -H -i -u "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/blocknotify.sh" "${BITCOIN_HOME}/blocknotify.sh"
echo "[*] Installing Bitcoin into OS"
sudo -H -i -u "${ROOT_USER}" sh -c "cd ${BITCOIN_HOME}/${BITCOIN_REPO_NAME} && make install >/dev/null"
echo "[*] Generating Bitcoin RPC credentials"
BITCOIN_RPC_USER=$(head -150 /dev/urandom | md5sum | awk '{print $1}')
sudo sed -i -e "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_HOME}/bitcoin.conf"
BITCOIN_RPC_PASS=$(head -150 /dev/urandom | md5sum | awk '{print $1}')
sudo sed -i -e "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_HOME}/bitcoin.conf"
echo "[*] Installing Bitcoin configuration"
sudo -H -i -u "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 644 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/bitcoin.conf" "${BITCOIN_HOME}/bitcoin.conf"
sudo -H -i -u "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/blocknotify.sh" "${BITCOIN_HOME}/blocknotify.sh"
echo "[*] Installing Bitcoin init scripts"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/bitcoin.service" "${SYSTEMD_SERVICE_HOME}"
echo "[*] Generating Bitcoin RPC credentials"
BITCOIN_RPC_USER=$(head -150 /dev/urandom | md5sum | awk '{print $1}')
sudo sed -i -e "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_HOME}/bitcoin.conf"
BITCOIN_RPC_PASS=$(head -150 /dev/urandom | md5sum | awk '{print $1}')
sudo sed -i -e "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_HOME}/bitcoin.conf"
echo "[*] Installing Bitcoin init scripts"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${ROOT_HOME}/${BISQ_REPO_NAME}/seednode/bitcoin.service" "${SYSTEMD_SERVICE_HOME}"
fi
echo "[*] Creating Bisq user with Tor access"
sudo -H -i -u "${ROOT_USER}" useradd -d "${BISQ_HOME}" -G "${TOR_GROUP}" "${BISQ_USER}"
@ -103,15 +123,24 @@ echo "[*] Installing OpenJDK 10.0.2 from Bisq repo"
sudo -H -i -u "${ROOT_USER}" "${BISQ_HOME}/${BISQ_REPO_NAME}/scripts/install_java.sh"
echo "[*] Installing Bisq init script"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq-seednode.service" "${SYSTEMD_SERVICE_HOME}/bisq-seednode.service"
sudo sed -i -e "s/__BISQ_REPO_NAME__/${BISQ_REPO_NAME}/" "${SYSTEMD_SERVICE_HOME}/bisq-seednode.service"
sudo sed -i -e "s!__BISQ_HOME__!${BISQ_HOME}!" "${SYSTEMD_SERVICE_HOME}/bisq-seednode.service"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq.service" "${SYSTEMD_SERVICE_HOME}/bisq.service"
if [ "${BITCOIN_INSTALL}" = true ];then
sudo sed -i -e "s/#Requires=bitcoin.service/Requires=bitcoin.service/" "${SYSTEMD_SERVICE_HOME}/bisq.service"
sudo sed -i -e "s/#BindsTo=bitcoin.service/BindsTo=bitcoin.service/" "${SYSTEMD_SERVICE_HOME}/bisq.service"
fi
sudo sed -i -e "s/__BISQ_REPO_NAME__/${BISQ_REPO_NAME}/" "${SYSTEMD_SERVICE_HOME}/bisq.service"
sudo sed -i -e "s!__BISQ_HOME__!${BISQ_HOME}!" "${SYSTEMD_SERVICE_HOME}/bisq.service"
echo "[*] Installing Bisq environment file with Bitcoin RPC credentials"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq-seednode.env" "${SYSTEMD_ENV_HOME}/bisq-seednode.env"
sudo sed -i -e "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${SYSTEMD_ENV_HOME}/bisq-seednode.env"
sudo sed -i -e "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${SYSTEMD_ENV_HOME}/bisq-seednode.env"
sudo sed -i -e "s!__BISQ_HOME__!${BISQ_HOME}!" "${SYSTEMD_ENV_HOME}/bisq-seednode.env"
sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${BISQ_HOME}/${BISQ_REPO_NAME}/seednode/bisq.env" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_P2P_HOST__/${BITCOIN_P2P_HOST}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_P2P_PORT__/${BITCOIN_P2P_PORT}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_RPC_HOST__/${BITCOIN_RPC_HOST}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_RPC_PORT__/${BITCOIN_RPC_PORT}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s!__BISQ_APP_NAME__!${BISQ_APP_NAME}!" "${SYSTEMD_ENV_HOME}/bisq.env"
sudo sed -i -e "s!__BISQ_HOME__!${BISQ_HOME}!" "${SYSTEMD_ENV_HOME}/bisq.env"
echo "[*] Checking out Bisq ${BISQ_LATEST_RELEASE}"
sudo -H -i -u "${BISQ_USER}" sh -c "cd ${BISQ_HOME}/${BISQ_REPO_NAME} && git checkout ${BISQ_LATEST_RELEASE}"
@ -122,8 +151,10 @@ sudo -H -i -u "${BISQ_USER}" sh -c "cd ${BISQ_HOME}/${BISQ_REPO_NAME} && ./gradl
echo "[*] Updating systemd daemon configuration"
sudo -H -i -u "${ROOT_USER}" systemctl daemon-reload
sudo -H -i -u "${ROOT_USER}" systemctl enable tor.service
sudo -H -i -u "${ROOT_USER}" systemctl enable bisq-seednode.service
sudo -H -i -u "${ROOT_USER}" systemctl enable bitcoin.service
sudo -H -i -u "${ROOT_USER}" systemctl enable bisq.service
if [ "${BITCOIN_INSTALL}" = true ];then
sudo -H -i -u "${ROOT_USER}" systemctl enable bitcoin.service
fi
echo "[*] Preparing firewall"
sudo -H -i -u "${ROOT_USER}" ufw default deny incoming
@ -132,10 +163,12 @@ sudo -H -i -u "${ROOT_USER}" ufw default allow outgoing
echo "[*] Starting Tor"
sudo -H -i -u "${ROOT_USER}" systemctl start tor
echo "[*] Starting Bitcoin"
sudo -H -i -u "${ROOT_USER}" systemctl start bitcoin
sudo -H -i -u "${ROOT_USER}" journalctl --no-pager --unit bitcoin
sudo -H -i -u "${ROOT_USER}" tail "${BITCOIN_HOME}/debug.log"
if [ "${BITCOIN_INSTALL}" = true ];then
echo "[*] Starting Bitcoin"
sudo -H -i -u "${ROOT_USER}" systemctl start bitcoin
sudo -H -i -u "${ROOT_USER}" journalctl --no-pager --unit bitcoin
sudo -H -i -u "${ROOT_USER}" tail "${BITCOIN_HOME}/debug.log"
fi
echo "[*] Adding notes to motd"
sudo -H -i -u "${ROOT_USER}" sh -c 'echo " " >> /etc/motd'
@ -143,10 +176,10 @@ sudo -H -i -u "${ROOT_USER}" sh -c 'echo "Bisq Seednode instructions:" >> /etc/m
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "https://github.com/bisq-network/bisq/tree/master/seednode" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo " " >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "How to check logs for Bisq-Seednode service:" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "sudo journalctl --no-pager --unit bisq-seednode" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "sudo journalctl --no-pager --unit bisq" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo " " >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "How to restart Bisq-Seednode service:" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "sudo service bisq-seednode restart" >> /etc/motd'
sudo -H -i -u "${ROOT_USER}" sh -c 'echo "sudo service bisq restart" >> /etc/motd'
echo '[*] Done!'

View File

@ -3,9 +3,9 @@ echo "[*] Uninstalling Bitcoin and Bisq, will delete all data!!"
sleep 10
sudo rm -rf /root/bisq
sudo systemctl stop bitcoin
sudo systemctl stop bisq-seednode
sudo systemctl stop bisq
sudo systemctl disable bitcoin
sudo systemctl disable bisq-seednode
sudo systemctl disable bisq
sudo userdel -f -r bisq
sudo userdel -f -r bitcoin
echo "[*] Done!"