From 98b3b710a97a9047c4fbce5144e93d15ee435956 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Fri, 23 Jul 2021 18:26:54 +0200 Subject: Ergo deployment OS and existing installation check. Signed-off-by: Georg Pfuetzenreuter --- scripts/sh/deploy_ergo.sh | 13 +++++++++++++ scripts/sh/remove_ergo.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/sh/deploy_ergo.sh b/scripts/sh/deploy_ergo.sh index 29eb9e0..b7486a4 100755 --- a/scripts/sh/deploy_ergo.sh +++ b/scripts/sh/deploy_ergo.sh @@ -1,4 +1,11 @@ #!/bin/sh +DISTRIB=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +echo "Detected $DISTRIB" +if [[ ${DISTRIB} = "openSUSE Leap" ]] +echo +then +if [ ! -d /opt/ergo ] +then GOVER=`go version | { read _ _ v _; echo ${v#go}; }` echo "Detected Go $GOVER" GOVER_REQ="1.16.0" @@ -53,3 +60,9 @@ fi else echo "This is currently only compatible with Go 1.16.6 or higher. Consider deploy_go.sh." fi +else +echo "Existing Ergo installation or leftovers detected. Consider remove_ergo.sh." +fi +else +echo "This is currently only compatible with SUSE Leap nodes." +fi diff --git a/scripts/sh/remove_ergo.sh b/scripts/sh/remove_ergo.sh index c9af4de..0634946 100755 --- a/scripts/sh/remove_ergo.sh +++ b/scripts/sh/remove_ergo.sh @@ -1,5 +1,5 @@ #!/bin/sh -if [ ! /opt/ergo ] +if [ ! -d /opt/ergo ] echo then read -p "Remove Ergo? This will kill running Ergo services and cause data loss. " -n 1 -r -- cgit v1.2.3 From d5c1dc1bc35414d8b2dc1217c39478db4484d419 Mon Sep 17 00:00:00 2001 From: Georg Date: Sun, 25 Jul 2021 22:30:42 +0200 Subject: node_exporter script Signed-off-by: Georg --- scripts/sh/deploy_node_exporter.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/sh/deploy_node_exporter.sh diff --git a/scripts/sh/deploy_node_exporter.sh b/scripts/sh/deploy_node_exporter.sh new file mode 100755 index 0000000..52dbc7f --- /dev/null +++ b/scripts/sh/deploy_node_exporter.sh @@ -0,0 +1,36 @@ +#!/bin/sh +if [ -d /etc/systemd/system ] +then +if [ ! -d /opt/node_exporter ] +then +groupadd -g 501 prometheus +useradd -rd /opt/node_exporter -g 501 -u 501 -s /bin/false node_exporter +mkdir /opt/node_exporter +curl -Lo /opt/node_exporter/LICENSE 192.168.0.120/opt/node_exporter/LICENSE +curl -Lo /opt/node_exporter/NOTICE 192.168.0.120/opt/node_exporter/NOTICE +curl -Lo /opt/node_exporter/node_exporter 192.168.0.120/opt/node_exporter/node_exporter +chmod +x /opt/node_exporter/node_exporter +chown -R node_exporter:prometheus /opt/node_exporter +chmod 750 /opt/node_exporter +cat <<'EOF' >/etc/systemd/system/node_exporter.service +[Unit] +Description=Prometheus Node Exporter +After=network.target + +[Service] +User=node_exporter +Group=prometheus +Type=simple +ExecStart=/opt/node_exporter/node_exporter --web.listen-address=":9200" + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now node_exporter +echo "OK" +else +echo "Found traces of an existing installation. Aborted." +fi +else +echo "Not compatible with this system. No systemd?" +fi -- cgit v1.2.3 From 9c35dec520f486c9657fa8abe57ba0b7c438e222 Mon Sep 17 00:00:00 2001 From: Georg Date: Sun, 25 Jul 2021 22:50:43 +0200 Subject: Integrating firewalld into node_exporter script Signed-off-by: Georg --- scripts/sh/deploy_node_exporter.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/sh/deploy_node_exporter.sh b/scripts/sh/deploy_node_exporter.sh index 52dbc7f..d6551f0 100755 --- a/scripts/sh/deploy_node_exporter.sh +++ b/scripts/sh/deploy_node_exporter.sh @@ -27,6 +27,13 @@ ExecStart=/opt/node_exporter/node_exporter --web.listen-address=":9200" WantedBy=multi-user.target EOF systemctl enable --now node_exporter +if [ -x $(command -v firewall-cmd) ] +then +firewall-cmd --zone=internal --add-port=9200/tcp --permanent +firewall-cmd --reload +else +echo "No firewalld, skipping." +fi echo "OK" else echo "Found traces of an existing installation. Aborted." -- cgit v1.2.3