forked from communigate/communigate-cpanel-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
executable file
·235 lines (207 loc) · 7.63 KB
/
upgrade.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
#!/bin/bash
PACKSRC=`pwd`
#################################################
# cPanel Specific #
#################################################
# iPhone provisioning using default httpd
cp ${PACKSRC}/iphone/iphonetemplate.mobileconfig /var/CommuniGate/apple/
# Install CGP Logo
cp ${PACKSRC}/whm/communigate.gif /usr/local/cpanel/whostmgr/docroot/images/communigate.gif
# Install cPanel CommuniGate Custom Module
cp ${PACKSRC}/module/CommuniGate.pm /usr/local/cpanel/Cpanel/
# Lets add CGPro perl lib
cp ${PACKSRC}/library/CLI.pm /usr/local/cpanel/perl/
if [ ! -L /usr/local/cpanel/CLI.pm ]
then
rm -f /usr/local/cpanel/CLI.pm
ln -s /usr/local/cpanel/perl/CLI.pm /usr/local/cpanel
fi
PERL_VERSION=`perl -v | grep 'This is perl' | perl -pe 's/^.*?v(\d+\.\d+\.\d+).*?$/$1/g'`
MY_PERL_PATHS="/usr/local/lib/perl5/$PERL_VERSION /usr/local/lib/perl/$PERL_VERSION /usr/local/share/perl/$PERL_VERSION /usr/local/share/perl5"
DEFAULT_PERL_PATHS=`perl -e "print join ' ', @INC"`
PERL_PATH=""
found=
for i in ${MY_PERL_PATHS[@]}; do
for j in ${DEFAULT_PERL_PATHS[@]}; do
[[ $i == $j ]] && { PERL_PATH=$i; found=1; break; }
done
[[ -n $skip ]] && { break; }
done
if [ ! -d $PERL_PATH ]
then
mkdir -p $PERL_PATH
fi
ln -s /usr/local/cpanel/perl/CLI.pm $PERL_PATH/
cp ${PACKSRC}/library/XIMSS.pm /usr/local/cpanel/
# CGPro cPanel Wrapper
cp ${PACKSRC}/cpwrap/ccaadmin /usr/local/cpanel/bin/
cp ${PACKSRC}/cpwrap/ccawrap /usr/local/cpanel/bin/
cp -r ${PACKSRC}/cpwrap/CGPro /usr/local/cpanel/bin/admin/
# install Perl dependencies
if [ -d '/var/CommuniGate/' -a `perldoc -l Mail::DKIM::Verifier | wc -l` == 0 ]
then
perl -MCPAN -e 'install Mail::DKIM::Verifier'
fi
if [ -d '/var/CommuniGate/' -a `perldoc -l Mail::DKIM::Signer | wc -l` == 0 ]
then
perl -MCPAN -e 'install Mail::DKIM::Signer'
fi
if [ -d '/var/CommuniGate/' -a `perldoc -l IO::Scalar | wc -l` == 0 ]
then
perl -MCPAN -e 'install IO::Scalar'
fi
if [ -d '/var/CommuniGate/' -a `perldoc -l Archive::Zip | wc -l` == 0 ]
then
perl -MCPAN -e 'install Archive::Zip'
fi
if [ -d '/var/CommuniGate/' -a `perldoc -l GD::Barcode::QRcode | wc -l` == 0 ]
then
perl -MCPAN -e 'install GD::Barcode::QRcode'
fi
if [ `perldoc -l YAML::Syck | wc -l` == 0 ]
then
/usr/local/cpanel/bin/cpanm -f -q YAML::Syck
fi
chmod +x ${PACKSRC}/scripts/install_cpanel_module.pl
${PACKSRC}/scripts/install_cpanel_module.pl MIME::QuotedPrint::Perl
${PACKSRC}/scripts/install_cpanel_module.pl XML::SAX
${PACKSRC}/scripts/install_cpanel_module.pl GD::Barcode::QRcode
# Install cPanel Function hooks
if [ ! -d /var/cpanel/perl5/lib/ ]
then
mkdir -p /var/cpanel/perl5/lib/
fi
/usr/local/cpanel/bin/manage_hooks delete module CGPro::Hooks
cp -rf ${PACKSRC}/hooks/CGPro /var/cpanel/perl5/lib/
# Register installed hooks
/usr/local/cpanel/bin/manage_hooks add module CGPro::Hooks
#Install config file
cp ${PACKSRC}/etc/cpanel_cgpro.conf /var/cpanel/communigate.yaml
chmod 600 /var/cpanel/communigate.yaml
# Install CommuniGate Webmail in cPanel
cp ${PACKSRC}/cgpro-webmail/webmail_communigate.yaml /var/cpanel/webmail/
cp -r ${PACKSRC}/cgpro-webmail/CommuniGate /usr/local/cpanel/base/3rdparty/
# Install SSO for Webmail
if [ ! -d /var/CommuniGate/cgi ]
then
mkdir -p /var/CommuniGate/cgi
fi
cp ${PACKSRC}/sso/#.pl /var/CommuniGate/cgi/
# chkservd for CGServer & spamd
cp ${PACKSRC}/chkservd/CommuniGate /etc/chkserv.d/
cp ${PACKSRC}/chkservd/CommuniGate_spamd /etc/chkserv.d/
# Check the scripts have executable flag
chmod +x /usr/local/cpanel/whostmgr/docroot/cgi/addon_cgpro*
chmod +x /var/CommuniGate/cgi/#.pl
chmod +x /usr/local/cpanel/Cpanel/CommuniGate.pm
chmod +x /usr/local/cpanel/bin/ccaadmin
chmod +s+x /usr/local/cpanel/bin/ccawrap
chmod +x /usr/local/cpanel/bin/admin/CGPro/cca
chmod u+s /opt/CommuniGate/mail
# Install CommuniGate Plugin
BASEDIR='/usr/local/cpanel/base/frontend';
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
THEMES=($(find ${BASEDIR} -maxdepth 1 -mindepth 1 -type d))
IFS=$OLDIFS
tLen=${#THEMES[@]}
LOCALES=($(find ${PACKSRC}/locale -maxdepth 1 -mindepth 1))
lLen=${#LOCALES[@]}
for (( i=0; i<${tLen}; i++ ));
do
if [ "${THEMES[$i]}" == "${BASEDIR}/CommuniGate" ]
then
continue
fi
rm -rf ${THEMES[$i]}/cgpro
cp -r "${PACKSRC}/theme/cgpro" "${THEMES[$i]}/"
rm -f ${THEMES[$i]}/branding/cgpro_*
cp "${PACKSRC}/icons/"* "${THEMES[$i]}/branding"
cp "${PACKSRC}/plugin/dynamicui_cgpro.conf" "${THEMES[$i]}/dynamicui/"
if [ ! -d ${THEMES[$i]}/js2-min/cgpro ]
then
mkdir -p ${THEMES[$i]}/js2-min/cgpro
fi
if [ ! -L ${THEMES[$i]}/js2-min/cgpro/mail ]
then
ln -s ${THEMES[$i]}/js2-min/mail ${THEMES[$i]}/js2-min/cgpro/
fi
if [ ! -d ${THEMES[$i]}/css2-min/cgpro ]
then
mkdir -p ${THEMES[$i]}/css2-min/cgpro
fi
if [ ! -L ${THEMES[$i]}/css2-min/cgpro/mail ]
then
ln -s ${THEMES[$i]}/css2-min/mail ${THEMES[$i]}/css2-min/cgpro/
fi
chmod +x ${THEMES[$i]}/cgpro/backup/getaccbackup.live.cgi
chmod +x ${THEMES[$i]}/cgpro/backup/getaliasesbackup.live.cgi
chmod +x ${THEMES[$i]}/cgpro/backup/getfiltersbackup.live.cgi
chmod +x ${THEMES[$i]}/cgpro/mail/checkDomainSettings.live.cgi
chmod +x ${THEMES[$i]}/cgpro/mail/getDomainAccounts.live.cgi
chmod +x ${THEMES[$i]}/cgpro/mail/getVCARD.live.cgi
chmod +x ${THEMES[$i]}/cgpro/mail/getQR.live.cgi
chmod +x ${THEMES[$i]}/cgpro/mail/contactsimport.live.cgi
chmod +x ${THEMES[$i]}/cgpro/getXmppHistory.live.cgi
chmod +x ${THEMES[$i]}/cgpro/playwav.live.cgi
chmod +x ${THEMES[$i]}/cgpro/getwav.live.cgi
if [ -f ${THEMES[$i]}cgpro/mail/groupware.html ]
then
rm -f ${THEMES[$i]}cgpro/mail/groupware.html
fi
for ((j=0; j<${lLen}; j++)); do
TARGET=${THEMES[$i]}/locale/`basename ${LOCALES[$j]} '{}'`.yaml.local
if [ ! -f ${TARGET} ]
then
echo "---" > ${TARGET}
else
sed -i -e '/^CGP/d' ${TARGET}
fi
cat ${LOCALES[$j]} >> ${TARGET}
done
done
chmod +x ${PACKSRC}/scripts/*
# Migrating groupware accounts
if [ -f /var/CommuniGate/cPanel/limits ]
then
${PACKSRC}/scripts/migrate_groupware.pl
echo "!!! Please delete /var/CommuniGate/cPanel/limits by hand if seetings are OK !!!"
fi
# Purge unneeded files
if [ -f /usr/local/cpanel/whostmgr/docroot/cgi/addon_cgpro-gwcontrol.cgi ]
then
rm -f /usr/local/cpanel/whostmgr/docroot/cgi/addon_cgpro-gwcontrol.cgi
fi
if [ -f /usr/local/cpanel/scripts/postwwwacct ]
then
rm -f /usr/local/cpanel/scripts/postwwwacct
fi
# Update Feature List
cp ${PACKSRC}/featurelists/cgpro /usr/local/cpanel/whostmgr/addonfeatures/
/usr/local/cpanel/bin/rebuild_sprites
/usr/local/cpanel/bin/build_locale_databases
if [ -d '/var/CommuniGate/' ]
then
# install DKIM tools FOR CGPro server Only
chmod +x ${PACKSRC}/tools/*
cp ${PACKSRC}/tools/helper_DKIM_sign.pl /var/CommuniGate/
cp ${PACKSRC}/tools/helper_DKIM_verify.pl /var/CommuniGate/
${PACKSRC}/scripts/install_dkim_signer.pl
# Install Active Queue Scripts
cp ${PACKSRC}/PBXApps/*spp* /var/CommuniGate/PBXApps/
# Install WebSkins
rm -rf /var/CommuniGate/WebSkins/ProntoDrive
rm -f /var/CommuniGate/WebSkins/prontodrive*
rm -f /var/CommuniGate/WebSkins/workfaces*
chmod +x ${PACKSRC}/cgi/*
cp -r ${PACKSRC}/WebSkins/* /var/CommuniGate/WebSkins/
cp ${PACKSRC}/cgi/* /var/CommuniGate/cgi/
/etc/init.d/CommuniGate stop
/etc/init.d/CommuniGate start
fi
# Install the WHM plugins (administration and groupware control)
rm -f /usr/local/cpanel/whostmgr/docroot/templates/cgpro_*
cp ${PACKSRC}/whm/templates/* /usr/local/cpanel/whostmgr/docroot/templates/
rm -rf /usr/local/cpanel/whostmgr/docroot/cgi/cgpro*
cp -rf ${PACKSRC}/whm/cgi/* /usr/local/cpanel/whostmgr/docroot/cgi/
echo "Upgrade Finished!"