Hi Holger,
On 06/05/2021 21:46, Holger Sunke wrote:
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
The echo commands don't make sense here. No user will ever see them. They will only show up when a build is being carried out. If the expectation is that the user can customise things then this needs to be part of the config of the package, not of the build.
- @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@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@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@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
I think it would be good to see if the IPFire initscript template makes sense to use for starting/stopping etc node_exporter rather than patching a file from the source tarball.
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=src/initscripts/system/tem...
Regards, Adolf.