Skip to content

Instantly share code, notes, and snippets.

@ilap
Last active August 4, 2021 05:06
Show Gist options
  • Save ilap/f9a2bd3e99d3903fe01c757ab4a10ef5 to your computer and use it in GitHub Desktop.
Save ilap/f9a2bd3e99d3903fe01c757ab4a10ef5 to your computer and use it in GitHub Desktop.
Standalone gLiveView

Prerequisities

You must be able to run ss or lsof as root to gather the node-s PID in their ouput, as I HIGHLY DO NOT RECOMMEND running a node and this script as root.

The easiest way is just add simmilar entries as the following into the /etc/sudoers or create a file under /etc/sudoers.d/

The /etc/sudoers example, but pls ensure that the path to those files are correct:

User_Alias SPO=spo,ahtn,shmn
SPO       ALL = NOPASSWD: /bin/systemctl *, \
                (root) NOPASSWD: /bin/ss *, \
                (root) NOPASSWD: /usr/bin/lsof *

Instructions

SCRIPT_DIR="${HOME}/scripts"

[ "$(which jq ss curl | wc -l)" != 3 ] && {
    echo "jq, ss and curl must be installed before proceed..." >&2 
    exit 127
}

LV_URL=https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/gLiveView.sh
ENV_URL=https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/env

mkdir -p "$SCRIPT_DIR" && pushd "$SCRIPT_DIR"

    curl -s -o gLiveView.sh $LV_URL
    curl -s -o env $ENV_URL

    sed -i -e 's@^CNODE_PORT=.*@CNODE_PORT=${CNODE_PORT:=6000}\nshopt -s expand_aliases\n\nalias ss="sudo $(which ss)"\nalias lsof="sudo $(which lsof)"\n@' env

    chmod +x gLiveView.sh env

popd

# Last tested Wed Aug  4 05:38:55 CEST 2021

#  Set the required env variables
export CNODE_PORT=8900 # Not required, it's just an eye-candy for displaying it in the UI.
export CONFIG=/opt/cardano/ahtn/conf/config.json # Path to config.json file

# Run...
cd ~ && . scripts/env # It must come back without error
scripts/gLiveView.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment