Autodeploy (kinda) Coda node and systemd integration script

Hey there, just paste here what I wrote on discord:
" I’ve made a quick deploy script that installs coda, creates a systemd entry and starts the daemon
at the moment you need to change 2 values manually: key path and password

it starts the node with block producer on (no snark worker) but you need to generate key manually"

#!/bin/sh
USER=$(whoami)
sudo apt-get remove coda-testnet-postake-medium-curves
echo "deb [trusted=yes] http://packages.o1test.net/ release main" | sudo tee /etc/apt/sources.list.d/coda.list
sudo apt-get update
sudo apt-get install coda-testnet-postake-medium-curves=0.0.12-beta-63b8a66
mkdir /home/$USER/coda
cd /home/$USER/coda
touch node_start.sh
touch node.service
cat <<EOF > node_start.sh
#!/bin/sh

#Warning: this command is insecure.
export CODA_PRIVKEY_PASS=CHANGE_THIS_TO_KEY_FILE_PASSWORD

#Change path to key file.
/usr/local/bin/coda daemon \
    -discovery-port 8303 \
    -peer /dns4/seed-one.genesis.o1test.net/tcp/10002/ipfs/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH \
    -peer /dns4/seed-two.genesis.o1test.net/tcp/10002/ipfs/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA \
    -propose-key /CHANGE_THIS_TO_KEY_PATH
EOF
cat <<EOF > node.service
[Unit]
Description=Coda Daemon Service
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=3

[Service]
Type=simple
Restart=always
RestartSec=3
User=$USER
ExecStart=/home/$USER/coda/node_start.sh
ExecStop=/usr/bin/pkill -f 'coda daemon'

[Install]
WantedBy=multi-user.target
EOF
sudo mv node.service /etc/systemd/system


sudo systemctl daemon-reload
sudo systemctl enable node
sudo systemctl start node
journalctl -fu node

last command (journalctl -fu node) starts node.service real time logging, just ctrl c to exit, node stil running

Great! There’s also this, maybe you can combine https://github.com/jkrauska/coda-systemd

1 Like