How to Install the CLI Node and Setup Autostart

In case that you want to clean the build directory to save some space on your Pi it may make sense to install the Beam node and the CLI wallet in another directory and add this to the system search path. Of course, you also can copy it manually and use it as described in my cloud vm article.

Use the following lines to create a new directory for your beam stuff in your home directory and copy the relevant files over to this directory.

sudo mkdir -p opt/beam

sudo chown pi:pi opt/beam cp ~/beam/{beam/beam-node,wallet/beam-wallet} /opt/beam

Besides the executables, we will also create a directory for the configuration files and the node data within our home directory.

mkdir -p ~/.local/share/beam cp ~/beam/{beam/beam-node.cfg,wallet/beam-wallet.cfg} ~/.local/share/beam

The relevant files are now copied to the new directory and you can clean up the sources — unless you want to build the GUI wallet as well (see below!).

Now we will tell the system about the new locations of the executables as well as the configurations. Type

geany /home/pi/.bashrc

and scroll down the file. At the bottom add the following lines:

export PATH=/opt/beam:$PATH function BeamNode {

pushd ~/.local/share/beam

beam-node $@

popd

} function BeamCLIWallet {

pushd ~/.local/share/beam

beam-node $@

popd

}

Close the text editor and type

source ./.bashrc

Now — and whenever you open your console later — your system will know the two commands “BeamNode” and “BeamCLIWallet” and switch to the right working directories automatically — and come back to your current working directory when done.



The corresponding configuration files for your node can be accessed by typing

geany /home/pi/.local/share/beam/beam-node.cfg

for the node configuration. To run the node in a very basic configuration its needed to change just two lines. First head out for line 25, which is

# peer=

and change it to

peer=eu-nodes.mainnet.beam.mw:8100

You also can pick any other Beam node to start your sync with. A list with known and trusted nodes can be found here.

Furthermore to enable fast syncing — which saves space and CPU time on your Raspberry-Pi add the line

fast_sync=1

to the bottom of the file. Then you already could start your node and strengthen the Beam network. Other options are only required in case you want to connect your own wallet or want to solo mine with your node.

Configure your node for your needs and type in “BeamNode” to start it for its first sync. This will take several hours and also will put a lot of load to the CPU. Best do this overnight but do not worry: once the node is fully synced the system load of the running node is almost zero.

Still not enough? It would be cool to start the node on each reboot in the background to keep it always on and synced, right? Ok, let’s do so!

For this task, we will install tmux that allows us to start a console program on boot-up and get the command line to front in case we need it.

sudo apt-get install tmux

Once this is done we will create a cron job that will launch our beam node on each boot-up. Type in

geany /opt/beam/beam.cron

to open the text editor and copy in the following lines.

#!/bin/bash

sleep 5

/usr/bin/tmux new-session -d -s beamSession ‘/bin/bash’

/usr/bin/tmux send-keys -t beamSession “source /home/pi/.bashrc” C-m

/usr/bin/tmux send-keys -t beamSession “BeamNode” C-m

Save the file and close the editor. Note that we did set a sleep time of 5 seconds before the node is supposed to start after reboot. This is to allow the system to establish the network connection first. Also starting multiple tmux instances at the same time may cause problems, so if you want to start multiple programs (e.g. a CLI wallet) by this method I recommend to set different sleeping times.

Now we will make cron aware of this file. Type in

crontab -e

In case you never did so till now you will be asked a question about the editor to use. Hit 1, so nano will be used.

Navigate with the arrow keys to the bottom of the file and insert the following line

Then hit ctrl+o to save the file and crtl+x to close the editor. Now on every boot, the system will start your beam node in a separate session. When you open the command line you can see the running session by typing

tmux attach-session -t beamSession

Do this on your first reboot to ensure everything is working. If not it is likely that some aspects are missing in the configuration file — I assume that the node is completely configured by this file and does not require additional command line parameters.