#!/bin/bash # Set up a Decred node. # # Debian or Ubuntu AMD64 (x86_64) server/VPS recommended. # # To use run: # curl -L https://node.dcr.pw | bash # # Check it's running with: # systemctl status dcrd # # Or run decred.sh to view the output of dcrd.log in real-time. # Check permissions. if [ "$(id -u)" != "0" ]; then echo "This script must be run as root." sudo bash "$0" exit fi # Function to log messages. log_message() { echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a /var/log/decred_setup.log } log_message "Starting Decred node setup..." # Set CPU architecture, Decred version, binaries archive name, and logo. arch=$(uname -m) case "$arch" in 'x86_64') a='amd64';; 'aarch64') a='arm64';; 'armv7l') a='arm';; *) log_message "Unsupported architecture: $arch"; exit 1;; esac v='v2.0.5' b="decred-linux-${a}-${v}.tar.gz" l=$(base64 -d <<<"H4sIAAAAAAAAA52TP2/DIBDFd3+K2xiKL1WlLlBlSccOVdTN6lABSiKhUBmS+uM3/DPYjtqmbzIIfvf87mhgFGaNG7QIYab2D2oqOGfCi2cQ0bLIlP2gDp6V6JWEo5EKrPtwJzur/95Mlkgjn5HMFwU/DFIUfgdS9BLOD3iPj/Pfugr3uITPQWBYa5PwvMB/1QKOlLOIn8UQMhqGIdM72Dv3adlqJUM8aPrdj3AkLGuaThCL3v/p/NLRIE4pSarNY0weM7yF7ekIybfdgzNwPqiv0AvUZjeBI+eevpy6pNTb0XkLr72yFp42b9uXNdxdPta+ghoObuGcci96nYzcRHbJ/KZYIryOGVNr07D4aR9r3/iISIBPZ4Rqk+TRmtctimY4mQ6VSOc1xfpwgvtoqjvII18znD24cj7cyTWyH4GLN4RI6JUbyZAUpPkGLCU5/o4EAAA=" | gunzip) # Show logo. printf "%s\n\n" "$l" # Download Decred binaries archive. log_message "Downloading Decred binaries..." curl -L -o "$b" "https://github.com/decred/decred-binaries/releases/download/${v}/${b}" if [ $? -ne 0 ]; then log_message "Failed to download Decred binaries." exit 1 fi # Extract Decred binaries. log_message "Extracting Decred binaries..." tar -xf "$b" --strip-components=1 -C /usr/local/bin/ if [ $? -ne 0 ]; then log_message "Failed to extract Decred binaries." exit 1 fi # Stop existing dcrd instance if running. if systemctl is-active --quiet dcrd.service; then log_message "Stopping existing dcrd service..." sudo systemctl stop dcrd.service fi # Create dcrd service. log_message "Creating dcrd service..." sudo bash -c 'cat > /etc/systemd/system/dcrd.service < /usr/local/bin/decred.sh <<'EOF' #!/bin/bash printf "%s\n\n" "$l" sudo tail -f /root/.dcrd/logs/mainnet/dcrd.log EOF chmod +x /usr/local/bin/decred.sh # Cleanup temporary files. log_message "Cleaning up temporary files..." rm -f "$b" log_message "Installation complete." printf "\n**********\nInstallation complete, enjoy your new Decred node! \nYou can monitor its status by using the decred.sh command.\n**********\n\n"