forked from Zimbra-Community/owncloud-zimlet
/
webdav-client-installer.sh
executable file
·178 lines (144 loc) · 6.39 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
#!/bin/bash
# Copyright (C) 2016 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 YN;
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/
su - zimbra -c "zmzimletctl undeploy tk_barrydegraaff_owncloud_zimlet"
TMPFOLDER="$(mktemp -d /tmp/webdav-client-installer.XXXXXXXX)"
echo "Saving existing configuration to $TMPFOLDER/upgrade"
if [ -f /opt/zimbra/lib/ext/ownCloud/config.properties ]; then
mkdir $TMPFOLDER/upgrade
cp /opt/zimbra/lib/ext/ownCloud/config.properties $TMPFOLDER/upgrade
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.2"
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 "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 !(zal*).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
" > /opt/zimbra/lib/ext/ownCloud/config.properties
ls -hal /opt/zimbra/lib/ext/ownCloud/
echo "Installing Zimlet"
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"
if [ "$YN" == '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
if [ -f $TMPFOLDER/upgrade/config.properties ]; then
echo "Restoring config.properties"
cd $TMPFOLDER/upgrade/
wget 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 https://github.com/Zimbra-Community/prop2xml/raw/master/out/artifacts/prop2xml_jar/prop2xml.jar
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
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
"
rm -Rf $TMPFOLDER