-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncer2
executable file
·88 lines (80 loc) · 2.18 KB
/
syncer2
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
#!/bin/bash
servlet_name=${PRJ_NAME:=${TM_PROJECT_DIRECTORY##*/}}
servlet_name=${servlet_name:=$1}
#
# make sure we're in a project, and thus wanna try to sync
#
if [ -z "$servlet_name" ]
then
## not in a project so exit quickly and quietly
exit
fi
#
# Try to find the destination directory
#
if [[ -d ${CATALINA_HOME}/webapps/${servlet_name}/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/${servlet_name}/
elif [[ -d ${CATALINA_HOME}/webapps/${servlet_name}DS/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/${servlet_name}DS/
elif [[ ( "$servlet_name" == "ds-core-web" || \
"$servlet_name" == "ds-core-lib" ) \
&& -d ${CATALINA_HOME}/webapps/lmDS/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/lmDS/
elif ! [[ -z "$PRJ_NAME" ]]
then
echo project "$PRJ_NAME" is not deployed
exit 1;
else
exit
fi
#
# find the root of the project
#
project_path=${TM_PROJECT_DIRECTORY:=$2}
pushd $project_path > /dev/null
while ! [ -d src ] && [ $(pwd) != "/" ]; do cd ..; done
project_path=$(pwd)
popd > /dev/null
if [ $project_path == "/" ]
then
echo I do not understand this projects directory structure
exit 1
fi
#
# find modified files and sync them
#
if [[ -d ${project_path}/src/main/webapp ]]
then
pushd ${project_path}/src/main/webapp > /dev/null
files=`svn status | grep -v ^D | cut -c8- | sort -u`
for s in $files
do
if [ -d $s ]
then
rsync -rc $s ${servlet_path}${s%/*} --exclude=.svn --out-format="sync: %f"
elif ! [ -e ${servlet_path}$s ] || [ "$(sum $s | cut -d' ' -f1-2)" != "$(sum ${servlet_path}$s | cut -d' ' -f1-2)" ]
then
echo sync: $s
cp $s ${servlet_path}$s
fi
done
popd > /dev/null
fi
if [[ -d ${project_path}/src/main/resources ]]
then
pushd ${project_path}/src/main/resources > /dev/null
files=`svn status | grep -v ^D | grep -v application-config | cut -c8- | sort -u`
for s in $files
do
if [ "$(sum $s | cut -d' ' -f1-2)" != "$(sum ${servlet_path}WEB-INF/classes/$s | cut -d' ' -f1-2)" ]
then
echo sync: $s
cp $s ${servlet_path}WEB-INF/classes
fi
done
popd > /dev/null
fi
exit