-
Notifications
You must be signed in to change notification settings - Fork 0
/
freshbuild-mysql.sh
169 lines (147 loc) · 4.44 KB
/
freshbuild-mysql.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
#!/bin/bash
SFABASE="/e/_joshyu_/data/IBM_projects/sfa"
GITDIR="$SFABASE/gitrepos/Mango"
BUILDPHPDIR="$GITDIR/build/rome"
SFAUTIL="$SFABASE/gitrepos/sfautils"
WEBSUGARROOT="$SFABASE/builds/ult/sugarcrm"
GITDIR=$SFABASE/gitrepos/Mango
LOCATIONDIR=$SFABASE/builds
BUILDPHPDIR=$GITDIR/build/rome
MYSQLBIN="/e/server/mysql55/bin"
MYSQLUNAME='root'
MYSQLUPASS='joshyupeng'
flavor="ult"
version="6.4.0"
location_sugarbase=$LOCATIONDIR/$flavor/sugarcrm
INSTALL_URL="http://localhost:81/install.php?goto=SilentInstall&cli=true";
installType="$1"
haswebdir='';
#=========================================================================================
# subs
#=========================================================================================
do_dropdatabase(){
echo "now drop database sugarcrm";
pushd $MYSQLBIN > /dev/null 2>&1
mysql -u$MYSQLUNAME -p$MYSQLUPASS -C -e"drop database sugarcrm";
errorcode=$?;
popd > /dev/null 2>&1
if [ $errorcode == 0 ];then
echo "drop database OK";
else
echo "drop database Fail.";
return 255;
fi
}
do_cover(){
echo "cover config_si file to sugarcrm build";
if [ -e "$SFAUTIL/config_si.php" ]
then
cp "$SFAUTIL/config_si.php" "$location_sugarbase" ;
fi
}
do_restore(){
if [ ! -z "$haswebdir" ]
then
echo "Restoring config to $location_sugarbase" ;
mv "/tmp/config.php" "$location_sugarbase" ;
if [ -e "/tmp/config_override.php" ]
then
mv "/tmp/config_override.php" "$location_sugarbase" ;
fi
fi
if [ $? == 0 ];then
echo "Restoring config OK";
else
echo "Restoring config Fail.";
fi
}
do_cleanConfig(){
pushd $location_sugarbase > /dev/null 2>&1
if [ -e "config.php" ];then
echo "remove config.php file";
rm config.php;
else
echo "config.php not exist";
fi
if [ -e "config_override.php" ];then
echo "remove config_override.php file";
rm config_override.php
else
echo "config_override.php not exist";
fi
popd > /dev/null 2>&1
}
do_backup(){
#backup the config file.
if [ -d "$location_sugarbase" -a -e "$location_sugarbase/config.php" ]
then
haswebdir="true";
echo "Backing up config from $location_sugarbase" ;
mv "$location_sugarbase/config.php" "/tmp" ;
if [ -e "$locatinon_sugarbase/config_override.php" ]
then
mv "$location_sugarbase/config_override.php" "/tmp" ;
fi
#rm -rf "$location_sugarbase" ;
fi
if [ $? == 0 ];then
echo "Backing up config OK";
else
echo "Backing up config Fail.";
fi
}
do_build(){
echo "now building new sugar build";
pushd $BUILDPHPDIR > /dev/null 2>&1
php -n build.php --clean=0 --dir="$GITDIR/sugarcrm" --flav="$flavor" --cleanCache=1 --base_dir="$GITDIR" --build_dir="$LOCATIONDIR" --ver="$version"
popd > /dev/null 2>&1
echo "build OK";
}
do_install(){
echo "silently install via curl";
curl $INSTALL_URL;
}
do_removeSugarBuild(){
echo "deleting existing sugarcrm build";
rm -rf "$location_sugarbase" ;
echo "delete OK";
}
######main function #####################
if [ -z $installType ];then
installType='help';
fi
if [ $installType == 'full' ];then
echo "Build Type: Full";
do_dropdatabase;
do_removeSugarBuild;
do_build;
do_cover;
do_install;
elif [ $installType == 'incre' ];then
echo "Build Type: Incremental";
do_backup;
do_build;
do_restore;
elif [ $installType == 'clean' ];then
do_cleanConfig;
elif [ $installType == 'build' ];then
do_removeSugarBuild;
do_build;
elif [ $installType == 'dropdb' ];then
do_dropdatabase;
elif [ $installType == 'help' ];then
echo "==============================================";
echo "freshbuild.sh for sugarcrm dev ";
echo " by Josh Yu([email protected]) ";
echo "freshbuild.sh help: show this help menu ";
echo "freshbuild.sh build: build a brand new version";
echo "freshbuild.sh full: fully build ";
echo "freshbuild.sh incre: incrementally build ";
echo "freshbuild.sh clean: remove config files ";
echo "freshbuild.sh dropdb: drop database ";
echo "==============================================";
elif [ ! -z $installType ];then
echo "invalid command \"$installType\".";
echo "please enter freshbuild.sh help";
exit 1;
fi