-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_kalibro_service.sh
executable file
·53 lines (45 loc) · 1.47 KB
/
update_kalibro_service.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
#!/bin/bash
TOMCAT_HOME="/var/lib/tomcat6/webapps"
error() {
echo -en "\e[00;31m"
echo "Parameters error."
echo "Please, choose a valid database: [mysql|postgres]"
echo -en "\e[01;29m"
exit
}
if [ $# -ne 1 ]; then
error
fi
echo " * Exporting Kalibro .war file."
ant -f build.xml
echo " * Erasing old kalibro database entries."
if [ $1 == "mysql" ]; then
sudo service tomcat6 stop
sudo mysql kalibro -e "drop database kalibro;
drop database kalibro_test;
create database kalibro;
create database kalibro_test;
grant all on kalibro.* to 'kalibro'@'localhost';
grant all on kalibro_test.* to 'kalibro'@'localhost';
flush privileges;"
elif [ $1 == "postgres" ]; then
sudo service tomcat6 stop
echo -en "\t > Please, type your kalibro database password: "
stty -echo
read
stty echo
echo
export PGPASSWORD=$REPLY
psql -q -U postgres -c "drop database kalibro"
psql -q -U postgres -c "drop database kalibro_test"
psql -q -U postgres -c "create database kalibro with owner=kalibro"
psql -q -U postgres -c "create database kalibro_test with owner=kalibro"
else
error
fi
echo " * Updating Kalibro Service."
sudo rm -rf $TOMCAT_HOME/KalibroService
sudo chown tomcat6:tomcat6 KalibroService.war
sudo mv KalibroService.war $TOMCAT_HOME
sudo chown tomcat6.tomcat6 $TOMCAT_HOME/KalibroService.war
sudo service tomcat6 start