-
Notifications
You must be signed in to change notification settings - Fork 3
/
dummy-vnfm.sh
executable file
·131 lines (111 loc) · 3.21 KB
/
dummy-vnfm.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
_openbaton_base="/opt/openbaton"
_dummy_vnfm_base="${_openbaton_base}/dummy-vnfm-amqp/"
source ${_dummy_vnfm_base}/gradle.properties
_version=${version}
_dummy_config_file=/etc/openbaton/dummy-vnfm-amqp.properties
_screen_name="dummy-vnfm-amqp"
function check_already_running {
pgrep -f dummy-vnfm-amqp-${_version}.jar > /dev/null
if [ "$?" -eq "0" ]; then
echo "Dummy-VNFM-Amqp is already running.."
exit;
fi
}
function start {
if [ ! -d ${_dummy_vnfm_base}/build/ ]
then
compile
fi
check_already_running
if [ 0 -eq $? ]; then
screen -ls | grep -v "No Sockets found" | grep -q openbaton
screen_exists=$?
if [ "${screen_exists}" -ne "0" ]; then
echo "Starting the Dummy-VNFM-Amqp in a new screen session (attach to the screen with screen -x openbaton)"
if [ -f ${_dummy_config_file} ]; then
echo "Using external configuration file ${_dummy_config_file}"
screen -c screenrc -d -m -S openbaton -t ${_screen_name} java -jar "${_dummy_vnfm_base}/build/libs/dummy-vnfm-amqp-${_version}.jar" --spring.config.location=file:${_dummy_config_file}
else
screen -c screenrc -d -m -S openbaton -t ${_screen_name} java -jar "${_dummy_vnfm_base}/build/libs/dummy-vnfm-amqp-${_version}.jar"
fi
else
echo "Starting the Dummy-VNFM-Amqp in the existing screen session (attach to the screen with screen -x openbaton)"
if [ -f ${_dummy_config_file} ]; then
echo "Using external configuration file ${_dummy_config_file}"
screen -S openbaton -X screen -t ${_screen_name} java -jar "${_dummy_vnfm_base}/build/libs/dummy-vnfm-amqp-${_version}.jar" --spring.config.location=file:${_dummy_config_file}
else
screen -S openbaton -X screen -t ${_screen_name} java -jar "${_dummy_vnfm_base}/build/libs/dummy-vnfm-amqp-${_version}.jar"
fi
fi
fi
}
function stop {
if screen -list | grep "openbaton" > /dev/null ; then
screen -S openbaton -p ${_screen_name} -X stuff '\003'
fi
}
function restart {
kill
start
}
function kill {
if screen -list | grep "openbaton"; then
screen -ls | grep openbaton | cut -d. -f1 | awk '{print $1}' | xargs kill
fi
}
function compile {
./gradlew build -x test
}
function tests {
./gradlew test
}
function clean {
./gradlew clean
}
function end {
exit
}
function usage {
echo -e "Open-Baton dummy-vnfm\n"
echo -e "Usage:\n\t ./dummy-vnfm.sh [compile|start|stop|test|kill|clean]"
}
##
# MAIN
##
if [ $# -eq 0 ]
then
usage
exit 1
fi
declare -a cmds=($@)
for (( i = 0; i < ${#cmds[*]}; ++ i ))
do
case ${cmds[$i]} in
"clean" )
clean ;;
"sc" )
clean
compile
start ;;
"start" )
start ;;
"stop" )
stop ;;
"restart" )
restart ;;
"compile" )
compile ;;
"kill" )
kill ;;
"test" )
tests ;;
* )
usage
end ;;
esac
if [[ $? -ne 0 ]];
then
exit 1
fi
done