source: branches/2.2.9/mindi/rootfs/sbin/LogIt @ 2723

Last change on this file since 2723 was 2723, checked in by Bruno Cornec, 9 years ago
  • Adds a restore quiet option
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1#!/bin/sh
2#
3# $Id: LogIt 2723 2011-02-25 18:00:17Z bruno $
4#
5
6currdate="`date '+%H:%M'`"
7
8if [ _"$LOGFILE" = _"" ]; then
9    echo "LOGFILE was undefined. Using /tmp/mondorestore2.log"
10    LOGFILE="/tmp/mondorestore2.log"
11fi
12
13if [ ! -e "$LOGFILE" ] ; then
14    echo "Start of Restore" > $LOGFILE
15    echo "----------------" >> $LOGFILE
16    echo "Date: `date`" >> $LOGFILE
17    echo "----------------" >> $LOGFILE
18    if [ "`grep -i quiet /proc/cmdline`" ]; then
19        echo "QUIET mode activated. Only error msgs are printed" >> $LOGFILE
20        echo "----------------" >> $LOGFILE
21    fi
22fi
23
24# LogIt $phrase ------ log only
25# LogIt $phrase 1 ---- log & display
26# LogIt $phrase 2 ---- log & display w/o LF
27# LogIt $prhase 3 ---- log & display, blanking the current screen line
28#                      before displaying message _with_ LF
29# LogIt $phrase 9 ---- log IF --verbose is ON
30
31if [ "$#" = "1" ] ; then
32    echo -e "$currdate $1" >> $LOGFILE
33elif [ "$#" = "2" ] ; then
34    if [ "$2" = "0" ] ; then
35        echo -e "$currdate $1" >> $LOGFILE
36    elif [ "$2" = "1" ] ; then
37        if [ "`grep -i quiet /proc/cmdline`" ]; then
38        else
39            echo -e "$1"
40        fi
41        echo -e "$currdate $1" >> $LOGFILE
42    elif [ "$2" = "2" ] ; then
43        if [ "`grep -i quiet /proc/cmdline`" ]; then
44        else
45            echo -e -n "                                                                                \r$1\r"
46        fi
47        echo -e "$currdate $1" >> $LOGFILE
48    elif [ "$2" = "3" ] ; then
49        if [ "`grep -i quiet /proc/cmdline`" ]; then
50        else
51            echo -e -n "                                                                                \r$1\n"
52        fi
53        echo -e "$currdate $1" >> $LOGFILE
54    elif [ "$2" = "9" ] ; then
55        if [ "$DEBUGGING" = "yes" ] ; then
56            echo -e "$currdate $1" >> $LOGFILE
57        fi
58    else
59        LogIt "LogIt '$1' '$2' .. unknown 2nd param"
60        exit 1
61    fi
62else
63    LogIt "LogIt '$1' .. silly params"
64    exit 1
65fi
66
67
68exit 0
Note: See TracBrowser for help on using the repository browser.