forked from maldua-suite/zimbra-maldua-2fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·116 lines (85 loc) · 3.18 KB
/
install.sh
File metadata and controls
executable file
·116 lines (85 loc) · 3.18 KB
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
#!/bin/bash
function zmacl_disable () {
if [[ -x /opt/zimbra/bin/zmacl ]]
then
/opt/zimbra/bin/zmacl disable
fi
}
function zmacl_enable () {
if [[ -x /opt/zimbra/bin/zmacl ]]
then
/opt/zimbra/bin/zmacl enable
fi
}
function deploy_qr_addon () {
# Set proper users and groups
chown zimbra:zimbra qr
chown zimbra:zimbra qr/qrcode.js
chown zimbra:zimbra qr/TwoFactor_qr.js
# Login 2FA
cp qr/qrcode.js /opt/zimbra/jetty/webapps/zimbra/js
cp qr/TwoFactor_qr.js /opt/zimbra/jetty/webapps/zimbra/js
chown zimbra:zimbra /opt/zimbra/jetty/webapps/zimbra/js/qrcode.js
chown zimbra:zimbra /opt/zimbra/jetty/webapps/zimbra/js/TwoFactor_qr.js
su - zimbra -c 'cat /opt/zimbra/jetty/webapps/zimbra/js/qrcode.js | gzip -c > /opt/zimbra/jetty/webapps/zimbra/js/qrcode.js.zgz'
su - zimbra -c 'cat /opt/zimbra/jetty/webapps/zimbra/js/TwoFactor_qr.js | gzip -c > /opt/zimbra/jetty/webapps/zimbra/js/TwoFactor_qr.js.zgz'
if grep -E 'TwoFactor_qr.js' /opt/zimbra/jetty/webapps/zimbra/public/TwoFactorSetup.jsp > /dev/null 2>&1 ; then
:
else
cp /opt/zimbra/jetty/webapps/zimbra/public/TwoFactorSetup.jsp /opt/zimbra/jetty/webapps/zimbra/public/TwoFactorSetup.jsp_2FAQR_COPY
sed -i 's~</head>~<script src="${contextPath}/js/qrcode.js<%=ext%>?v=${version}"></script><script src="${contextPath}/js/TwoFactor_qr.js<%=ext%>?v=${version}"></script></head>~g' /opt/zimbra/jetty/webapps/zimbra/public/TwoFactorSetup.jsp
fi
# Preferences 2FA
if grep -E 'TwoFactor_qr.js' /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js > /dev/null 2>&1 ; then
:
else
cp /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js_2FAQR_COPY
cp /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js.zgz /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js.zgz_2FAQR_COPY
cat /opt/zimbra/jetty/webapps/zimbra/js/qrcode.js >> /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js
cat /opt/zimbra/jetty/webapps/zimbra/js/TwoFactor_qr.js >> /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js
su - zimbra -c 'cat /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js | gzip -c > /opt/zimbra/jetty/webapps/zimbra/js/Preferences_all.js.zgz'
fi
}
function usage () {
cat << EOF
$0
Regular installation.
$0 --help
Print this help.
EOF
}
function restart_notice () {
cat << EOF
- Zimbra 2FA Extension
- Zimbra 2FA Admin zimlet
- Zimbra 2FA QR addon
were installed.
Please restart mailboxd thanks to:
su - zimbra -c 'zmmailboxdctl restart'
so that this new extension is used.
EOF
}
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
if [[ "$1" == '--help' ]]
then
usage
exit 0
fi
if [[ ! -x /opt/zimbra/bin/zmmailboxdctl ]]
then echo "Please run on a mailbox node."
exit 1
fi
zmacl_disable
chown zimbra:zimbra $(pwd)
chown zimbra:zimbra com_btactic_twofactorauth_admin.zip
cp zetatwofactorauth.jar /opt/zimbra/lib/ext/twofactorauth/zetatwofactorauth.jar
chmod 444 /opt/zimbra/lib/ext/twofactorauth/zetatwofactorauth.jar
cp zetatotp /opt/zimbra/bin/zetatotp
chmod 755 /opt/zimbra/bin/zetatotp
su - zimbra -c 'zmzimletctl -l deploy '"$(pwd)"'/com_btactic_twofactorauth_admin.zip'
deploy_qr_addon
zmacl_enable
restart_notice