Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 475622 - www-servers/pound - add configuration sanity check to init.d script
Summary: www-servers/pound - add configuration sanity check to init.d script
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Patrick Lauer
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-07-03 12:08 UTC by Tomáš Mózes
Modified: 2016-02-11 19:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomáš Mózes 2013-07-03 12:08:17 UTC
Pound init script could be modified to be able to check the configuration file syntax. Pound has a "-c" option that enables this:
-c     Check only: Pound will exit immediately after parsing the configuration file. This may be used for running a quick syntax check before actually activating a server.

# diff -u /usr/portage/www-servers/pound/files/pound.init-1.9 /etc/init.d/pound
--- /usr/portage/www-servers/pound/files/pound.init-1.9 2005-07-07 17:45:08.000000000 +0200
+++ /etc/init.d/pound   2013-07-03 13:59:11.762440558 +0200
@@ -3,16 +3,42 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/www-servers/pound/files/pound.init-1.9,v 1.1 2005/07/07 15:45:08 mkennedy Exp $
 
+extra_commands="configtest"
+
+description_configtest="Run syntax tests for configuration files."
+
+POUND="/usr/sbin/pound"
+CONFIGFILE="/etc/pound.cfg"
+
 depend() {
        need net
 }
 
+configtest() {
+       ebegin "Checking ${SVCNAME} configuration"
+       checkconfig
+       eend $?
+}
+
+checkconfig() {
+       ${POUND} -c >/dev/null 2>&1
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               eerror "${SVCNAME} has detected an error in your setup:"
+               ${POUND} -c
+       fi
+
+       return $ret
+}
+
 start() {
+       checkconfig || return 1
+
        ebegin "Starting pound"
-       if [ ! -f "/etc/pound.cfg" ]; then
-               eend 1 "configfile /etc/pound.cfg not found."
+       if [ ! -f "${CONFIGFILE}" ]; then
+               eend 1 "configfile ${CONFIGFILE} not found."
        fi
-       start-stop-daemon --quiet --start --exec /usr/sbin/pound -- -f /etc/pound.cfg -p /var/run/pound.pid
+       start-stop-daemon --quiet --start --exec ${POUND} -- -f ${CONFIGFILE} -p /var/run/pound.pid
        eend $?
 }