|
#!/bin/bash -i |
|
DATA_PATH="/home/$USER" # Change if desired, directory must exist! |
|
DATA_DIRECTORY="RaiBlocks" # Determined by rai_node |
|
|
|
sudo apt update |
|
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 |
|
|
|
|
|
# Download Google Drive Client |
|
# Update this URL with the latest gdrive-linux-x64 version from: |
|
# https://github.com/prasmussen/gdrive#downloads |
|
wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA&export=download |
|
|
|
# Initialize data directory by running rai_node for 5 seconds |
|
./rai_node --daemon --data_path="$DATA_PATH/$DATA_DIRECTORY"& PID=$!; sleep 5; kill $PID |
|
|
|
# Enable executing as application |
|
chmod +x gdrive |
|
|
|
# GDrive must be verified against your account for access |
|
# An interactive prompt will ask to log in using your Google account with a special link |
|
# The id used on this command is irrelevant and does not need to be changed. |
|
./gdrive info 0B3X9GlR6EmbnQ0FtZmJJUXEyRTA |
|
|
|
# Download database snapshot archive from google drive |
|
# Update the file ID with the latest 7zip Linux database archive on Google Drive from: |
|
# https://www.reddit.com/r/RaiBlocks/wiki/index |
|
# Right click on the archive in google drive and select "Get shareable link..." |
|
# The id at the end of this URL should be used in the command |
|
./gdrive download --stdout 1JFy7OvY9bKRtQMcwczqFYdgqvOOeHqSM > db.7z |
|
|
|
# Decompress database |
|
p7zip -d 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 |