The easiest and most efficient way to set up a master node is by using Docker. Follow these two simple steps to set up a master node with Docker. We have provided a shell script to handle all the heavy lifting for you.
Note: This guide assumes some familiarity with the command line and running a Linux server. For a more detailed walkthrough, check out our full Master Node setup guide.
Step 1 : Create or Download the shell file
Copy the below code to a shell file master-node-deploy.sh
#!/bin/bash# Define the Docker image and container nameIMAGE_NAME="beldex/beldex-master-node:v1"CONTAINER_NAME="beldex-mn-node"SERVICE_NAME="beldex-testnet-storage-server.service"# Run the Docker containerecho"Running the Docker container..."dockerrun--network=host--privileged--name $CONTAINER_NAME -v/sys/fs/cgroup:/sys/fs/cgroup:ro-d $IMAGE_NAME# Give Docker a moment to start the containersleep5# Fetch the container ID for the given container nameCONTAINER_ID=$(dockerps-q--filtername=$CONTAINER_NAME)# Check if any container ID is foundif [ -z"$CONTAINER_ID" ]; thenecho"No running container found with name: $CONTAINER_NAME"exit1elseecho"Container ID for container $CONTAINER_NAME: $CONTAINER_ID"fi# Define the script to update the belnet.ini fileUPDATE_SCRIPT=$(cat<<'EOF'IP=$(curl -sS http://api.ipify.org || true)echo "IP for belnet: $IP"# Update the beldex.conf filesed -i -e "s/^master-node-public-ip=.*/master-node-public-ip=$IP/" /etc/beldex/beldex.confPRIVATE_IP=$(ip route get 1.2.3.4 | awk '{print $7}')echo "PRIVATE_IP for belnet: $PRIVATE_IP"sed -i -e "s/^public-ip=.*/public-ip=$IP/" /var/lib/belnet/router/belnet.inised -i -e "s/^[[:space:]]*inbound=.*/ inbound=$PRIVATE_IP/" /var/lib/belnet/router/belnet.iniEOF)# Execute the update script inside the Docker containerecho"Updating the belnet.ini,beldex.conf file inside the Docker container..."dockerexec $CONTAINER_ID bash-c"$UPDATE_SCRIPT"# Confirm the updateif [ $? -eq0 ]; thenecho"belnet.ini,beldex.conf file inside container $CONTAINER_NAME with ID $CONTAINER_ID has been updated successfully."elseecho"Failed to update belnet.ini,beldex.conf file inside container $CONTAINER_NAME with ID $CONTAINER_ID."exit1fi# stop the service inside the Docker containerecho"Stop the service inside the Docker container..."dockerexec-it $CONTAINER_ID systemctlstop $SERVICE_NAME# Confirm the service restartif [ $? -eq0 ]; thenecho"Service $SERVICE_NAME inside container $CONTAINER_NAME with ID $CONTAINER_ID has been stoped successfully."elseecho"Failed to stop service $SERVICE_NAME inside container $CONTAINER_NAME with ID $CONTAINER_ID."exit1fi
Make sure the node is fully synced before run this command
Check the node status
docker exec -it <CONTAINER_ID> beldexd status
You should receive an output similar to the screenshot provided. Ensure that the height of your node matches the current network height, which can be verified at Beldex Explorer. If the heights do not match, allow the node to fully sync, which may take 4-5 hours.
Prepare for Registration
Once the node is fully synced, run the below command to register the master node
After successfully running the command, you will receive an output similar to the screenshot below. To complete the registration, execute the master node command from the output in your wallet.
You can run all beldexd commands using docker. Run docker exec -it <CONTAINER_ID> beldexd --help to get the list of commands