Author: glen                         Date: Sun Dec 12 18:11:19 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- reworked config handling to support old and new mode more transparently

---- Files affected:
packages/mrtg:
   mrtg.init (1.25 -> 1.26) 

---- Diffs:

================================================================
Index: packages/mrtg/mrtg.init
diff -u packages/mrtg/mrtg.init:1.25 packages/mrtg/mrtg.init:1.26
--- packages/mrtg/mrtg.init:1.25        Sun Dec 12 19:01:38 2010
+++ packages/mrtg/mrtg.init     Sun Dec 12 19:11:14 2010
@@ -26,67 +26,55 @@
        fi
 done
 
-checkconfigs() {
-       local rc
-       for file in ${CONFIGDIR}/*.cfg; do
-               f=${file##*/}
-               run_cmd --user "$DAEMON_USER" "Checking MRTG configuration: 
${f}" mrtg --check ${file}
-               rc=$?
-               if [ $rc -ne 0 -a $RETVAL -eq 0 ]; then
-                       RETVAL=$rc
-               fi
-       done
+
+getconfigs() {
+       if [ -z "${CONFIGS}" ]; then
+               echo ${CONFIGDIR}/*.cfg
+       else
+               echo >&2 "WARNING: Using obsolete CONFIGS definition."
+               echo >&2 "WARNING: look at /etc/sysconfig/mrtg for hints."
+               echo $CONFIGS
+       fi
 }
 
-# For obsolete multiple configs - to be droped soon:
-checkconfigs_old() {
+checkconfigs() {
        local rc file f
-       for file in ${CONFIGS}; do
+       for file in "$@"; do
                f=${file##*/}
                run_cmd --user "$DAEMON_USER" "Checking MRTG configuration: 
$file" \
-                       mrtg --check ${CONFIGDIR}/$file \
-                               --lock-file=/var/run/mrtg/$f_l \
+                       mrtg --check $file \
+                               --lock-file=/var/run/mrtg/${f}_l
                rc=$?
                if [ $rc -ne 0 -a $RETVAL -eq 0 ]; then
                        RETVAL=$rc
                fi
        done
+       if [ $RETVAL -ne 0 ]; then
+               exit $RETVAL
+       fi
 }
 
-
 start() {
        if [ -f /var/lock/subsys/mrtg ]; then
                msg_already_running "MRTG"
                return
        fi
 
-       local file f closefds
-       if [ -z "${CONFIGS}" ]; then
-               checkconfigs
-               is_no "$RC_LOGGING" && closefds=--closefds
-               for file in ${CONFIGDIR}/*.cfg; do
-                       f=${file##*/}
-                       msg_starting "MRTG ($f)"
-                       daemon $closefds --user "$DAEMON_USER" /usr/bin/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/lib/mrtg/$f.ok
-               done
-       else
-               echo "WARNING: using obsolete CONFIGS definition."
-               echo "WARNING: look at /etc/sysconfig/mrtg for hints."
-               checkconfigs_old
-               for file in $CONFIGS; do
-                       f=${file##*/}
-                       msg_starting "MRTG ($f)"
-                       daemon --user ${DAEMON_USER} /usr/bin/mrtg 
$CONFIGDIR/$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/lib/mrtg/$f.ok
-               done
-       fi
+       local file f closefds configs
+       is_no "$RC_LOGGING" && closefds=--closefds
+
+       configs=$(getconfigs)
+       checkconfigs "$configs"
+
+       for file in $configs; do
+               f=${file##*/}
+               msg_starting "MRTG ($f)"
+               daemon $closefds --user "$DAEMON_USER" /usr/bin/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/lib/mrtg/$f.ok
+       done
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mrtg
 }
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/mrtg/mrtg.init?r1=1.25&r2=1.26&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to