#!/bin/bash # Variables NODE_EXPORTER_VERSION="1.0.1" NODE_EXPORTER_TAR="node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz" NODE_EXPORTER_DIR="node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64" DOWNLOAD_URL="https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/${NODE_EXPORTER_TAR}" SERVICE_FILE="/usr/lib/systemd/system/node_exporter.service" USER="node_exporter" # Download Node Exporter wget $DOWNLOAD_URL # Create User and Directories sudo groupadd -f $USER sudo useradd -g $USER --no-create-home --shell /bin/false $USER sudo mkdir /etc/node_exporter sudo chown $USER:$USER /etc/node_exporter # Unpack Node Exporter Binary tar -xvf $NODE_EXPORTER_TAR mv $NODE_EXPORTER_DIR node_exporter-files # Install Node Exporter sudo cp node_exporter-files/node_exporter /usr/bin/ sudo chown $USER:$USER /usr/bin/node_exporter # Setup Node Exporter Service sudo bash -c "cat > $SERVICE_FILE" <