Skip to content

Instantly share code, notes, and snippets.

@tommyv1987
Last active June 19, 2024 11:47
Show Gist options
  • Save tommyv1987/548880b3eafd6f9541654bb9886ef225 to your computer and use it in GitHub Desktop.
Save tommyv1987/548880b3eafd6f9541654bb9886ef225 to your computer and use it in GitHub Desktop.
Enable Nymvisor for you Nym Binaries (nym-node - nym-api)
#!/bin/bash
NODE_TYPE=$1 # this can be nym-api or nym-node
ENV=$2 # upstream change of envs for upgrade info
NODE_ID=$3 # the id set up when configuring your node
NYMVISOR_URL="https://github.com/nymtech/nym/releases/download/nym-binaries-v2024.5-ragusa/nymvisor" # amend this value if you desire
NYMVISOR_BINARY="nymvisor" # binary name for nymvisor
PATH_TO_NODE_BINARY="/root/${NODE_TYPE}" # amend this value for your root path on your binary
if [ -z "$NODE_TYPE" ] || [ -z "$ENV" ] || [ -z "$NODE_ID" ]; then
echo "Usage: $0 <NODE_TYPE> <ENV> <NODE_ID>"
exit 1
fi
echo "node ID: $NODE_ID"
echo "downloading nymvisor binary..."
curl -L $NYMVISOR_URL -o $NYMVISOR_BINARY
chmod +x $NYMVISOR_BINARY
echo "checking available commands..."
./$NYMVISOR_BINARY --help
sleep 5
echo "init nymvisor instance..."
./$NYMVISOR_BINARY init --daemon-home ~/.nym/"$NODE_TYPE"/"$NODE_ID" "$PATH_TO_NODE_BINARY"
echo "stopping existing service"
systemctl stop "${NODE_TYPE}".service
SERVICE_FILE="/etc/systemd/system/nymvisor.service"
echo "creating systemd service file..."
sudo bash -c "cat > $SERVICE_FILE" <<EOL
[Unit]
Description=Nymvisor Service
After=network.target
[Service]
User=root
WorkingDirectory=/root
ExecStart=/root/nymvisor run run --id $NODE_ID
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOL
echo "enabling and starting Nymvisor service..."
sudo systemctl daemon-reload
sudo systemctl enable nymvisor.service
sudo systemctl start nymvisor.service
echo "checking nymvisor service status..."
sudo systemctl status nymvisor.service
echo "nymvisor setup and node started successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment