blob: 92d7754915ea3cb55541a7b260acef89826234d3 (
plain)
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
|
#!/bin/bash
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/
# shellcheck disable=2034,2059
true
SCRIPT_NAME="Collabora (Integrated)"
# shellcheck source=lib.sh
NC_UPDATE=1 . <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
unset NC_UPDATE
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
print_text_in_color "$ICyan" "Running the Collabora install script..."
# Nextcloud 19 is required.
lowest_compatible_nc 19
ram_check 2 Collabora
cpu_check 2 Collabora
# Check if Nextcloud is installed with TLS
check_nextcloud_https "Collabora (Integrated)"
# Check if Collabora is installed using the old method
if does_this_docker_exist 'collabora/code'
then
msg_box "Your server is compatible with the new way of installing Collabora. We will now remove the old docker and install the app from Nextcloud instead."
# Remove docker image
docker_prune_this 'collabora/code'
# Disable RichDocuments (Collabora App) if activated
if is_app_installed richdocuments
then
occ_command app:remove richdocuments
fi
# Disable OnlyOffice (Collabora App) if activated
if is_app_installed onlyoffice
then
occ_command app:remove onlyoffice
fi
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
REMOVE_OLD="$(find "$LETSENCRYPTPATH/" -name "$SUBDOMAIN*")"
for remove in $REMOVE_OLD
do rm -rf "$remove"
done
fi
# Remove Apache2 config
if [ -f "$SITES_AVAILABLE/$SUBDOMAIN.conf" ]
then
a2dissite "$SUBDOMAIN".conf
restart_webserver
rm -f "$SITES_AVAILABLE/$SUBDOMAIN.conf"
fi
# Remove trusted domain
count=0
while [ "$count" -lt 10 ]
do
if [ "$(occ_command_no_check config:system:get trusted_domains "$count")" == "$SUBDOMAIN" ]
then
occ_command_no_check config:system:delete trusted_domains "$count"
break
else
count=$((count+1))
fi
done
fi
# Check if Collabora is installed using the new method
if is_app_enabled richdocumentscode
then
choice=$(whiptail --title "$TITLE" --menu "It seems like 'Collabora' is already installed.\nChoose what you want to do." "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Collabora" "" \
"Uninstall Collabora" "" 3>&1 1>&2 2>&3)
case "$choice" in
"Uninstall Collabora")
print_text_in_color "$ICyan" "Uninstalling Collabora..."
occ_command app:remove richdocumentscode
# Disable Collabora App if activated
if is_app_installed richdocuments
then
occ_command app:remove richdocuments
fi
msg_box "Collabora was successfully uninstalled."
exit
;;
"Reinstall Collabora")
print_text_in_color "$ICyan" "Reinstalling Collabora..."
occ_command app:remove richdocumentscode
;;
*)
;;
esac
fi
# Check if Onlyoffice is installed and remove every trace of it
if does_this_docker_exist 'onlyoffice/documentserver'
then
msg_box "You can't run both Collabora and OnlyOffice on the same VM. We will now remove Onlyoffice from the server."
# Remove docker image
docker_prune_this 'onlyoffice/documentserver'
# Revoke LE
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Onlyoffice, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
REMOVE_OLD="$(find "$LETSENCRYPTPATH/" -name "$SUBDOMAIN*")"
for remove in $REMOVE_OLD
do rm -rf "$remove"
done
fi
# Remove Apache2 config
if [ -f "$SITES_AVAILABLE/$SUBDOMAIN.conf" ]
then
a2dissite "$SUBDOMAIN".conf
restart_webserver
rm -f "$SITES_AVAILABLE/$SUBDOMAIN.conf"
fi
# Remove trusted domain
count=0
while [ "$count" -lt 10 ]
do
if [ "$(occ_command_no_check config:system:get trusted_domains "$count")" == "$SUBDOMAIN" ]
then
occ_command_no_check config:system:delete trusted_domains "$count"
break
else
count=$((count+1))
fi
done
else
# Remove OnlyOffice app
if is_app_installed onlyoffice
then
occ_command app:remove onlyoffice
fi
fi
# remove OnlyOffice-documentserver if activated
if is_app_enabled documentserver_community
then
any_key "OnlyOffice will get uninstalled. Press any key to continue. Press CTRL+C to abort"
occ_command app:remove documentserver_community
fi
# Disable OnlyOffice App if activated
if is_app_installed onlyoffice
then
occ_command app:remove onlyoffice
fi
# Install Collabora
msg_box "We will now install Collabora.
Please note that it might take very long time to install the app, and you will not see any progress bar.
Please be paitent, don't abort."
install_and_enable_app richdocuments
sleep 2
if install_and_enable_app richdocumentscode
then
chown -R www-data:www-data "$NC_APPS_PATH"
msg_box "Collabora was successfully installed."
else
msg_box "The Collabora app failed to install. Please try again later."
fi
if ! is_app_installed richdocuments
then
msg_box "The Collabora app failed to install. Please try again later."
fi
# Just make sure the script exits
exit
|