diff --git a/electrs/t1_electrs_on_RaspiBlitz.sh b/electrs/t1_electrs_on_RaspiBlitz.sh new file mode 100644 index 0000000..991930a --- /dev/null +++ b/electrs/t1_electrs_on_RaspiBlitz.sh @@ -0,0 +1,46 @@ +# Download and run this script on the RaspiBlitz: +# $ wget https://github.com/openoms/bitcoin-tutorials/raw/master/electrs/electrs_install_on_RaspiBlitz.sh && bash electrs_install_on_RaspiBlitz.sh + +# https://github.com/romanz/electrs/blob/master/doc/usage.md +echo "" +echo "***" +echo "Installing Rust - press 1 and [ENTER] when prompted" +echo "***" +echo "" +curl https://sh.rustup.rs -sSf | sh + +source $HOME/.cargo/env +sudo apt update +sudo apt install -y clang cmake # for building 'rust-rocksdb' + +echo "" +echo "***" +echo "Downloading and building electrs. This will take ~30 minutes" # ~22 min on an Odroid XU4 +echo "***" +echo "" +git clone https://github.com/romanz/electrs +cd electrs +cargo build --release + +echo "" +echo "***" +echo "The electrs database will be built in /mnt/hdd/electrs/testnetdb. Takes ~18 hours and ~50Gb diskspace" +echo "***" +echo "" + +sudo mkdir /mnt/hdd/electrs +sudo chown -R admin:admin /mnt/hdd/electrs +sudo ufw allow 60001 + +echo "Type the PASSWORD B of your RaspiBlitz followed by [ENTER]:" +read PASSWORD_B + +# Run with password B filled in: +cargo run --release -- -vvvv --index-batch-size=10 --jsonrpc-import --db-dir /mnt/hdd/electrs/testnetdb --cookie="raspibolt:$PASSWORD_B" --electrum-rpc-addr="0.0.0.0:60001" --network testnet --timestamp + +# to preserve settings: +# see https://github.com/romanz/electrs/blob/master/src/config.rs +# sudo nano $HOME/electrs/src/config.rs +# change the lines: +# 73: from: .takes_value(true), to: .default_value("raspibolt:PASSWORD B"), +# 132: from .default_value("Welcome to electrs (Electrum Rust Server)!") to your custom message \ No newline at end of file diff --git a/electrs/t2_electrs_systemd_service.sh b/electrs/t2_electrs_systemd_service.sh new file mode 100644 index 0000000..3fa6122 --- /dev/null +++ b/electrs/t2_electrs_systemd_service.sh @@ -0,0 +1,35 @@ +# Install the electrs systemd service. +# Prerequisite: 1_electrs_on_RaspiBlitz.sh + +# To download and run: +# $ wget https://raw.githubusercontent.com/openoms/bitcoin-tutorials/master/electrs/2_electrs_systemd_service.sh && bash 2_electrs_systemd_service.sh + +echo "" +echo "***" +echo "Type the PASSWORD B of your RaspiBlitz followed by [ENTER] for the electrs service:" +read PASSWORD_B + +# sudo nano /etc/systemd/system/electrs.service +echo " +[Unit] +Description=Electrs +After=bitcoind.service + +[Service] +WorkingDirectory=/home/admin/electrs +ExecStart=/home/admin/electrs/target/release/electrs --index-batch-size=10 --jsonrpc-import --db-dir /mnt/hdd/electrs/testnetdb --electrum-rpc-addr="0.0.0.0:60001" --cookie="raspibolt:$PASSWORD_B" --network testnet --timestamp -vvvv + +User=admin +Group=admin +Type=simple +KillMode=process +TimeoutSec=60 +Restart=always +RestartSec=60 + +[Install] +WantedBy=multi-user.target +" | sudo tee -a /etc/systemd/system/electrs.service + +sudo systemctl enable electrs +sudo systemctl start electrs \ No newline at end of file