File: sendreport.sh

package info (click to toggle)
klic 3.003-1.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,068 kB
  • ctags: 6,333
  • sloc: ansic: 101,584; makefile: 3,395; sh: 1,321; perl: 312; exp: 131; tcl: 111; asm: 102; lisp: 4; sed: 1
file content (154 lines) | stat: -rwxr-xr-x 2,973 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh

TOADDR=klic-report@klic.icot.or.jp

ask_yes_or_no () {
    set_var=$2;
    do_ask=true;
    if [ -n "$set_var" ]; then eval "default=\$$set_var"; do_ask=$def_ask;
    else default=""; fi
    if [ -z "$default" ]; then default=$1; do_ask=true; fi
    if [ "$set_var" = USE_DEFAULT ]; then set_var=''; do_ask=$def_ask; fi
    echo $n " (yes or no)"$c
    while true ; do
	echo $n " [$default] "$c
	if $do_ask ; then read ans; else echo $default; ans=$default; fi
	if test -z "$ans" ; then ans=$default; fi
	if [ -n "$set_var" ]; then echo "$set_var='$ans'" >> config.tmp; fi
	case $ans in
	yes) return 0;;
	no) return 1;;
	*) echo $n "Please input yes or no"$c;;
	esac
	do_ask=true
    done
}

concat_string () {
   if [ x"$1" = x ]; then
     eval $3="$2"
   else
     if [ x"$2" = x ]; then
       eval $3="$1"
     else
       eval $3=\"$1 $2\"
     fi
  fi
}

include_file () {
  source=$1
  dest=$2

  if [ ! -f $source ]; then
    echo "-------------------- $1 is not found --------------------" >>$dest
    return 0
  else
    echo "-------------------- $1 begin --------------------" >>$dest
    cat $source >>$dest
    echo "-------------------- $1 end --------------------" >>$dest
    return 1
  fi
}

if ( echo "test line\c"; echo " ") | grep c >/dev/null 2>/dev/null ; then
    n='-n'
    c=''
else
    n=''
    c='\c'
fi

MAILLOG=mail.log

cat <<GAZONK
This program checks the test results and send following files
to klic-report@klic.icot.or.jp:

	config.sh
	include/klic/config.h

GAZONK

echo $n "Can I send the above files to klic-report? "$c

if ask_yes_or_no yes; then
   :
else
   echo "Good bye!"
   exit 1
fi

cat <<GAZONK

If this program fails to send the mail, please send the contents of
the file mail.log to klic-report@klic.icot.or.jp by hands.

GAZONK

if [ x$USER = x ]; then
   USER=`whoami`
fi

cat <<GAZONK >$MAILLOG
From: $USER
To: $TOADDR
Subject: KLIC installation report

GAZONK

echo $n 'Platform: ' >>$MAILLOG

uname -a  >>$MAILLOG

echo >>$MAILLOG

IMP=0

if [ -f tests.log ]; then
   IMP=1
   cat tests.log >>$MAILLOG
fi

if [ -f disttests.log ]; then
   IMP=1
   cat disttests.log >>$MAILLOG
fi

if [ -f shmtests.log ]; then
   IMP=1
   cat shmtests.log >>$MAILLOG
fi

if [ $IMP -eq 0 ]; then
   echo "No implemetation was installed." >>$MAILLOG
fi

include_file config.sh $MAILLOG
include_file include/klic/config.h $MAILLOG


for sm in /usr/lib /usr/bin /usr/sbin /bin /sbin; do
   if [ -x $sm/sendmail ]; then
      SENDMAIL=$sm/sendmail
   fi
done

if [ x$SENDMAIL = x ]; then
   echo 'sendmail program not found.'
   echo 'Please send mail.log to klic-report@klic.icot.or.jp by hand.'
   echo 'Thanks in advance.'
else
   echo $n 'Sending mail...'

   if $SENDMAIL $TOADDR <$MAILLOG; then
      echo 'done.'
      echo 'Thanks for your coorperation.'
   else
      echo 'Failed to send mail.'
      echo 'Please send mail.log to klic-report@klic.icot.or.jp by hand.'
      echo 'Thanks in advance.'
   fi
fi

exit 0