public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Holger Sunke <holger.sunke@posteo.de>
To: development@lists.ipfire.org
Subject: [PATCH 2/2] Added new node_exporter package.
Date: Thu, 06 May 2021 19:46:16 +0000	[thread overview]
Message-ID: <20210506194616.2972714-3-holger.sunke@posteo.de> (raw)
In-Reply-To: <20210506194616.2972714-1-holger.sunke@posteo.de>

[-- Attachment #1: Type: text/plain, Size: 13293 bytes --]

---
 config/rootfiles/packages/node_exporter       |  3 +
 lfs/node_exporter                             | 88 +++++++++++++++++++
 make.sh                                       |  1 +
 src/paks/node_exporter/install.sh             | 31 +++++++
 src/paks/node_exporter/uninstall.sh           | 30 +++++++
 src/paks/node_exporter/update.sh              | 27 ++++++
 ..._exporter-configurable-initd-options.patch | 48 ++++++++++
 7 files changed, 228 insertions(+)
 create mode 100644 config/rootfiles/packages/node_exporter
 create mode 100644 lfs/node_exporter
 create mode 100644 src/paks/node_exporter/install.sh
 create mode 100644 src/paks/node_exporter/uninstall.sh
 create mode 100644 src/paks/node_exporter/update.sh
 create mode 100644 src/patches/node_exporter-configurable-initd-options.patch

diff --git a/config/rootfiles/packages/node_exporter b/config/rootfiles/packages/node_exporter
new file mode 100644
index 000000000..20ec55174
--- /dev/null
+++ b/config/rootfiles/packages/node_exporter
@@ -0,0 +1,3 @@
+usr/bin/node_exporter
+etc/node_exporter
+etc/rc.d/init.d/node_exporter
diff --git a/lfs/node_exporter b/lfs/node_exporter
new file mode 100644
index 000000000..3bb4db60e
--- /dev/null
+++ b/lfs/node_exporter
@@ -0,0 +1,88 @@
+##############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 1.1.2
+
+THISAPP    = node_exporter-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+#DL_FROM    = https://github.com/prometheus/node_exporter/archive/refs/tags/v1.1.2.tar.gz
+DL_FROM    = https://github.com/prometheus/node_exporter/archive/v$(VER)/
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = node_exporter
+PAK_VER    = 1
+
+DEPS       = ""
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = 33c2be846dbd502f9c0efab149a8cbc5
+
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download : $(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist :
+	@$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+	@$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+	@$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+	@$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+	@$(PREBUILD)
+	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) &&  patch -Np1 -i $(DIR_SRC)/src/patches/node_exporter-configurable-initd-options.patch
+	cd $(DIR_APP) && make build $(MAKETUNING) $(EXTRA_MAKE)
+	cd $(DIR_APP) && cp node_exporter /usr/bin
+	cd $(DIR_APP) && cp examples/init.d/node_exporter /etc/init.d/
+	echo '# Customize node_exporter command line options by editing OPTIONS below:' > /etc/node_exporter
+	echo 'export OPTIONS="--web.listen-address=:9100"' >> /etc/node_exporter
+	@rm -rf $(DIR_APP)
+	@$(POSTBUILD)
+
diff --git a/make.sh b/make.sh
index 2da3aca21..df2995ec5 100755
--- a/make.sh
+++ b/make.sh
@@ -1640,6 +1640,7 @@ buildipfire() {
   lfsmake2 ncdu
   lfsmake2 lshw
   lfsmake2 socat
+  lfsmake2 node_exporter
 }
 
 buildinstaller() {
diff --git a/src/paks/node_exporter/install.sh b/src/paks/node_exporter/install.sh
new file mode 100644
index 000000000..e9272d7cb
--- /dev/null
+++ b/src/paks/node_exporter/install.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info(a)ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+extract_files
+restore_backup ${NAME}
+start_service --background ${NAME}
+
+ln -svf  ../init.d/node_exporter /etc/rc.d/rc0.d/K30node_exporter
+ln -svf  ../init.d/node_exporter /etc/rc.d/rc3.d/S40node_exporter
+ln -svf  ../init.d/node_exporter /etc/rc.d/rc6.d/K30node_exporter
diff --git a/src/paks/node_exporter/uninstall.sh b/src/paks/node_exporter/uninstall.sh
new file mode 100644
index 000000000..710baf8b4
--- /dev/null
+++ b/src/paks/node_exporter/uninstall.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info(a)ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+/etc/init.d/node_exporter stop
+make_backup ${NAME}
+remove_files
+
+rm -rfv /etc/rc.d/rc*.d/*node_exporter
+
diff --git a/src/paks/node_exporter/update.sh b/src/paks/node_exporter/update.sh
new file mode 100644
index 000000000..99776659c
--- /dev/null
+++ b/src/paks/node_exporter/update.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007-2020 IPFire-Team <info(a)ipfire.org>.                   #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+extract_backup_includes
+./uninstall.sh
+./install.sh
diff --git a/src/patches/node_exporter-configurable-initd-options.patch b/src/patches/node_exporter-configurable-initd-options.patch
new file mode 100644
index 000000000..9f662f918
--- /dev/null
+++ b/src/patches/node_exporter-configurable-initd-options.patch
@@ -0,0 +1,48 @@
+diff -Nur node_exporter-1.1.2.orig/examples/init.d/node_exporter node_exporter-1.1.2/examples/init.d/node_exporter
+--- node_exporter-1.1.2.orig/examples/init.d/node_exporter	2021-03-05 10:27:11.000000000 +0100
++++ node_exporter-1.1.2/examples/init.d/node_exporter	2021-05-04 14:45:20.644729176 +0200
+@@ -2,9 +2,11 @@
+ 
+ RETVAL=0
+ PROG="node_exporter"
+-EXEC="/etc/node_exporter/node_exporter"
++EXEC="/usr/bin/node_exporter"
+ LOCKFILE="/var/lock/subsys/$PROG"
+-OPTIONS="--web.listen-address=:9100"
++
++# read configurable OPTIONS
++. /etc/node_exporter
+ 
+ # Source function library.
+ if [ -f /etc/rc.d/init.d/functions ]; then
+@@ -22,18 +24,16 @@
+     echo -n "Starting $PROG: "
+     nohup $EXEC $OPTIONS >/dev/null 2>&1 &
+     RETVAL=$?
+-    [ $RETVAL -eq 0 ] && touch $LOCKFILE && success || failure
+-    echo
++    [ $RETVAL -eq 0 ] && touch $LOCKFILE && echo success || echo failure
+     return $RETVAL
+   fi
+ }
+ 
+ stop() {
+   echo -n "Stopping $PROG: "
+-  killproc $EXEC
++  killproc $EXEC > /dev/null
+   RETVAL=$?
+-  [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure
+-  echo
++  [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && echo success || echo failure
+ }
+ 
+ restart ()
+@@ -51,7 +51,7 @@
+     stop
+     ;;
+   status)
+-    status $PROG
++    statusproc $PROG
+     ;;
+   restart)
+     restart
-- 
2.30.2


  parent reply	other threads:[~2021-05-06 19:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 19:46 [PATCH 0/2] Added new Package node_exporter Holger Sunke
2021-05-06 19:46 ` [PATCH 1/2] Added i586/386 support for GO language required for node_exporter Holger Sunke
2021-05-06 20:26   ` Adolf Belka
2021-05-07 11:28   ` Michael Tremer
2021-05-07 18:19     ` Holger Sunke
2021-05-11  9:53       ` Michael Tremer
2021-05-21  8:56         ` Holger Sunke
2021-05-21  8:59           ` Michael Tremer
2021-05-06 19:46 ` Holger Sunke [this message]
2021-05-06 20:58   ` [PATCH 2/2] Added new node_exporter package Adolf Belka
2021-05-06 20:43 ` [PATCH 0/2] Added new Package node_exporter Adolf Belka
2021-05-07 18:05   ` Holger Sunke
2021-05-24 20:45     ` Robin Roevens
2021-06-06 17:48 [PATCH 0/2] Reworked patches introducing node_exporter on master branch Holger Sunke
2021-06-06 17:48 ` [PATCH 2/2] Added new node_exporter package Holger Sunke
2021-06-08 16:56   ` Michael Tremer
2021-06-09  6:14     ` Holger Sunke
2021-06-10  9:03       ` Michael Tremer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210506194616.2972714-3-holger.sunke@posteo.de \
    --to=holger.sunke@posteo.de \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox