Changeset 2685


Ignore:
Timestamp:
Sep 17, 2010, 12:51:29 AM (8 years ago)
Author:
bruno
Message:

r4071@localhost: bruno | 2010-09-17 00:34:28 +0200

  • Die and related functions placed before any other code as used early, and ash doesn't support function declaration. So will solve #446 by exiting mindi before doing anything weird in it.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi/mindi

    r2681 r2685  
    109109fi
    110110
     111# Last function called before exiting
     112# Parameter is exit code value
     113# Should be declared here as used immediately below potentialy
     114MindiExit() {
     115    echo "Mindi $MINDI_VERSION is exiting" >> $LOGFILE
     116    echo "End date : `date`" >> $LOGFILE
     117    if [ _"$MONDO_SHARE" != _"" ] ; then
     118        echo "------------- mindi logfile included -------------------------" >> /var/log/mondoarchive.log
     119        cat $LOGFILE >> /var/log/mondoarchive.log
     120        echo "--------------------------------------------------------------">> /var/log/mondoarchive.log
     121    fi
     122
     123    cd /
     124    sync&
     125
     126    # Clean temporary files only when standalone mindi
     127    if [ _"$MINDI_TMP" != _"$MONDO_TMP" ]; then
     128        rm -Rf $MINDI_TMP
     129    fi
     130    exit $1
     131}
     132
     133LogIt() {
     134    if [ -e /dev/stderr ] ; then
     135        echo -e "$1" >> /dev/stderr
     136    elif [ -e /usr/bin/logger ] ; then
     137        /usr/bin/logger -s $1
     138    fi
     139    echo -e "$1" >> $LOGFILE
     140    if [ _"$2" != _"" ]; then
     141        grep -Ev "tar: Removing \`/\'" "$2" >> $LOGFILE
     142    fi
     143    rm -f "$2"
     144}
     145
     146
     147Die() {
     148    local i
     149    if [ "$1" = "" ] ; then
     150        LogIt "FATAL ERROR"
     151    else
     152        LogIt "FATAL ERROR. $1"
     153    fi
     154    if [ _"$2" != _"" ]; then
     155        grep -Ev "tar: Removing \`/\'" "$2" >> $LOGFILE
     156    fi
     157    rm -f "$2"
     158
     159    LogIt "Please e-mail a copy of $LOGFILE to the mailing list."
     160    LogIt "See http://www.mondorescue.org for more information."
     161    LogIt "WE CANNOT HELP unless you enclose that file.\n"
     162    MindiExit -1
     163}
     164
    111165# Now we can create what we need
    112166MINDI_TMP=`mktemp -d $TMPDIR/mindi.XXXXXXXXXX`
     
    237291    done
    238292    echo $r
    239 }
    240 
    241 
    242 # Last function called before exiting
    243 # Parameter is exit code value
    244 MindiExit() {
    245     echo "Mindi $MINDI_VERSION is exiting" >> $LOGFILE
    246     echo "End date : `date`" >> $LOGFILE
    247     if [ _"$MONDO_SHARE" != _"" ] ; then
    248         echo "------------- mindi logfile included -------------------------" >> /var/log/mondoarchive.log
    249         cat $LOGFILE >> /var/log/mondoarchive.log
    250         echo "--------------------------------------------------------------">> /var/log/mondoarchive.log
    251     fi
    252 
    253     cd /
    254     sync&
    255 
    256     # Clean temporary files only when standalone mindi
    257     if [ _"$MINDI_TMP" != _"$MONDO_TMP" ]; then
    258         rm -Rf $MINDI_TMP
    259     fi
    260     exit $1
    261 }
    262 
    263 Die() {
    264     local i
    265     if [ "$1" = "" ] ; then
    266         LogIt "FATAL ERROR"
    267     else
    268         LogIt "FATAL ERROR. $1"
    269     fi
    270     if [ _"$2" != _"" ]; then
    271         grep -Ev "tar: Removing \`/\'" "$2" >> $LOGFILE
    272     fi
    273     rm -f "$2"
    274 
    275     LogIt "Please e-mail a copy of $LOGFILE to the mailing list."
    276     LogIt "See http://www.mondorescue.org for more information."
    277     LogIt "WE CANNOT HELP unless you enclose that file.\n"
    278     MindiExit -1
    279293}
    280294
     
    906920    echo "$output"
    907921    return 0
    908 }
    909 
    910 
    911 LogIt() {
    912     if [ -e /dev/stderr ] ; then
    913         echo -e "$1" >> /dev/stderr
    914     elif [ -e /usr/bin/logger ] ; then
    915         /usr/bin/logger -s $1
    916     fi
    917     echo -e "$1" >> $LOGFILE
    918     if [ _"$2" != _"" ]; then
    919         grep -Ev "tar: Removing \`/\'" "$2" >> $LOGFILE
    920     fi
    921     rm -f "$2"
    922922}
    923923
Note: See TracChangeset for help on using the changeset viewer.