-
Notifications
You must be signed in to change notification settings - Fork 19
/
shared-mailbox-toolkit-installer.sh
executable file
·144 lines (119 loc) · 4.41 KB
/
shared-mailbox-toolkit-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
#!/bin/bash
# Copyright (C) 2014-2023 Barry de Graaff
#
# Bugs and feedback: https://github.com/Zimbra-Community/shared-mailbox-toolkit/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 "Shared Mailbox Toolkit installer"
# 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
if [ -z "$1" ]
then
echo "Check if yum/apt installed."
set +e
YUM_CMD=$(which yum)
set -e
if [[ ! -z $YUM_CMD ]]; then
yum install -y newt
else
apt install -y whiptail
fi
one=$(whiptail --title "Shared Mailbox Toolkit Installer" --checklist "Choose components to install. CLI commands are always installed." 15 60 4 \
"Client Zimlet" "" on \
"Admin Zimlet and extension" "" on \
"X-Authenticated-User header" "" on --clear 3>&1 1>&2 2>&3)
if [ "$?" = "1" ]
then
echo "cancelled by user"
exit 0
fi
#Change bash script parameter, aka one cannot do something like 1=$(whiptail....) to set $1
set -- "$one" "$2"
fi
echo "Check if git and zip are installed."
set +e
YUM_CMD=$(which yum)
set -e
if [[ ! -z $YUM_CMD ]]; then
yum install -y git zip newt
else
apt-get install -y git zip whiptail
fi
TMPFOLDER="$(mktemp -d /tmp/shared-mailbox-toolkit-installer.XXXXXXXX)"
if ! git remote -v | grep /shared-mailbox-toolkit.git; then
echo "Download Shared Mailbox Toolkit to $TMPFOLDER"
cd $TMPFOLDER
git clone --depth=1 https://github.com/Zimbra-Community/shared-mailbox-toolkit
cd shared-mailbox-toolkit
fi
if [[ $1 == *"Client Zimlet"* ]]
then
echo "Deploy client Zimlet"
rm -Rf /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_sharetoolkit_client
mkdir -p /opt/zimbra/zimlets-deployed/_dev/
cp -rv tk_barrydegraaff_sharetoolkit_client /opt/zimbra/zimlets-deployed/_dev/tk_barrydegraaff_sharetoolkit_client
fi
if [[ $1 == *"Admin Zimlet and extension"* ]]
then
echo "Deploy admin Zimlet"
su - zimbra -c "zmzimletctl undeploy tk_barrydegraaff_sharetoolkit_admin"
rm -f /tmp/tk_barrydegraaff_sharetoolkit_admin.zip
cd tk_barrydegraaff_sharetoolkit_admin
zip -r /tmp/tk_barrydegraaff_sharetoolkit_admin.zip *
cd ..
su - zimbra -c "zmzimletctl deploy /tmp/tk_barrydegraaff_sharetoolkit_admin.zip"
echo "Deploy Java server extension"
rm -Rf /opt/zimbra/lib/ext/ShareToolkit
mkdir -p /opt/zimbra/lib/ext/ShareToolkit
cp -v extension/ShareToolkit/out/artifacts/ShareToolkit/ShareToolkit.jar /opt/zimbra/lib/ext/ShareToolkit/
fi
if [[ $1 == *"X-Authenticated-User header"* ]]
then
echo "Enable X-Authenticated-User header"
su - zimbra -c "zmprov mcf zimbraSmtpSendAddAuthenticatedUser TRUE"
su - zimbra -c "zmprov mcf zimbraMtaSmtpdSaslAuthenticatedHeader yes"
fi
echo "Deploy CLI tools"
cp -rv bin/* /usr/local/sbin/
echo "Flushing Zimlet Cache"
su - zimbra -c "zmprov fc all"
echo "--------------------------------------------------------------------------------------------------------------
Shared Mailbox Toolkit installed successful"
if [[ $1 == *"X-Authenticated-User header"* ]] || [[ $1 == *"Admin Zimlet and extension"* ]];
then
echo "You still need to restart some services to load the changes:"
fi
if [[ $1 == *"X-Authenticated-User header"* ]]
then
echo "su - zimbra -c \"zmmtactl restart\""
fi
if [[ $1 == *"Admin Zimlet and extension"* ]]
then
echo "su - zimbra -c \"zmmailboxdctl restart\""
fi
SESSION_LIMIT=$(/opt/zimbra/bin/zmlocalconfig zimbra_session_limit_admin | awk '{print $3}')
if [ $SESSION_LIMIT -lt 10 ]
then
echo "WARNING: zimbra_session_limit_admin is:" $SESSION_LIMIT
echo "Consider changing it to 10 if you run into troubles when creating shares on the Web UI."
echo "zmlocalconfig -e zimbra_session_limit_admin=10"
echo "zmmailboxdctl restart"
fi
rm -Rf $TMPFOLDER