]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: extract temporary $CFG to eliminate duplication
authorAdam Spiers <aspiers@suse.com>
Mon, 23 Feb 2015 15:28:36 +0000 (15:28 +0000)
committerWilly Tarreau <w@1wt.eu>
Mon, 23 Feb 2015 17:13:14 +0000 (18:13 +0100)
Signed-off-by: Adam Spiers <aspiers@suse.com>
examples/haproxy.init

index 942d959c8a535829404395883119b1f254f9b84b..ae3ac0f9077cde039ee71a4d2aef93104d36339e 100644 (file)
@@ -32,19 +32,20 @@ if [ -L $0 ]; then
   BASENAME=`basename $BASENAME`
 fi
 
-[ -f /etc/$BASENAME/$BASENAME.cfg ] || exit 1
+CFG=/etc/$BASENAME/$BASENAME.cfg
+[ -f $CFG ] || exit 1
 
 RETVAL=0
 
 start() {
-  /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
+  /usr/sbin/$BASENAME -c -q -f $CFG
   if [ $? -ne 0 ]; then
     echo "Errors found in configuration file, check it with '$BASENAME check'."
     return 1
   fi
 
   echo -n "Starting $BASENAME: "
-  daemon /usr/sbin/$BASENAME -D -f /etc/$BASENAME/$BASENAME.cfg -p /var/run/$BASENAME.pid
+  daemon /usr/sbin/$BASENAME -D -f $CFG -p /var/run/$BASENAME.pid
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
@@ -62,7 +63,7 @@ stop() {
 }
 
 restart() {
-  /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
+  /usr/sbin/$BASENAME -c -q -f $CFG
   if [ $? -ne 0 ]; then
     echo "Errors found in configuration file, check it with '$BASENAME check'."
     return 1
@@ -72,16 +73,16 @@ restart() {
 }
 
 reload() {
-  /usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg
+  /usr/sbin/$BASENAME -c -q -f $CFG
   if [ $? -ne 0 ]; then
     echo "Errors found in configuration file, check it with '$BASENAME check'."
     return 1
   fi
-  /usr/sbin/$BASENAME -D -f /etc/$BASENAME/$BASENAME.cfg -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid)
+  /usr/sbin/$BASENAME -D -f $CFG -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid)
 }
 
 check() {
-  /usr/sbin/$BASENAME -c -q -V -f /etc/$BASENAME/$BASENAME.cfg
+  /usr/sbin/$BASENAME -c -q -V -f $CFG
 }
 
 rhstatus() {