-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
executable file
·61 lines (53 loc) · 1.36 KB
/
main.sh
File metadata and controls
executable file
·61 lines (53 loc) · 1.36 KB
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
#!/bin/bash
echo "Tracking the gradle run process ..."
echo "project_dir : $1"
echo "email : $2"
# -z means empty
if [ -z "$1" ]; then
echo "project_dir is empty"
exit 1
fi
if [ -z "$2" ]; then
echo "email is empty"
exit 1
fi
# if email domain is not handong.ac.kr, exit
if [[ $2 != *@handong.ac.kr ]]; then
echo "email domain is not handong.ac.kr"
exit 1
fi
# -n means not empty
if [ -n "$3" ]; then
echo "log file : $3"
log_file=$3
fi
# variables
project_dir=$1
email=$2
sender="codemodel@ubuntu"
# start time
init_time=$(date +%s)
# gradle run
cd $project_dir
gradle clean run
# finish time
fin_time=$(date +%s)
# Path: main.sh
mail_title="Gradle Run Complete Notification"
# send mail after run
if [ -n "$3" ]; then
echo "Gradle run complete on $project_dir
====================================
Start time : $(date -d @$init_time)
Finish time : $(date -d @$fin_time)
====================================
Elapsed time : $(($fin_time - $init_time)) seconds
====================================" | mail -s "$mail_title" -aFrom:$sender -A "$log_file" "$email"
else
echo "Gradle run complete on $project_dir
====================================
Start time : $(date -d @$init_time)
Finish time : $(date -d @$fin_time)
Elapsed time : $(($fin_time - $init_time)) seconds
====================================" | mail -s "$mail_title" "$email"
fi