Add -a parameter to only run after_upgrade() function

This commit is contained in:
Benjamin Renard 2015-01-26 10:11:31 +01:00 committed by root
parent 029aec7b9e
commit d7f6ae73e1

View file

@ -22,6 +22,7 @@ NAGIOS=0
UPGRADE=0 UPGRADE=0
EXTRACT=0 EXTRACT=0
JUST_DISP=0 JUST_DISP=0
JUST_AFTER_UPGRADE=0
function usage() { function usage() {
echo "Usage : $0 [-v] [-n] [-d] [-u]" echo "Usage : $0 [-v] [-n] [-d] [-u]"
@ -29,11 +30,12 @@ function usage() {
echo " -n Nagios mode" echo " -n Nagios mode"
echo " -d Download new release" echo " -d Download new release"
echo " -u Upgrade installation" echo " -u Upgrade installation"
echo " -a Just run after_upgrade function"
echo " -j Just display current stable version" echo " -j Just display current stable version"
echo " -h Display this help" echo " -h Display this help"
} }
while getopts ":dvnhuj" opt; do while getopts ":dvnhuaj" opt; do
case $opt in case $opt in
v) v)
DEBUG=1 DEBUG=1
@ -50,6 +52,9 @@ while getopts ":dvnhuj" opt; do
DEBUG=1 DEBUG=1
EXTRACT=1 EXTRACT=1
;; ;;
a)
JUST_AFTER_UPGRADE=1
;;
j) j)
JUST_DISP=1 JUST_DISP=1
;; ;;
@ -75,6 +80,28 @@ done
[ -f "$0.local" ] && source "$0.local" && [ $DEBUG -eq 1 ] && echo "Import local config file : $0.local" [ -f "$0.local" ] && source "$0.local" && [ $DEBUG -eq 1 ] && echo "Import local config file : $0.local"
function run_after_upgrade() {
RC_NEW_HOME="$1"
type after_upgrade > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Execution de la fonction custom after_upgrade() :"
after_upgrade "$RC_NEW_HOME"
res=$?
echo "Fin de la fonction after_upgrade() (Retour : $res)"
return $res
else
echo "La fonction 'after_upgrade' n'est pas définie. On passe."
return 0
fi
}
if [ $JUST_AFTER_UPGRADE -eq 1 ]
then
run_after_upgrade "$RC_HOME"
exit $?
fi
for i in `seq 1 $MAX_CHECK` for i in `seq 1 $MAX_CHECK`
do do
tmpfile=`mktemp` tmpfile=`mktemp`
@ -246,13 +273,7 @@ then
cd "$src" cd "$src"
./bin/installto.sh "$to" ./bin/installto.sh "$to"
type after_upgrade > /dev/null 2>&1 run_after_upgrade "$to"
if [ $? -eq 0 ]
then
echo "Execution de la fonction custom after_upgrade() :"
after_upgrade "$to"
echo "Fin de la fonction after_upgrade()"
fi
if [ -L "$RC_HOME" ] if [ -L "$RC_HOME" ]
then then