-
Notifications
You must be signed in to change notification settings - Fork 7
/
command.sh
106 lines (94 loc) · 3.69 KB
/
command.sh
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
#!/bin/bash
current_path=$(pwd)
# check param
if [[ $1 != "open" ]] && [[ $1 != "subscribe" ]] && [[ $1 != "publish" ]] && [[ $1 != "publishJson" ]] && [[ $1 != "status" ]] && [[ $1 != "getEvent" ]] && [[ $1 != "general" ]] && [[ $1 != "listGroup" ]] && [[ $1 != "sendFile" ]] && [[ $1 != "receiveFile" ]];then
echo "Usage:"
echo " ./command.sh listGroup"
echo " ./command.sh open groupId topicName"
echo " ./command.sh subscribe groupId topicName"
echo " ./command.sh publish groupId topicName content"
echo " ./command.sh publishJson groupId topicName content"
echo " ./command.sh getEvent groupId eventId(After an event is successfully published, the eventid of the event is returned)"
echo " ./command.sh status groupId topicName"
echo " ./command.sh sendFile groupId topicName filePath"
echo " ./command.sh receiveFile groupId topicName"
echo " ./command.sh general groupId"
exit 1
fi
if [[ $1 == "listGroup" ]];then
brokerUrl=$(grep "broker.url" ${current_path}/dist/conf/application.properties| head -1 | awk -F'=' '{print $NF}' | sed s/[[:space:]]//g)
if [[ $? -ne 0 ]];then
echo "get brokerUrl fail"
exit 1
fi
listGroup_response=$(curl -s "$brokerUrl/admin/listGroup")
echo "listGroup result: $listGroup_response"
exit 1
fi
if [[ $1 == "general" ]];then
brokerUrl=$(grep "broker.url" ${current_path}/dist/conf/application.properties| head -1 | awk -F'=' '{print $NF}' | sed s/[[:space:]]//g)
if [[ $? -ne 0 ]];then
echo "get brokerUrl fail"
exit 1
fi
general_response=$(curl -s "$brokerUrl/admin/group/general?groupId=$2")
echo "general result: $general_response"
exit 1
fi
if [[ $1 == "open" ]] && [[ $# -ne 3 ]];then
echo "Usage:"
echo " ./command.sh open groupId topicName"
exit 1
fi
if [[ $1 == "subscribe" ]] && [[ $# -ne 3 ]];then
echo "Usage:"
echo " ./command.sh subscribe groupId topicName"
exit 1
fi
if [[ $1 == "publish" ]] && [[ $# -ne 4 ]];then
echo "Usage:"
echo " ./command.sh publish groupId topicName content"
exit 1
fi
if [[ $1 == "publishJson" ]] && [[ $# -ne 4 ]];then
echo "Usage:"
echo " ./command.sh publishJson groupId topicName content"
exit 1
fi
if [[ $1 == "status" ]] && [[ $# -ne 3 ]];then
echo "Usage:"
echo " ./command.sh status groupId topicName"
exit 1
fi
if [[ $1 == "getEvent" ]] && [[ $# -ne 3 ]];then
echo "Usage:"
echo " ./command.sh getEvent groupId eventId"
exit 1
fi
if [[ $1 == "sendFile" ]] && [[ $# -ne 4 ]];then
echo "Usage:"
echo " ./command.sh sendFile groupId topicName filePath"
exit 1
fi
if [[ $1 == "receiveFile" ]] && [[ $# -ne 3 ]];then
echo "Usage:"
echo " ./command.sh receiveFile groupId topicName"
exit 1
fi
# Mac OS X || GNU/Linux
if [[ "$(uname)" == "Darwin" ]] || [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]];then
if [[ $1 == "publish" ]] || [[ $1 == "publishJson" ]] || [[ $1 == "sendFile" ]];then
"${JAVA_HOME}"/bin/java -cp dist/conf/:dist/lib/*:dist/apps/* com.webank.weevent.demo.JavaSDKSample $1 $2 $3 $4
else
"${JAVA_HOME}"/bin/java -cp dist/conf/:dist/lib/*:dist/apps/* com.webank.weevent.demo.JavaSDKSample $1 $2 $3
fi
# Windows
elif [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]];then
if [[ $1 == "publish" ]] || [[ $1 == "publishJson" ]] || [[ $1 == "sendFile" ]];then
"${JAVA_HOME}"/bin/java -cp 'dist/conf/;dist/lib/*;dist/apps/*' com.webank.weevent.demo.JavaSDKSample $1 $2 $3 $4
else
"${JAVA_HOME}"/bin/java -cp 'dist/conf/;dist/lib/*;dist/apps/*' com.webank.weevent.demo.JavaSDKSample $1 $2 $3
fi
else
echo "Unknown os:" $(uname -s)
fi