CLEANUP: extract temporary $CFG to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
This commit is contained in:
Adam Spiers 2015-02-23 15:28:36 +00:00 committed by Willy Tarreau
parent 501260bf67
commit 5e71b6f803

View File

@ -32,19 +32,20 @@ if [ -L $0 ]; then
BASENAME=`basename $BASENAME` BASENAME=`basename $BASENAME`
fi fi
[ -f /etc/$BASENAME/$BASENAME.cfg ] || exit 1 CFG=/etc/$BASENAME/$BASENAME.cfg
[ -f $CFG ] || exit 1
RETVAL=0 RETVAL=0
start() { start() {
/usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg /usr/sbin/$BASENAME -c -q -f $CFG
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
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
echo -n "Starting $BASENAME: " 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=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
@ -62,7 +63,7 @@ stop() {
} }
restart() { restart() {
/usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg /usr/sbin/$BASENAME -c -q -f $CFG
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
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
@ -72,16 +73,16 @@ restart() {
} }
reload() { reload() {
/usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg /usr/sbin/$BASENAME -c -q -f $CFG
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
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
/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() { check() {
/usr/sbin/$BASENAME -c -q -V -f /etc/$BASENAME/$BASENAME.cfg /usr/sbin/$BASENAME -c -q -V -f $CFG
} }
rhstatus() { rhstatus() {