Always running daemon script

Disadvantages: can not see the process crash

run staking script

#!/bin/bash

i=1
while :
do
    echo -e "***password***\n" | coda daemon -discovery-port 8303 -peer /dns4/peer1-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWHMmfuS9DmmK9eH4GC31arDhbtHEBQzX6PwPtQftxzwJs -peer /dns4/peer2-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWAux9MAW1yAdD8gsDbYHmgVjRvdfYkpkfX7AnyGvQaRPF -peer /dns4/peer3-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWCZA4pPWmDAkQf6riDQ3XMRN5k99tCsiRhBAPZCkA8re7 -insecure-rest-server -propose-key /keys/my-wallet

    
    sleep 3
    echo $i
    echo $i >> status.txt
    let "int++"
done

run snark script
note: you need to install expect

#!/bin/bash

$CODA_PK=*****
i=1
while :
do
    coda daemon \
    -discovery-port 8303 \
    -peer /dns4/peer1-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWHMmfuS9DmmK9eH4GC31arDhbtHEBQzX6PwPtQftxzwJs \
    -peer /dns4/peer2-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWAux9MAW1yAdD8gsDbYHmgVjRvdfYkpkfX7AnyGvQaRPF \
    -peer /dns4/peer3-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWCZA4pPWmDAkQf6riDQ3XMRN5k99tCsiRhBAPZCkA8re7 \
    -run-snark-worker $CODA_PK \
    -snark-worker-fee 1

    echo $i >> status.txt
    let "int++"
done
1 Like

On Ubuntu or Debian I would suggest using systemd for this as intended.

Create /lib/systemd/system/coda.service with this content:

Description=coda-daemon

[Service]
Type=simple
Restart=always
RestartSec=5s
ExecStart=/usr/local/bin/coda daemon \
        -discovery-port 8303 \
        -peer /dns4/peer1-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWHMmfuS9DmmK9eH4GC31arDhbtHEBQzX6PwPtQftxzwJs \
        -peer /dns4/peer2-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWAux9MAW1yAdD8gsDbYHmgVjRvdfYkpkfX7AnyGvQaRPF \
        -peer /dns4/peer3-rising-phoenix.o1test.net/tcp/8303/ipfs/12D3KooWCZA4pPWmDAkQf6riDQ3XMRN5k99tCsiRhBAPZCkA8re7

[Install]
WantedBy=multi-user.target

Then

systemctl enable coda
systemctl start coda

You can manage it like so:

systemctl start coda
systemctl restart coda
systemctl stop coda

And you can view logs in /var/log/syslog

tail -f /var/log/syslog

1 Like

I updated the script, can be used in screen.
peer.sh

#!/bin/bash
export CODA_PRIVKEY_PASS=<<YOUR PASSWORD>>

i=1
while :
do
    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 keys/my-wallet
    
    echo $i >> status.txt
    i=`expr $i + 1`
    sleep 10
done

snark.sh

#!/bin/bash

Master_PUBLIC_KEY=<<YOUR PUBLIC KEY>>
i=1
while :
do
    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 \
    -run-snark-worker $Master_PUBLIC_KEY \
    -snark-worker-fee 1

    echo $i >> status.txt
    i=`expr $i + 1`
    sleep 10
done
1 Like