Last active
June 18, 2021 13:01
-
-
Save davepuchyr/1bb1d33eacf009e4b700deb751a065a3 to your computer and use it in GitHub Desktop.
Start an IBC-enabled node for the `stargatenet` testnet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for i in basename chgrp chmod curl grep journalctl jq sed sha256sum systemctl wget ; do [[ $(command -v $i) ]] || { echo "$i is not in PATH; PATH == $PATH; cannot proceed" ; exit -1 ; } ; done # https://unix.stackexchange.com/a/379425 | |
sudo su -c bash # make life easier for the next ~100 lines | |
cd /etc/systemd/system | |
export USER_IOV=iov # "iov" is not recommended | |
export SIGNER=dave*iov # signer for the create-validator tx | |
# create an environment file for the Starname Asset Name Service | |
cat <<__EOF_STARNAMED_ENV__ > starnamed.env | |
# operator variables | |
CHAIN_ID=stargatenet | |
MONIKER=$(hostname) | |
SIGNER=${SIGNER} | |
USER_IOV=${USER_IOV} | |
# directories (without spaces to ease pain) | |
DIR_STARNAMED=/opt/iovns/bin | |
DIR_WORK=/home/${USER_IOV}/stargatenet | |
# artifacts | |
STARNAMED=https://github.com/iov-one/starnamed/releases/download/v0.10.12/starnamed-0.10.12-linux-amd64.tar.gz | |
__EOF_STARNAMED_ENV__ | |
chgrp ${USER_IOV} starnamed.env | |
chmod g+r starnamed.env | |
set -o allexport ; source /etc/systemd/system/starnamed.env ; set +o allexport # pick-up env vars | |
# create starname.service | |
cat <<__EOF_STARNAMED_SERVICE__ > starnamed.service | |
[Unit] | |
Description=Starname Asset Name Service | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=$(id ${USER_IOV} -u -n) | |
Group=$(id ${USER_IOV} -g -n) | |
EnvironmentFile=/etc/systemd/system/starnamed.env | |
ExecStart=${DIR_STARNAMED}/starnamed.sh | |
LimitNOFILE=4096 | |
#Restart=on-failure | |
#RestartSec=3 | |
StandardError=journal | |
StandardOutput=journal | |
SyslogIdentifier=starnamed | |
[Install] | |
WantedBy=multi-user.target | |
__EOF_STARNAMED_SERVICE__ | |
systemctl daemon-reload | |
# download gitian built binary; starnamed is the Starname Asset Name Service daemon | |
mkdir -p ${DIR_STARNAMED} && cd ${DIR_STARNAMED} | |
wget ${STARNAMED} && sha256sum $(basename ${STARNAMED}) | grep 505aaddb5a8390576a6f0315627387a64a5682133ddc07b612fd2e05f1280bad && tar xvf $(basename ${STARNAMED}) && echo 'All good!' || echo 'BAD BINARY!' | |
# create starnamed.sh, a wrapper for starnamed | |
cat <<__EOF_STARNAMED_SH__ > starnamed.sh | |
#!/bin/bash | |
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD} | |
exec $PWD/starnamed start \\ | |
--home=${DIR_WORK} \\ | |
--minimum-gas-prices='1.0uvoi' \\ | |
--moniker='${MONIKER}' \\ | |
--p2p.laddr='tcp://0.0.0.0:56656' \\ | |
--p2p.persistent_peers='[email protected]:56656' \\ | |
--rpc.laddr='tcp://127.0.0.1:56657' \\ | |
--rpc.unsafe=true \\ | |
__EOF_STARNAMED_SH__ | |
chgrp ${USER_IOV} starnamed.sh | |
chmod a+x starnamed.sh | |
# initialize the Starname Asset Name Service | |
su - ${USER_IOV} | |
set -o allexport ; source /etc/systemd/system/starnamed.env ; set +o allexport # pick-up env vars | |
rm -rf ${DIR_WORK} && mkdir -p ${DIR_WORK} && cd ${DIR_WORK} | |
# initialize starnamed | |
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${DIR_STARNAMED} ${DIR_STARNAMED}/starnamed init ${MONIKER} --chain-id ${CHAIN_ID} --home ${DIR_WORK} 2>&1 | jq -r .chain_id | |
# get the genesis file | |
curl --fail https://rpc.cluster-stargatenet.iov.one/genesis | jq -r .result.genesis > config/genesis.json | |
sha256sum config/genesis.json | grep f01b12218dac33390a3c8f18d3c88fc28f2c8061e5e26d87f18a1f83830221e9 && echo 'All good!' || echo 'BAD GENESIS FILE!' | |
exit # ${USER_IOV} | |
systemctl enable starnamed.service | |
journalctl -f -u starnamed.service & systemctl start starnamed.service # watch the chain sync | |
exit # root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment