SOURCES: mrtg.init, mrtg.sysconfig - changed the way to start mult...
blues
blues at pld-linux.org
Thu Jul 26 15:18:48 CEST 2007
Author: blues Date: Thu Jul 26 13:18:48 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- changed the way to start multiple configs. Should be backward compatible,
but requires massive testings.
---- Files affected:
SOURCES:
mrtg.init (1.14 -> 1.15) , mrtg.sysconfig (1.2 -> 1.3)
---- Diffs:
================================================================
Index: SOURCES/mrtg.init
diff -u SOURCES/mrtg.init:1.14 SOURCES/mrtg.init:1.15
--- SOURCES/mrtg.init:1.14 Thu Jul 26 14:22:44 2007
+++ SOURCES/mrtg.init Thu Jul 26 15:18:43 2007
@@ -13,8 +13,7 @@
RETVAL=0
# Initial values:
-CONFIGDIR="/etc/mrtg"
-CONFIGS="mrtg.cfg"
+CONFIGDIR="/etc/mrtg/conf.d"
DAEMON_USER="stats"
# Get service config
@@ -29,25 +28,46 @@
fi
done
-# See how we were called.
-case "$1" in
- start)
- # Check if the service is already running?
+start() {
if [ ! -f /var/lock/subsys/mrtg ]; then
- for i in $CONFIGS; do
- msg_starting "mrtg ($i)"
- daemon --user ${DAEMON_USER} mrtg $CONFIGDIR/$i --daemon \
- --logging /var/log/mrtg/$i.log \
- --pid-file=/var/run/mrtg/$i.pid
- done
+ if [ ! "${CONFIGS}" ]; then
+ for file in ${CONFIGDIR}/*.cfg; do
+ f=`basename ${file}`
+ run_cmd "Checking MRTG configuration: ${f}" mrtg --check ${file}
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ msg_starting "mrtg (${f})"
+ daemon --user ${DAEMON_USER} mrtg ${file} --daemon \
+ --logging /var/log/mrtg/${f}.log \
+ --pid-file=/var/run/mrtg/${f}.pid \
+ --lock-file=/var/run/mrtg/${f}_l \
+ --confcache-file=/var/run/mrtg/${f}.ok
+ fi
+ done
+ else
+ echo "WARNING: using obsolete CONFIGS definition."
+ echo "WARNIGN: look at /etc/sysconfig/mrtg for hints."
+ for i in $CONFIGS; do
+ run_cmd "Checking MRTG configuration: ${i}" mrtg --check ${i}
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ msg_starting "mrtg ($i)"
+ daemon --user ${DAEMON_USER} mrtg $CONFIGDIR/$i --daemon \
+ --logging /var/log/mrtg/$i.log \
+ --pid-file=/var/run/mrtg/$i.pid \
+ --lock-file=/var/run/mrtg/${f}_l \
+ --confcache-file=/var/run/mrtg/${f}.ok
+ fi
+ done
+ fi
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mrtg
else
msg_already_running mrtg
fi
- ;;
- stop)
- # Stop daemons.
+}
+
+stop() {
if [ -f /var/lock/subsys/mrtg ]; then
msg_stopping mrtg
killproc mrtg
@@ -55,10 +75,20 @@
else
msg_not_running mrtg
fi
+}
+
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
;;
restart)
- $0 stop
- $0 start
+ stop
+ start
exit $?
;;
reload|force-reload)
================================================================
Index: SOURCES/mrtg.sysconfig
diff -u SOURCES/mrtg.sysconfig:1.2 SOURCES/mrtg.sysconfig:1.3
--- SOURCES/mrtg.sysconfig:1.2 Thu Jul 26 14:22:44 2007
+++ SOURCES/mrtg.sysconfig Thu Jul 26 15:18:43 2007
@@ -3,14 +3,21 @@
# Define nice level for mrtg
SERVICE_RUN_NICE_LEVEL="+5"
-# Define configs directory:
+# Define configs directory. Files (or links) *.cfg in that directory are
+# started while bringing daemon up.
#Default:
-#CONFIGDIR="/etc/mrtg"
+#CONFIGDIR="/etc/mrtg/conf.d"
+# Run Daemon as specific user.
+# Default: stats
+#DAEMON_USER=stats
+
+
+### OBSOLETE:
# Define multiple configs, separated with space
# Default:
#CONFIGS="mrtg.cfg"
+#
+# Instead of that simply put files (or symlinks) in directory specified
+# in CONFIGDIR.
-# Run Daemon as specific user.
-# Default: stats
-#DAEMON_USER=stats
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/mrtg.init?r1=1.14&r2=1.15&f=u
http://cvs.pld-linux.org/SOURCES/mrtg.sysconfig?r1=1.2&r2=1.3&f=u
More information about the pld-cvs-commit
mailing list