I had to add something like this to an old Scientific Linux 6.7 system:
```#!bash
#
#
. /etc/rc.d/init.d/functions
[ -f /etc/sysconfig/node_exporter ] && . /etc/sysconfig/node_exporter
RETVAL=0
prog="node_exporter"
lockfile=/var/lock/subsys/$prog
USER=node_exporter
PID_FILE=/var/run/node_exporter.pid
NODE_EXPORTER=/usr/local/bin/node_exporter
runlevel=$(set -- $(runlevel); eval "echo \$$#" )
start()
{
[ -x $NODE_EXPORTER ] || exit 5
echo -n $"Starting $prog: "
daemonize -u $USER -p $PID_FILE -l $lockfile $NODE_EXPORTER $OPTIONS && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $PID_FILE $NODE_EXPORTER
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $lockfile
echo
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $PID_FILE $NODE_EXPORTER -HUP
RETVAL=$?
echo
}
restart() {
stop
start
}
force_reload() {
restart
}
rh_status() {
status -p $PID_FILE openssh-daemon
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
start
;;
stop)
if ! rh_status_q; then
rm -f $lockfile
exit 0
fi
stop
;;
restart)
restart
;;
reload)
rh_status_q || exit 7
reload
;;
force-reload)
force_reload
;;
condrestart|try-restart)
rh_status_q || exit 0
if [ -f $lockfile ] ; then
do_restart_sanity_check
if [ $RETVAL -eq 0 ] ; then
stop
# avoid race
sleep 3
start
else
RETVAL=6
fi
fi
;;
status)
rh_status
RETVAL=$?
if [ $RETVAL -eq 3 -a -f $lockfile ] ; then
RETVAL=2
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
RETVAL=2
esac
exit $RETVAL
```
You can generate this script yourself using pleaserun:
pleaserun --install-prefix /tmp -p sysv -v lsb-3.1 --name node_exporter /usr/local/bin/node_exporter
Then write a /etc/sysconfig/node_exporter file with the contents:
args="--collectors.enabled etc --and --other --args"
Since the node-exporter doesn't need any special setup, I don't think it makes much sense to include a sysv script that might need (small but still) ongoing maintenance.
As @SuperQ said, if we want to add something like that, it should be done on the build infrastructure level so it works for all prometheus projects.
Since the node-exporter doesn't need any special setup, I don't think it makes much sense to include a sysv script that might need (small but still) ongoing maintenance.
As @SuperQ said, if we want to add something like that, it should be done on the build infrastructure level so it works for all prometheus projects.
Agree with you.
Most helpful comment
It would be interesting to add RPM/DEB building to promu. Something like fpm should be able to automatically generate this kind of thing.
Any interest in contributing this feature?