Skip to content

Build

We're now going to discuss how to build Khatru Pyramid.

Dependencies

Before building the binary, we need to install Go and Git.

We need to install Git to be able to clone the Khatru Pyramid repository:

apt install git

We're now going to discuss how to install Go on your relay.

First, you need to determine which version of Go you want to install which you can do by going to the All releases page on the Go website.

Make sure to choose the appropriate download file for your relay's operating system (OS) and architecture. Since we're using Debian with an AMD processor, we're going to download the linux-amd64 file.

At the time of writing the current version of Go is 1.23.2, so we'll be downloading the go1.23.2.linux-amd64.tar.gz file.

We'll be downloading the file to the /tmp directory which is cleared when the system reboots. We’ll be downloading the file here because we won’t need this file after the installation process is completed.

Since we're using a headless server, we can use the wget command to download Go:

wget -P /tmp https://go.dev/dl/go1.23.2.linux-amd64.tar.gz

Be sure to replace go1.23.2.linux-amd64.tar.gz with whatever version of Go you're downloading and with whatever architecture you're using.

Before extracting the contents of the file, be sure to first remove any previously installed version of Go:

rm -rf /usr/local/go

You can now extract the contents of the file into the /usr/local directory:

tar -C /usr/local -xzf /tmp/go1.23.2.linux-amd64.tar.gz

Be sure to not extract the contents into an already existing /usr/local/go directory since this can break the Go installation.

After successfully extracting the contents, you should see a go directory in the /usr/local directory:

ls /usr/local

You can now add /usr/local/go/bin to the PATH environment variable by adding export PATH=$PATH:/usr/local/go/bin to your $HOME/.bashrc file.

First open the file with a text editor of your choice, e.g., nano:

nano $HOME/.bashrc

Then add the following to the end of the file:

export PATH=$PATH:/usr/local/go/bin

Save the changes made to the .bashrc file and exit the editor.

The changes may not take effect until after you log back into the server.

To apply the changes immediately run:

source $HOME/.bashrc

Verify the installation was successful by running:

go version

The command should output:

go version go1.23.2 linux/amd64

Clone the Repository

We'll be downloading the repository to the /tmp directory since it's cleared when the system reboots, and we don't need the files associated with the installation of Khatru Pyramid after the installation process is completed.

Navigate to the /tmp directory:

cd /tmp

If you want to keep the Khatru Pyramid repository on your relay, then you can download the repository in a persistent directory, e.g., your $HOME directory.

We're now ready to clone the Khatru Pyramid repository:

git clone https://github.com/github-tijlxyz/khatru-pyramid.git

After cloning the repository, navigate to the khatru-pyramid directory:

cd khatru-pyramid

Build Khatru Pyramid

We're now ready to build Khatru Pyramid:

go build

The compilation could take a while depending on your server's specs, so be patient while the binary is being built.

When the compilation is finished the binary will be located in the khatru-pyramid directory.

You can list out the contents of that directory to see the binary:

ls

You should see the binary file which should be named khatru-pyramid.

Version

At the time of writing, the latest version of Khatru Pyramid is v0.1.0 which is what the rest of the guide is currently based on.

Run Binary

You can now run the binary:

DOMAIN="relay.relayrunner.xyz" RELAY_NAME="Relay Runner's Khatru Pyramid Relay" RELAY_PUBKEY="3bcbb0f7dea9da9f5b2659ca5da89d5e576215de3885e51bd2474dd1b0c44b16" ./khatru-pyramid

Khatru Pyramid should now be listening on 0.0.0.0:3334. A relay database will be created in your current directory called db along with a file for storing user data called users.json.

To stop the relay press Ctrl+C.