Arquivos mensais: novembro 2014

Deploy UAT was -personal

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
#!/bin/bash
## versao3 (libs e backup)
## Este script tem como objetivo atualizar os wars e o site do servidor de teste com os dados do servidor de desenvolvimento.
echo "Iniciando atualizacao..."
echo "Definindo valores..."
host_local="10.75.253.194"
host_remoto="10.75.253.149"
user_remoto="z300176"
data=`date +%d-%m-%Y_%H:%M:%S`
bkp_home=~/BACKUP_MSTUDIO/bkp_$data
app_home="/app"
wars_home="/app/wars"
deploy_tmp="/app/deploy_tmp"
jbosss_home="/app/jboss/jboss-eap-5.1/jboss-as"
libs_home="/app/jboss/jboss-eap-5.1/jboss-as/common/lib"
site_home="/app/MeritiaFile/projectData/project/personal"
wars_remoto="/app/wars"
site_remoto="/app/MeritiaFile/projectData/project/personal"
repositorio="/app/MeritiaFile/projectData/project/personal/personal/integration/repositories"
 
	copiar (){
		echo "Buscando novos wars do servidor $host_remoto"
		scp -r $user_remoto@$host_remoto:$wars_remoto/* $deploy_tmp/wars/ > $deploy_tmp/scp_wars.log
		echo "ok!"
		echo "copiando novos arquivos wars para $wars_home..."
		cp -rf $deploy_tmp/wars/* $wars_home/
		echo "ok!"
		echo "Buscando site atualizado do servidor $host_remoto"
		scp -r $user_remoto@$host_remoto:$site_remoto $deploy_tmp/site/ > $deploy_tmp/scp_site.log
		echo "ok!"
		echo "Copiando novos arquivos do site para $site_home"
		cp -rf $deploy_tmp/site/personal/personal/* $site_home/personal/
		echo "ok!"
 
		echo "Atualizando libs... $libs_home"
		echo "Buscando libs do servidor $host_remoto"
		scp -r $user_remoto@$host_remoto:$libs_home $deploy_tmp/ > $deploy_tmp/scp_wars.log
		cp -rf $deploy_tmp/lib/* $libs_home/
		echo "ok!"
 
		echo "Adequando novos arquivos para o servidor $host_local"
		grep -rl $host_remoto $site_home |xargs sed -i s/$host_remoto/$host_local/g
		cp -rf $deploy_tmp/repositories/* $repositorio/
		echo "limpando pasta $deploy_tmp"
		rm -r $deploy_tmp
	reeiniciar
	}
 
	reeiniciar (){
		echo "Reeiniciando o jboss..."
		kill -9 `ps aux |grep java|awk '{print $2}'`
		$jbosss_home/bin/shutdown.sh -S
		sh $app_home/start.sh
		echo "Ok"
		exit
	}
echo "Criando diretorios para backup..."
mkdir $bkp_home
mkdir $deploy_tmp
mkdir $deploy_tmp/wars
mkdir $deploy_tmp/site
echo "Parando o jboss..."
kill -9 `ps aux |grep java|awk '{print $2}'`
 
echo "Executando backup..."
cp -rf $wars_home $bkp_home/
cp -rf $site_home $bkp_home/
cp -rf $repositorio $deploy_tmp/
cp -rf $libs_home $bkp_home/
echo "Verificando backup..."
total_wars=`du -sh $wars_home | awk '{print $1}'`
total_wars_bkp=`du -sh $bkp_home/wars | awk '{print $1}'`
total_site=`du -sh $site_home/personal | awk '{print $1}'`
total_site_bkp=`du -sh $bkp_home/personal | awk '{print $1}'`
 
	if [ $total_wars = $total_wars_bkp -a $total_site = $total_site_bkp ];then
		echo "Backup bem sucedido!"
		copiar
		exit
	else
		echo "O backup em [$bkp_home] nao confere com [$wars_home]"
		echo "Informacoes:"
		echo "$wars_home: $total_wars"
		echo "$bkp_home/wars: $total_wars_bkp"
		echo "$site_home/personal: $total_site"
		echo "$bkp_home/personal: $total_site_bkp"
		echo "Nao pode prosseguir..."
		exit
	fi
# Desenvolvido por Marcelo Viana - Analista em Redes Linux.
# É o Senhor que mostra os caminhos.