CLEANUP: extract temporary $PIDFILE to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
This commit is contained in:
Adam Spiers 2015-02-23 15:28:38 +00:00 committed by Willy Tarreau
parent 85bb5ca39b
commit 922a37b2fb
1 changed files with 5 additions and 3 deletions

View File

@ -37,6 +37,8 @@ BIN=/usr/sbin/$BASENAME
CFG=/etc/$BASENAME/$BASENAME.cfg CFG=/etc/$BASENAME/$BASENAME.cfg
[ -f $CFG ] || exit 1 [ -f $CFG ] || exit 1
PIDFILE=/var/run/$BASENAME.pid
RETVAL=0 RETVAL=0
start() { start() {
@ -47,7 +49,7 @@ start() {
fi fi
echo -n "Starting $BASENAME: " echo -n "Starting $BASENAME: "
daemon $BIN -D -f $CFG -p /var/run/$BASENAME.pid daemon $BIN -D -f $CFG -p $PIDFILE
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
@ -60,7 +62,7 @@ stop() {
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
[ $RETVAL -eq 0 ] && rm -f /var/run/$BASENAME.pid [ $RETVAL -eq 0 ] && rm -f $PIDFILE
return $RETVAL return $RETVAL
} }
@ -80,7 +82,7 @@ reload() {
echo "Errors found in configuration file, check it with '$BASENAME check'." echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1 return 1
fi fi
$BIN -D -f $CFG -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid) $BIN -D -f $CFG -p $PIDFILE -sf $(cat $PIDFILE)
} }
check() { check() {