-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunMV.sh
executable file
·405 lines (303 loc) · 9.08 KB
/
runMV.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#!/bin/bash
# -*- coding: utf-8 -*-
################################################
# >>>>>>> VAR SCRIPTS
################################################
VERSION=0.3
NAME=$(basename $0)
NM=$0
AUTHOR="@svg153 (based on garquiscript.sh by @mrgarri)"
CUR_DIR="$(pwd)"
bold=`tput bold`
normal=`tput sgr0`
UPDATE_source=https://raw.githubusercontent.com/svg153/SOS_prac2SOAP.15162S/master/runMV.sh
H="-h"
HELP="--help"
V="-v"
VER="--version"
U="-u"
UPD="--update"
function mostrar_descargando {
echo -ne "Downloading files. \r"
sleep 0.5
echo -ne "Downloading files.. \r"
sleep 0.5
echo -ne "Downloading files...\r"
sleep 0.5
}
function download {
wget --quiet --output-document=$1 $2 &
while [[ $(ps | grep -c "wget") -gt 0 ]]
do
mostrar_descargando
done
printf "\rDone!\n"
}
function actualizar {
# Download new version
download $CUR_DIR/$NAME.tmp $UPDATE_source
# Copy over modes from old version
OCTAL_MODE=$(stat -c '%a' $0)
chmod $OCTAL_MODE $CUR_DIR/$NAME.tmp
# Overwrite old file with new
mv -f $CUR_DIR/$NAME.tmp $NAME
if [[ $? == 0 ]]
then
NEWVER=$(head ${NM} | grep "VERSION=" | sed 's/[^0-9.]//g')
if [[ $NEWVER != $VERSION ]]
then
echo "Succesfully updated to version $NEWVER!"
else
echo "No updates found."
fi
exit 0
else
echo "There was an error performing the update, please try again later. Exit code: $?"
exit 1
fi
}
function print_version_corta {
printf "\n$NAME ${bold}v$VERSION${normal}. LastUpdate:$(date -r $NAME). By $AUTHOR.\n\n"
}
function print_version {
printf "\n${bold}$NAME version:${normal} $VERSION.\n\n"
printf "${bold}Last updated:${normal} $(date -r $NAME).\n\n"
printf "${bold}Author:${normal} $AUTHOR.\n\n"
}
function print_nombre {
printf "${bold} $NAME ${normal} \n"
}
function mostrar_ayuda {
print_acciones_script
printf "\n"
texto_uso
printf "\n"
printf "OPCIONES:\n"
print_opciones
printf "\n"
printf "Otras opciones:\n"
print_otras_opciones
printf "\n"
printf "You can ask my cat now how this script works and she'll just meaow you.\n"
printf "\n"
}
function print_otras_opciones {
printf "\t${bold}$H or $HELP:${normal} Shows help text.\n"
printf "\t${bold}$V or $VER:${normal} Shows actual version of the script.\n"
printf "\t${bold}$U or $UPD:${normal} Auto-updates the script to the latest version.\n"
}
################################################
# <<<<<<< VAR SCRIPTS
################################################
WJ="-wj"
WSDL2JAVA="--wsdl2java"
UP="-up"
DESPLEGAR="--desplegar"
SDW="-sd"
APAGAR="--apagar"
ENT="-ent"
ENTREGA="--entrega"
PATHBASE=/home/lsduser/software2015_linux
ANT_HOME=${PATHBASE}/apache-ant-1.9.7
CATALINA_HOME=${PATHBASE}/apache-tomcat-7.0.59
WEB_TOM=http://localhost:8080
TOM_UP=${CATALINA_HOME}/bin/startup.sh
TOM_DW=${CATALINA_HOME}/bin/shutdown.sh
# log de Tomcat
# $> $CATALINA_HOME /logs/catalina.out
WAR_TOM=${CATALINA_HOME}/webapps/axis2.war
AXIS2_HOME=${PATHBASE}/axis2-1.6.2
WAR_AXIS2=${AXIS2_HOME}/dist/axis2.war
# $AXIS2_HOME/webapp y construir la aplicación web utilizando ant
# $> $AXIS2_HOME/webapp ant
export TOM_UP=${TOM_UP}
export TOM_DW=${TOM_DW}
# Creamos las varibles aqui para que tengan ambito global
WSDL_PATH=""
JAVA_PROYECT_PATH=""
JAVA_NAME=""
ARR_PATH=""
CLIENTE_FOLDER="cliente"
SERVICIO_FOLDER="servicio"
function texto_uso {
printf "Usage: ${bold}$0 { $H | $HELP | $WJ | $WSDL2JAVA | $UP | $DESPLEGAR | $SDW | $APAGAR | $ENT | $ENTREGA }${normal}\n"
}
function mostrar_uso {
texto_uso
}
function print_opciones {
printf "\t${bold}$CO or $COMP:${normal} Compila: \"${FICH_BASE}\".\n"
printf "\n"
}
function print_acciones_script {
printf "ACCIONES:\n"
printf ${bold}
printf " * \n"
printf ${normal}
}
function wsdl2java_func {
printf "wsdl2java: Create a sketelon from WSDL file\n"
printf "Write the complete path of WSDL file: \n"
read $WSDL_PATH
printf "Write the complete path of your java proyect: \n"
read $JAVA_PROYECT_PATH
printf "Write the java package name: \n"
read $JAVA_NAME
cd $JAVA_PROYECT_PATH
$AXIS2_HOME/bin/wsdl2java.sh -s -ss -sd -wv 2.0 -p $JAVA_PROYECT_PATH/$JAVA_NAME -d adb -uri $WSDL_PATH
# $AXIS2_HOME/bin/wsdl2java.sh -s -ss -sd -wv 2.0 -p userManagement -d adb -uri UserManagement.wsdl
#TODO: control de errores de AXIS" wsdl2java.sh
# printf "Make '${bold}$JAVA_NAME${normal}' in path '${bold}$JAVA_PROYECT_PATH${normal}'\n"
cd $CUR_DIR
}
function crearPaqueteAAR {
if [[ $JAVA_PROYECT_PATH == "" || $JAVA_NAME == "" ]] ; then
crearPaqueteAAR_IMPUT
else
#crearPaqueteAAR_DEFECTO
cd $JAVA_PROYECT_PATH
ant
ARR_PATH="$JAVA_PROYECT_PATH/build/lib/$JAVA_NAME.aar"
fi
}
function desplegarAAR {
if [[ $ARR_PATH == "" || $JAVA_NAME="" ]] ; then
desplegarAAR_IMPUT
else
#desplegarAAR_DEFECTO
ln -s $ARR_PATH $CATALINA_HOME/webapps/axis2/WEB-INF/services/$JAVA_NAME.aar
fi
}
function montarAPP {
printf "wsdl2java: Create a sketelon from WSDL file\n"
# Crear el paquete para desplegar
crearPaqueteAAR
# Desplegar el servicio
desplegarAAR
}
function generarStub {
printf "generarStub: genera el stub para el cliente\n"
printf "wsdl2java: Create a sketelon from WSDL file\n"
printf "Write the complete path of WSDL file: \n"
read $WSDL_PATH
printf "Write the complete path of your java proyect: \n"
read $JAVA_PROYECT_PATH
printf "Write the java package name: \n"
read $JAVA_NAME
cd $JAVA_PROYECT_PATH
$AXIS2_HOME/bin/wsdl2java.sh -uri $WSDL_PATH -wv 2.0 -p $JAVA_NAME -d adb
#TODO: control de errores de AXIS" wsdl2java.sh
# printf "Make '${bold}$JAVA_NAME${normal}' in path '${bold}$JAVA_PROYECT_PATH${normal}'\n"
cd $CUR_DIR
}
################################################
# ------ MAIN
################################################
case "$1" in
"$H")
mostrar_uso
exit 0
;;
"$HELP")
#@TODO: Hacer la funcion
mostrar_ayuda
exit 0
;;
"$V")
print_version_corta
exit 0
;;
"$VER")
print_version
exit 0
;;
"$U")
actualizar
exit 0
;;
"$UPD")
actualizar
exit 0
;;
"$WJ" | "$WSDL2JAVA")
wsdl2java_func
exit 0
;;
"$UP" | "$DESPLEGAR")
source ~/.bashrc
echo "Paramos axis2..."
$CATALINA_HOME/bin/shutdown.sh
# activo=$(ps -aux | grep axis2 | wc -l)
# echo $activo
# if [ $activo > 0 ]; then
# LOG=
# else
# LOG="TRUE"
# fi
JAVA_NAME="UserManagementWS"
ARR_PATH="/home/lsduser/workspace/$SERVICIO_FOLDER/build/lib/$JAVA_NAME.aar"
cd $SERVICIO_FOLDER
rm ARR_PATH
echo "Crearmos el fichero echo '$JAVA_NAME.aar'"
ant
# TODO mirar que se hizo bien en caso contrario no avanzar
cd ..
#desplegarAAR_DEFECTO
# No se puede hacer esto por que tomcat no reconoce que haya cambiado
# ln -s $ARR_PATH $CATALINA_HOME/webapps/axis2/WEB-INF/services/$JAVA_NAME.aar
echo "Borramos el fichero antiguo '$JAVA_NAME.aar' de axis2"
rm $CATALINA_HOME/webapps/axis2/WEB-INF/services/$JAVA_NAME.aar
echo "Copiamos el nuevo '$JAVA_NAME.aar' en axis2"
cp $ARR_PATH $CATALINA_HOME/webapps/axis2/WEB-INF/services/$JAVA_NAME.aar
echo "Arrancamos axis2..."
$CATALINA_HOME/bin/startup.sh
# TODO solo cuando no este una ventana ya abierta
# gnome-terminal --title="logTomcatTerminal" --command="tail -f --lines=20 $CATALINA_HOME/logs/catalina.out"
# gnome-terminal --title="logTomcatDebbugTerminal" --command="tail -f --lines=20 $CATALINA_HOME/logs/catalina.out | grep --line-buffered 'DEBBUG'"
# echo "$LOG" && echo "OK"
# if [ -z "$LOG"]; then
# LOG="TRUE"
# export $LOG
# source ~/.bashrc
# echo $LOG
# fi
#
# ping http://localhost:8080/axis2/services/listServices
# Ejercutar el JAVA del cliente
# cd $CLIENTE_FOLDER
# javac
# cd ..
exit 0
;;
"$SDW" | "$APAGAR")
$CATALINA_HOME/bin/shutdown.sh
# LOG=
# export LOG
# source ~/.bashrc
# echo $LOG
exit 0
;;
"$ENT" | "$ENTREGA")
# pedimos al user el nombre de la carpeta
echo "Introduccior el primer apellido de cada autor. Ejemplo: Pepe Garcia y Jose Perez --> garciaperez"
read NAMEENTREGA
if [ -d "$NAMEENTREGA" ]; then
rm -r $NAMEENTREGA
fi
mkdir $NAMEENTREGA
JAVA_NAME="UserManagementWS"
ARR_PATH="/home/lsduser/workspace/$SERVICIO_FOLDER/build/lib/$JAVA_NAME.aar"
cp $ARR_PATH ./$NAMEENTREGA/$JAVA_NAME.aar
# @CHANGE: por otro user
cp -r ./$SERVICIO_FOLDER ./$NAMEENTREGA/servicio
cp -r ./$CLIENTE_FOLDER ./$NAMEENTREGA/cliente
cp /home/lsduser/workspace/$SERVICIO_FOLDER/src/UserManagement/UserManagementWSSkeleton.java ./$NAMEENTREGA/UserManagementWSSkeleton.java
rm "$NAMEENTREGA.rar"
rar a -r -c- $NAMEENTREGA.rar ./$NAMEENTREGA/
rm -r $NAMEENTREGA
exit 0
;;
*)
mostrar_ayuda
exit 0
esac