forked from Zimbra-Community/owncloud-zimlet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webdav-client-installer.sh
executable file
·264 lines (222 loc) · 9.82 KB
/
webdav-client-installer.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/bin/bash
# Copyright (C) 2016-2017 Barry de Graaff
#
# Bugs and feedback: https://github.com/Zimbra-Community/owncloud-zimlet/issues
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
set -e
# if you want to trace your script uncomment the following line
#set -x
echo "Automated Zimbra WebDAV Client installer for single-server Zimbra 8.7 on CentOS 6 or 7 (Ubuntu untested)
- Installs ant and git, the WebDAV Client server extension and Zimlet."
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo ""
echo "Do you want to enable experimental document preview (tested on CentOS 7 and Ubuntu 14.04)? Y/n:"
read YNDOCPREV;
echo ""
echo "Do you want to automatically install Zimlet and force enable it in all COS'es?"
echo "If you choose n you have to run zmzimletctl, configuration COS and set config_template.xml manually."
echo "If you have trouble or are unsure, choose Y. Y/n:"
read YNZIMLETDEV;
echo ""
echo "Do you want to install public link sharing?"
echo "If you use a WebDAV server that is not ownCloud or Nextcloud choose n."
echo "If you have trouble or are unsure, choose Y. Y/n:"
read YNOCS;
echo "Check if git and ant are installed."
set +e
YUM_CMD=$(which yum)
APT_CMD=$(which apt-get)
GIT_CMD=$(which git)
ANT_CMD=$(which ant)
ZIP_CMD=$(which zip)
set -e
if [[ -z $GIT_CMD ]] || [[ -z $ANT_CMD ]] || [[ -z $ZIP_CMD ]]; then
if [[ ! -z $YUM_CMD ]]; then
yum install -y git ant make zip
else
apt-get install -y git ant make default-jdk zip
fi
fi
echo "Remove old versions of Zimlet."
rm -Rf /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_owncloud_zimlet/
if [[ "$YNZIMLETDEV" == 'N' || "$YNZIMLETDEV" == 'n' ]];
then
echo "Not touching COS per user request."
else
su - zimbra -c "zmzimletctl undeploy tk_barrydegraaff_owncloud_zimlet"
fi
TMPFOLDER="$(mktemp -d /tmp/webdav-client-installer.XXXXXXXX)"
echo "Saving existing configuration to $TMPFOLDER/upgrade"
mkdir $TMPFOLDER/upgrade
if [ -f /opt/zimbra/lib/ext/ownCloud/config.properties ]; then
cp /opt/zimbra/lib/ext/ownCloud/config.properties $TMPFOLDER/upgrade
else
touch $TMPFOLDER/upgrade/config.properties
fi
echo "Download WebDAV Client to $TMPFOLDER"
cd $TMPFOLDER
git clone --depth=1 https://github.com/barrydegraaff/owncloud-zimlet
#cp -r /root/owncloud-zimlet $TMPFOLDER
echo "Compiling WebDAV Client."
cd owncloud-zimlet
cd extension && ant download-libs && cd ..
make
echo "Installing server extension to /opt/zimbra/lib/ext/ownCloud"
cd $TMPFOLDER/owncloud-zimlet/dist/owncloud-extension/
shopt -s extglob
ZAL_VERSION="1.11"
ZAL_VERSION_EXTENDED="1.11.7"
ZIMBRA_VERSION=$(sudo su - zimbra -c "zmcontrol -v" | tr -d '\n' | sed -r 's/.* ([0-9\.]+[0-9]).*/\1/')
echo "Downloading the correct ZAL Version (${ZAL_VERSION_EXTENDED} for zimbra ${ZIMBRA_VERSION})..."
wget --no-cache "https://openzal.org/${ZAL_VERSION}/zal-${ZAL_VERSION_EXTENDED}-${ZIMBRA_VERSION}.jar" -O "zal-${ZAL_VERSION_EXTENDED}-${ZIMBRA_VERSION}.jar"
mkdir -p /opt/zimbra/lib/ext/ownCloud
rm -f /opt/zimbra/lib/ext/ownCloud/*.jar
cp "zal-${ZAL_VERSION_EXTENDED}-${ZIMBRA_VERSION}.jar" /opt/zimbra/lib/ext/ownCloud/
cp ant-1.7.0.jar /opt/zimbra/lib/ext/ownCloud/
cp commons-cli-1.2.jar /opt/zimbra/lib/ext/ownCloud/
cp commons-codec-1.9.jar /opt/zimbra/lib/ext/ownCloud/
cp commons-fileupload-1.3.1.jar /opt/zimbra/lib/ext/ownCloud/
cp commons-httpclient-3.1.jar /opt/zimbra/lib/ext/ownCloud/
cp commons-logging-1.2.jar /opt/zimbra/lib/ext/ownCloud/
cp dav-soap-connector-extension.jar /opt/zimbra/lib/ext/ownCloud/
cp fluent-hc-4.5.1.jar /opt/zimbra/lib/ext/ownCloud/
cp httpclient-4.5.1.jar /opt/zimbra/lib/ext/ownCloud/
cp httpclient-cache-4.5.1.jar /opt/zimbra/lib/ext/ownCloud/
cp httpcore-4.4.3.jar /opt/zimbra/lib/ext/ownCloud/
cp httpcore-ab-4.4.3.jar /opt/zimbra/lib/ext/ownCloud/
cp httpcore-nio-4.4.3.jar /opt/zimbra/lib/ext/ownCloud/
cp httpmime-4.5.1.jar /opt/zimbra/lib/ext/ownCloud/
cp jna-4.1.0.jar /opt/zimbra/lib/ext/ownCloud/
cp jna-platform-4.1.0.jar /opt/zimbra/lib/ext/ownCloud/
cp urlrewritefilter-4.0.3.jar /opt/zimbra/lib/ext/ownCloud/
# Here we set the template for config.properties, if upgrading we alter it further down
echo "allowdomains=*
disable_password_storing=false
owncloud_zimlet_server_name=
owncloud_zimlet_server_port=
owncloud_zimlet_server_path=/owncloud/remote.php/webdav/
owncloud_zimlet_oc_folder=/owncloud
owncloud_zimlet_default_folder=
owncloud_zimlet_ask_folder_each_time=false
owncloud_zimlet_disable_rename_delete_new_folder=false
owncloud_zimlet_extra_toolbar_button_title=Open ownCloud tab
owncloud_zimlet_extra_toolbar_button_url=/owncloud
owncloud_zimlet_app_title=WebDAV
owncloud_zimlet_max_upload_size=104857600
owncloud_zimlet_preview_delay=200
owncloud_zimlet_use_numbers=false
file_number=1000000
owncloud_zimlet_welcome_url=https\://barrydegraaff.github.io/owncloud/
" > /opt/zimbra/lib/ext/ownCloud/config.properties
if [[ "$YNOCS" == 'N' || "$YNOCS" == 'n' ]];
then
echo "owncloud_zimlet_disable_ocs_public_link_shares=true
" >> /opt/zimbra/lib/ext/ownCloud/config.properties
else
echo "owncloud_zimlet_disable_ocs_public_link_shares=false
" >> /opt/zimbra/lib/ext/ownCloud/config.properties
fi
ls -hal /opt/zimbra/lib/ext/ownCloud/
echo "Installing Zimlet."
if [[ "$YNZIMLETDEV" == 'N' || "$YNZIMLETDEV" == 'n' ]];
then
echo "Skipped per user request."
else
mkdir -p /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_owncloud_zimlet/
unzip $TMPFOLDER/owncloud-zimlet/zimlet/tk_barrydegraaff_owncloud_zimlet.zip -d /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_owncloud_zimlet/
echo "Flushing Zimlet Cache."
su - zimbra -c "zmprov fc all"
fi
if [[ "$YNDOCPREV" == 'Y' || "$YNDOCPREV" == 'y' ]];
then
echo "Install LibreOffice."
cp -v $TMPFOLDER/owncloud-zimlet/bin/* /usr/local/sbin/
if [[ ! -z $YUM_CMD ]]; then
yum install -y libreoffice-headless libreoffice
else
apt-get install -y libreoffice
fi
echo "Configure docconvert user and set up sudo in /etc/sudoers.d/99_zimbra-docconvert"
set +e
if [[ ! -z $YUM_CMD ]]; then
adduser docconvert
else
useradd docconvert
fi
set -e
echo "zimbra ALL=(docconvert) NOPASSWD: ALL" > /etc/sudoers.d/99_zimbra-docconvert
usermod -a -G zimbra docconvert
usermod -a -G docconvert zimbra
echo "setting up fall back clean-up in /etc/cron.d/docconvert-clean"
echo "*/5 * * * * root /usr/bin/find /tmp -cmin +5 -type f -name 'docconvert*' -exec rm -f {} \;" > /etc/cron.d/docconvert-clean
fi
echo "Downloading OCS Share API implementation for WebDAV Client"
if [[ "$YNOCS" == 'N' || "$YNOCS" == 'n' ]];
then
echo "Skip by user request."
mkdir -p /opt/zimbra/lib/ext/OCS
rm -Rf /opt/zimbra/lib/ext/OCS
else
mkdir -p /opt/zimbra/lib/ext/OCS
rm -f /opt/zimbra/lib/ext/OCS/*.jar
cd /opt/zimbra/lib/ext/OCS
wget --no-cache "https://github.com/Zimbra-Community/OCS/raw/master/extension/out/artifacts/OCS_jar/OCS.jar"
fi
echo "Restoring config.properties"
cd $TMPFOLDER/upgrade/
wget --no-cache https://github.com/Zimbra-Community/propmigr/raw/master/out/artifacts/propmigr_jar/propmigr.jar
java -jar $TMPFOLDER/upgrade/propmigr.jar $TMPFOLDER/upgrade/config.properties /opt/zimbra/lib/ext/ownCloud/config.properties
echo "Generating config_template.xml"
wget --no-cache https://github.com/Zimbra-Community/prop2xml/raw/master/out/artifacts/prop2xml_jar/prop2xml.jar
if [[ "$YNZIMLETDEV" == 'N' || "$YNZIMLETDEV" == 'n' ]];
then
echo "Skip config_template.xml generation by user request."
else
java -jar $TMPFOLDER/upgrade/prop2xml.jar tk_barrydegraaff_owncloud_zimlet /opt/zimbra/lib/ext/ownCloud/config.properties /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_owncloud_zimlet/config_template.xml
fi
chown zimbra:zimbra /opt/zimbra/lib/ext/ownCloud/config.properties
chmod u+rw /opt/zimbra/lib/ext/ownCloud/config.properties
echo "--------------------------------------------------------------------------------------------------------------
Zimbra WebDAV Client installed successful.
To load the extension:
su zimbra
zmmailboxdctl restart
As of version 0.5.6 your clients CAN CONNECT TO ALL DAV SERVERS BY DEFAULT,
you can restrict the allowed DAV servers to connect to in:
/opt/zimbra/lib/ext/ownCloud/config.properties
allowdomains=allowme.example.com;allowmealso.example.com
- No service restart is needed after changing this file.
If you installed WebDAV Client before, you should remove your DAV servers
from zimbraProxyAllowedDomains:
zmprov gc default zimbraProxyAllowedDomains
zmprov mc default -zimbraProxyAllowedDomains allowme.example.com
"
if [[ "$YNZIMLETDEV" == 'N' || "$YNZIMLETDEV" == 'n' ]];
then
chown zimbra:zimbra $TMPFOLDER -R
echo "To install Zimlet run as user Zimbra:"
echo "zmzimletctl deploy $TMPFOLDER/owncloud-zimlet/zimlet/tk_barrydegraaff_owncloud_zimlet.zip"
echo "java -jar $TMPFOLDER/upgrade/prop2xml.jar tk_barrydegraaff_owncloud_zimlet /opt/zimbra/lib/ext/ownCloud/config.properties /opt/zimbra/zimlets-deployed/tk_barrydegraaff_owncloud_zimlet/config_template.xml"
echo "zmzimletctl configure /opt/zimbra/zimlets-deployed/tk_barrydegraaff_owncloud_zimlet/config_template.xml"
echo "zmprov fc all"
echo "rm -Rf $TMPFOLDER"
echo "Then go to the Admin Web Interface and enable Zimlet in the COS'es you want."
else
rm -Rf $TMPFOLDER
fi