#!/bin/bash if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" if getent passwd connectivity_exporter > /dev/null 2>&1; then echo "User already exists!" else adduser --system --no-create-home --group --shell=/bin/false connectivity_exporter fi if service --status-all | grep -Fq 'connectivity_exporter'; then service connectivity_exporter stop fi echo "Copying exporter" mkdir -p /usr/prometheus echo "Checking/Creating systemd configuration" cp $SCRIPTPATH/connectivity_exporter /usr/prometheus/connectivity_exporter chmod +x /usr/prometheus/connectivity_exporter cp $SCRIPTPATH/connectivity_exporter.service /etc/systemd/system/ [ ! -d /etc/sysconfig ] && mkdir /etc/sysconfig if [ -f "/etc/sysconfig/connectivity_exporter" ]; then echo "/etc/sysconfig/connectivity_exporter already there. Skipping." else cp $SCRIPTPATH/connectivity_exporter.sysconfig /etc/sysconfig/connectivity_exporter fi if [ -f "/etc/sysconfig/connectivity_exporter.yaml" ]; then echo "/etc/sysconfig/connectivity_exporter.yaml already there. Skipping." else cp $SCRIPTPATH/connectivity_exporter.yaml /etc/sysconfig/connectivity_exporter.yaml fi echo "Starting exporter" systemctl enable connectivity_exporter.service service connectivity_exporter start echo "Exporter available at :9285"