Skip to content

Instantly share code, notes, and snippets.

@wildcommunist
Created June 7, 2022 06:26
Show Gist options
  • Save wildcommunist/2a6b06b943ce1eff7415c77ae0233172 to your computer and use it in GitHub Desktop.
Save wildcommunist/2a6b06b943ce1eff7415c77ae0233172 to your computer and use it in GitHub Desktop.
#!/bin/bash
red=$(tput setaf 1)
cyan=$(tput setaf 6)
green=$(tput setaf 2)
reset=$(tput sgr0)
NODE_VER="1.3.1"
NODE_DL_URL="https://github.com/prometheus/node_exporter/releases/download/v${NODE_VER}/node_exporter-${NODE_VER}.linux-amd64.tar.gz"
SERVICE="/etc/systemd/system/node_exporter.service"
sudo apt update && sudo apt install git nano wget curl -y
echo "Downloading ${cyan}${NODE_DL_URL}${reset}"
wget -q $NODE_DL_URL
tar xvf node_exporter-${NODE_VER}.linux-amd64.tar.gz
sudo cp node_exporter-${NODE_VER}.linux-amd64/node_exporter /usr/local/bin
rm -rf node_exporter-${NODE_VER}.linux-amd64.tar.gz
sudo useradd --no-create-home --shell /bin/false node_exporter
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
sudo tee $SERVICE << END
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
END
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
sudo systemctl status node_exporter
echo "${green}Installation complete!${reset}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment