Skip to content

Commit

Permalink
Standalone setup fixes (#153)
Browse files Browse the repository at this point in the history
* use bitcoin binary in /usr/local/bin/
* fix hostname and related warnings
* fix ownership of possibly migrated files
* build: fix fail2ban, remove boot drive tweak
* FAQ: remove outdated entries
  • Loading branch information
openoms authored May 22, 2024
1 parent e2e540c commit efad4a0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 96 deletions.
63 changes: 1 addition & 62 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,26 +567,7 @@ Alternatively to a pruned node there could be a larger >400 GB storage connected
# drwx------ 34 bitcoin bitcoin 4096 Dec 7 23:39 specter
# drwx------ 2 bitcoin bitcoin 4096 Mar 21 10:38 wallet.dat
installMainnet
# Failed to stop bitcoind.service: Unit bitcoind.service not loaded.
#
# [Unit]
# Description=Bitcoin daemon on mainnet
# [Service]
# User=bitcoin
# Group=bitcoin
# Type=forking
# PIDFile=/home/bitcoin/bitcoin/bitcoind.pid
# ExecStart=/home/bitcoin/bitcoin/bitcoind -daemon -pid=/home/bitcoin/bitcoin/bitcoind.pid
# Restart=always
# TimeoutSec=120
# RestartSec=30
# StandardOutput=null
# StandardError=journal
#
# [Install]
# WantedBy=multi-user.target
#
# Created symlink /etc/systemd/system/multi-user.target.wants/bitcoind.service → /etc/systemd/system/bitcoind.service.
...
# # OK - the bitcoind.service is now enabled
#
# # Installed Bitcoin Core version v0.21.0
Expand All @@ -604,48 +585,6 @@ Alternatively to a pruned node there could be a larger >400 GB storage connected
## IRC server settings
* See the most up to date configuration in:
https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/jmclient/jmclient/configure.py
* The latest setting with Tor enabled:
```
[MESSAGING:server1]
#host = irc.darkscience.net
channel = joinmarket-pit
port = 6697
usessl = true
#socks5 = false
socks5_host = localhost
socks5_port = 9050
#for tor
host = darkirc6tqgpnwd3blln3yfv5ckl47eg7llfxkmtovrv7c7iwohhb6ad.onion
socks5 = true
[MESSAGING:server2]
#host = irc.hackint.org
channel = joinmarket-pit
#port = 6697
#usessl = true
#socks5 = false
socks5_host = localhost
socks5_port = 9050
#for tor
host = ncwkrwxpq2ikcngxq3dy2xctuheniggtqeibvgofixpzvrwpa77tozqd.onion
port = 6667
usessl = false
socks5 = true
[MESSAGING:server3]
#host = agora.anarplex.net
channel = joinmarket-pit
#port = 14716
#usessl = true
#socks5 = false
socks5_host = localhost
socks5_port = 9050
#for tor
host = vxecvd6lc4giwtasjhgbrr3eop6pzq6i5rveracktioneunalgqlwfad.onion
port = 6667
usessl = false
socks5 = true
```

## Install JoinMarket without the QT GUI and dependencies
* Run the build script with the options `BRANCH` `GITHUBUSER` `without-qt`:
Expand Down
16 changes: 3 additions & 13 deletions build_joininbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ echo "
# https://github.com/${githubUser}/joininbox/tree/${wantedBranch}
# Press ENTER to confirm or CTRL+C to exit"
read key
read

echo
echo "###################################"
Expand Down Expand Up @@ -160,17 +160,6 @@ if [ "${baseimage}" = "raspios" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "$max_usb_current already in $configFile"
fi

# run fsck on sd root partition on every startup to prevent "maintenance login" screen
# see: https://github.com/rootzoll/raspiblitz/issues/782#issuecomment-564981630
# see https://github.com/rootzoll/raspiblitz/issues/1053#issuecomment-600878695
# use command to check last fsck check: sudo tune2fs -l /dev/mmcblk0p2
if [ "${tweak_boot_drive}" == "true" ]; then
echo "* running tune2fs"
tune2fs -c 1 /dev/mmcblk0p2
else
echo "* skipping tweak_boot_drive"
fi

# edit kernel parameters
kernelOptionsFile=/boot/cmdline.txt
fsOption1="fsck.mode=force"
Expand Down Expand Up @@ -485,7 +474,7 @@ deb-src [arch=${arch}] https://deb.torproject.org/torproject.org ${distro} main"
apt-get install -y build-essential fakeroot devscripts
apt-get build-dep -y tor deb.torproject.org-keyring
mkdir ~/debian-packages
cd ~/debian-packages
cd ~/debian-packages || exit 1
apt-get source tor
cd tor-* || exit 1
debuild -rfakeroot -uc -us
Expand Down Expand Up @@ -533,6 +522,7 @@ echo
apt-get install -y fail2ban ufw
# autostart fail2ban
systemctl enable fail2ban
touch /var/log/auth.log

# set up the firewall
ufw default deny incoming
Expand Down
3 changes: 3 additions & 0 deletions ci/amd64/debian/scripts/networking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ update-grub;

# Adding a 2 sec delay to the interface up, to make the dhclient happy
echo "pre-up sleep 2" >> /etc/network/interfaces

echo "$(hostname -I | awk '{print $1}') $(hostname)" >>/etc/hosts
echo "127.0.1.1 $(hostname)" >>/etc/hosts
3 changes: 2 additions & 1 deletion ci/arm64-rpi/arm64-rpi.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ build {
inline = [
"echo 'nameserver 1.1.1.1' >/etc/resolv.conf",
"echo 'nameserver 8.8.8.8' >>/etc/resolv.conf",
"echo $(hostname -I | awk '{print $1}') $(hostname) >>/etc/hosts",
"echo $(hostname -I | awk '{print $1}') $(hostname) >>/etc/hosts",
"echo 127.0.1.1 $(hostname) >>/etc/hosts",
"echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections",
"apt-get update",
"apt-get install -y sudo wget",
Expand Down
34 changes: 17 additions & 17 deletions scripts/standalone/_functions.standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ function downloadSnapShot() {

echo "# Unzip ..."
sudo apt-get install -y unzip
sudo -u bitcoin unzip -o $downloadFileName -d /home/store/app-data/.bitcoin
sudo -u bitcoin unzip -o $downloadFileName -d /home/store/app-data/.bitcoin || exit 1
echo "# OK - Decompressed successfully"
echo "# Removing the downloaded files"
rm -f $hashFileName
rm -f $downloadFileName
if sudo -u bitcoin ls /home/bitcoin/.bitcoin/bitcoin.conf.backup; then
echo "# Restore bitcoin.conf"
sudo -u bitcoin mv -f /home/bitcoin/.bitcoin/bitcoin.conf.backup \
Expand All @@ -151,8 +155,8 @@ function downloadSnapShot() {
function installBitcoinCoreStandalone() {
downloadBitcoinCore

if [ -f /home/bitcoin/bitcoin/bitcoind ]; then
installedVersion=$(/home/bitcoin/bitcoin/bitcoind --version | grep version)
if [ -f /usr/local/bin/bitcoind ]; then
installedVersion=$(/usr/local/bin/bitcoind --version | grep version)
echo "${installedVersion} is already installed"
else
echo "# Adding the user: bitcoin"
Expand All @@ -162,15 +166,10 @@ function installBitcoinCoreStandalone() {
echo "# Add the joinmarket user to the bitcoin group"
sudo usermod -aG bitcoin joinmarket
echo "# Installing Bitcoin Core v${bitcoinVersion}"
sudo -u bitcoin mkdir -p /home/bitcoin/bitcoin
cd /home/joinmarket/download/bitcoin-${bitcoinVersion}/bin/ || exit 1
sudo install -m 0755 -o root -g root -t /home/bitcoin/bitcoin ./*
sudo install -m 0755 -o root -g root -t /usr/local/bin/ ./*
fi
if [ "$(grep -c "/home/bitcoin/bitcoin" </etc/profile)" -eq 0 ]; then
echo "# Add /home/bitcoin/bitcoin to global PATH"
echo "PATH=/home/bitcoin/bitcoin:$PATH" | sudo tee -a /etc/profile
fi
if ! sudo -u bitcoin /home/bitcoin/bitcoin/bitcoind --version | grep "Bitcoin Core version"; then
if ! sudo -u bitcoin /usr/local/bin/bitcoind --version | grep "Bitcoin Core version"; then
echo
echo "# BUILD FAILED --> Was not able to install Bitcoin Core)"
exit 1
Expand Down Expand Up @@ -223,9 +222,10 @@ Description=Bitcoin daemon on mainnet
[Service]
Environment='MALLOC_ARENA_MAX=1'
PIDFile=/home/bitcoin/bitcoin/bitcoind.pid
ExecStart=/home/bitcoin/bitcoin/bitcoind -daemon \\
-pid=/home/bitcoin/bitcoin/bitcoind.pid
ExecStart=/usr/local/bin/bitcoind \\
-daemonwait \\
-conf=/home/bitcoin/.bitcoin/bitcoin.conf \\
-datadir=/home/bitcoin/.bitcoin
PermissionsStartOnly=true
# Process management
Expand Down Expand Up @@ -270,10 +270,10 @@ WantedBy=multi-user.target

# add aliases
if ! grep "alias bitcoin-cli" /home/joinmarket/_aliases.sh; then
sudo bash -c "echo 'alias bitcoin-cli=\"sudo -u bitcoin /home/bitcoin/bitcoin/bitcoin-cli\"' >> /home/joinmarket/_aliases.sh"
sudo bash -c "echo 'alias bitcoin-cli=\"sudo -u bitcoin /usr/local/bin/bitcoin-cli\"' >> /home/joinmarket/_aliases.sh"
fi
if ! grep "alias bitcoind" /home/joinmarket/_aliases.sh; then
sudo bash -c "echo 'alias bitcoind=\"sudo -u bitcoin /home/bitcoin/bitcoin/bitcoind\"' >> /home/joinmarket/_aliases.sh"
sudo bash -c "echo 'alias bitcoind=\"sudo -u bitcoin /usr/local/bin/bitcoind\"' >> /home/joinmarket/_aliases.sh"
fi
if ! grep "alias bitcoinlog" /home/joinmarket/_aliases.sh; then
sudo bash -c "echo 'alias bitcoinlog=\"sudo tail -f /home/bitcoin/.bitcoin/debug.log\"' >> /home/joinmarket/_aliases.sh"
Expand All @@ -287,14 +287,14 @@ WantedBy=multi-user.target

sudo systemctl start bitcoind
echo
echo "# Installed $(sudo -u bitcoin /home/bitcoin/bitcoin/bitcoind --version | grep version)"
echo "# Installed $(sudo -u bitcoin /usr/local/bin/bitcoind --version | grep version)"
echo
echo "# Monitor the bitcoind with: sudo tail -f /home/bitcoin/.bitcoin/mainnet/debug.log"
echo

if [ ! -f /home/bitcoin/.bitcoin/mainnet/wallets/wallet.dat/wallet.dat ]; then
echo "# Create wallet.dat ..."
sleep 10
sudo -u bitcoin /home/bitcoin/bitcoin/bitcoin-cli -named createwallet wallet_name=wallet.dat descriptors=false
sudo -u bitcoin /usr/local/bin/bitcoin-cli -named createwallet wallet_name=wallet.dat descriptors=false
fi
}
6 changes: 3 additions & 3 deletions scripts/standalone/bitcoin.update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ elif [ "$(uname -m | grep -c 'x86_64')" -gt 0 ]; then
fi

# installed version
installedVersion=$(sudo -u bitcoin /home/bitcoin/bitcoin/bitcoind --version | head -n1 | cut -d" " -f4 | cut -c 2-)
installedVersion=$(sudo -u bitcoin /usr/local/bin/bitcoind --version | head -n1 | cut -d" " -f4 | cut -c 2-)

# test if the installed version already the tested/recommended update version
bitcoinUpdateInstalled=$(echo "${installedVersion}" | grep -c "${bitcoinVersion}")
Expand Down Expand Up @@ -202,9 +202,9 @@ if [ "${mode}" = "tested" ] || [ "${mode}" = "reckless" ] || [ "${mode}" = "cust
echo
echo "# Installing Bitcoin Core v${bitcoinVersion}"
tar -xvf ${binaryName}
sudo install -m 0755 -o root -g root -t /home/bitcoin/bitcoin/ bitcoin-${bitcoinVersion}/bin/*
sudo install -m 0755 -o root -g root -t /usr/local/bin/ bitcoin-${bitcoinVersion}/bin/*
sleep 3
if ! sudo /home/bitcoin/bitcoin/bitcoind --version | grep "${bitcoinVersion}"; then
if ! sudo /usr/local/bin/bitcoind --version | grep "${bitcoinVersion}"; then
echo
echo "# BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions scripts/standalone/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ echo "***********************************************" >> $logFile

# make sure SSH server is configured & running
sudo /home/joinmarket/standalone/ssh.sh checkrepair >> ${logFile}

# fix ownership of possibly migrated files
sudo chown -R bitcoin:bitcoin /home/bitcoin/
sudo chown -R joinmarket:joinmarket /home/joinmarket/

0 comments on commit efad4a0

Please sign in to comment.