Skip to content

Instantly share code, notes, and snippets.

@colinrtwhite
Last active June 22, 2018 11:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinrtwhite/2fe662a68216b7ea3f929419e2e0e781 to your computer and use it in GitHub Desktop.
Save colinrtwhite/2fe662a68216b7ea3f929419e2e0e781 to your computer and use it in GitHub Desktop.
#!/bin/bash -i
### THIS IS A MODIFIED VERSION OF BEN GREEN'S SCRIPT LOCATED HERE:
### https://gist.githubusercontent.com/numtel/96dd51106f0e7e25c50dcf4a4f119499/raw/4d2cf0d17b26239b10050a0b35e6ed5646273a38/install_rai_node.sh
DATA_PATH="/home/$USER" # Change if desired, directory must exist!
DATA_DIRECTORY="RaiBlocks" # Determined by rai_node
sudo apt update
sudo apt upgrade
sudo apt install -y xz-utils p7zip
cd $DATA_PATH
# Download rai_node archive
# Update this URL with the latest from:
# https://github.com/clemahieu/raiblocks/releases
curl -L https://github.com/clemahieu/raiblocks/releases/download/V9.0/rai_node.xz > rai_node.xz
# Decompress rai_node
tar xf rai_node.xz
# Initialize data directory by running rai_node for 5 seconds
./rai_node --daemon --data_path="$DATA_PATH/$DATA_DIRECTORY"& PID=$!; sleep 5; kill $PID
# Decompress database
p7zip -d rai_db.7z
# Move database snapshot to data directory
mv data.ldb $DATA_PATH/$DATA_DIRECTORY/data.ldb
# replace RPC address in config.json for all interfaces
sed -i "s/\"address\": \"::1\"/\"address\": \"::ffff:0.0.0.0\"/g" "$DATA_PATH/$DATA_DIRECTORY/config.json"
# enable RPC in config.json
sed -i "s/\"rpc_enable\": \"false\"/\"rpc_enable\": \"true\"/g" "$DATA_PATH/$DATA_DIRECTORY/config.json"
# Create rai_node service
sudo touch /etc/systemd/system/rai_node.service
sudo chmod 664 /etc/systemd/system/rai_node.service
echo "[Unit]
Description=RaiBlocks node service
After=network.target
[Service]
ExecStart=$DATA_PATH/rai_node --daemon --data_path=\"$DATA_PATH/$DATA_DIRECTORY\"
Restart=on-failure
User=$NAME
Group=$(id -gn)
[Install]
WantedBy=multi-user.target" | sudo tee --append /etc/systemd/system/rai_node.service
# Enable on startup
sudo systemctl enable rai_node
# Start service
sudo service rai_node start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment