|
@@ -0,0 +1,515 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+#
|
|
3
|
+# .---. . .
|
|
4
|
+# | | |
|
|
5
|
+# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
6
|
+# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
7
|
+# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
8
|
+#
|
|
9
|
+# Freedom in the Cloud
|
|
10
|
+#
|
|
11
|
+# nextcloud application
|
|
12
|
+#
|
|
13
|
+# License
|
|
14
|
+# =======
|
|
15
|
+#
|
|
16
|
+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
|
|
17
|
+#
|
|
18
|
+# This program is free software: you can redistribute it and/or modify
|
|
19
|
+# it under the terms of the GNU Affero General Public License as published by
|
|
20
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
21
|
+# (at your option) any later version.
|
|
22
|
+#
|
|
23
|
+# This program is distributed in the hope that it will be useful,
|
|
24
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
25
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
26
|
+# GNU Affero General Public License for more details.
|
|
27
|
+#
|
|
28
|
+# You should have received a copy of the GNU Affero General Public License
|
|
29
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
30
|
+
|
|
31
|
+VARIANTS='full full-vim media'
|
|
32
|
+
|
|
33
|
+IN_DEFAULT_INSTALL=0
|
|
34
|
+SHOW_ON_ABOUT=1
|
|
35
|
+
|
|
36
|
+NEXTCLOUD_DOMAIN_NAME=
|
|
37
|
+NEXTCLOUD_CODE=
|
|
38
|
+NEXTCLOUD_ONION_PORT=8087
|
|
39
|
+NEXTCLOUD_REPO="https://github.com/nextcloud/server"
|
|
40
|
+NEXTCLOUD_COMMIT='562c45d925a27b21f694a091029d87158364970c'
|
|
41
|
+NEXTCLOUD_ADMIN_PASSWORD=
|
|
42
|
+
|
|
43
|
+nextcloud_variables=(ONION_ONLY
|
|
44
|
+ NEXTCLOUD_DOMAIN_NAME
|
|
45
|
+ NEXTCLOUD_CODE
|
|
46
|
+ DDNS_PROVIDER
|
|
47
|
+ MY_USERNAME)
|
|
48
|
+
|
|
49
|
+function remove_user_nextcloud {
|
|
50
|
+ remove_username="$1"
|
|
51
|
+
|
|
52
|
+ ${PROJECT_NAME}-pass -u $remove_username --rmapp nextcloud
|
|
53
|
+}
|
|
54
|
+
|
|
55
|
+function add_user_nextcloud {
|
|
56
|
+ new_username="$1"
|
|
57
|
+ new_user_password="$2"
|
|
58
|
+
|
|
59
|
+ ${PROJECT_NAME}-pass -u $new_username -a nextcloud -p "$new_user_password"
|
|
60
|
+ echo '0'
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+function install_interactive_nextcloud {
|
|
64
|
+ if [ ! $ONION_ONLY ]; then
|
|
65
|
+ ONION_ONLY='no'
|
|
66
|
+ fi
|
|
67
|
+
|
|
68
|
+ if [[ $ONION_ONLY != "no" ]]; then
|
|
69
|
+ NEXTCLOUD_DOMAIN_NAME='nextcloud.local'
|
|
70
|
+ else
|
|
71
|
+ NEXTCLOUD_DETAILS_COMPLETE=
|
|
72
|
+ while [ ! $NEXTCLOUD_DETAILS_COMPLETE ]
|
|
73
|
+ do
|
|
74
|
+ data=$(tempfile 2>/dev/null)
|
|
75
|
+ trap "rm -f $data" 0 1 2 5 15
|
|
76
|
+ if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
|
77
|
+ dialog --backtitle $"Freedombone Configuration" \
|
|
78
|
+ --title $"NextCloud Configuration" \
|
|
79
|
+ --form $"\nPlease enter your NextCloud details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
|
80
|
+ $"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
|
81
|
+ $"Code:" 3 1 "$(grep 'NEXTCLOUD_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 25 33 255 \
|
|
82
|
+ 2> $data
|
|
83
|
+ else
|
|
84
|
+ dialog --backtitle $"Freedombone Configuration" \
|
|
85
|
+ --title $"NextCloud Configuration" \
|
|
86
|
+ --form $"\nPlease enter your NextCloud details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
|
87
|
+ $"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
|
88
|
+ 2> $data
|
|
89
|
+ fi
|
|
90
|
+ sel=$?
|
|
91
|
+ case $sel in
|
|
92
|
+ 1) exit 1;;
|
|
93
|
+ 255) exit 1;;
|
|
94
|
+ esac
|
|
95
|
+ NEXTCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
|
96
|
+ title=$(cat $data | sed -n 2p)
|
|
97
|
+ if [ ${#title} -gt 1 ]; then
|
|
98
|
+ NEXTCLOUD_TITLE=$welcome_msg
|
|
99
|
+ fi
|
|
100
|
+ img_url=$(cat $data | sed -n 3p)
|
|
101
|
+ if [ ${#img_url} -gt 1 ]; then
|
|
102
|
+ NEXTCLOUD_BACKGROUND_IMAGE_URL=$img_url
|
|
103
|
+ fi
|
|
104
|
+ if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
105
|
+ TEST_DOMAIN_NAME=$NEXTCLOUD_DOMAIN_NAME
|
|
106
|
+ validate_domain_name
|
|
107
|
+ if [[ $TEST_DOMAIN_NAME != $NEXTCLOUD_DOMAIN_NAME ]]; then
|
|
108
|
+ NEXTCLOUD_DOMAIN_NAME=
|
|
109
|
+ dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
|
110
|
+ else
|
|
111
|
+ if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
|
112
|
+ NEXTCLOUD_CODE=$(cat $data | sed -n 4p)
|
|
113
|
+ validate_freedns_code "$NEXTCLOUD_CODE"
|
|
114
|
+ if [ ! $VALID_CODE ]; then
|
|
115
|
+ NEXTCLOUD_DOMAIN_NAME=
|
|
116
|
+ fi
|
|
117
|
+ fi
|
|
118
|
+ fi
|
|
119
|
+ fi
|
|
120
|
+ if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
121
|
+ NEXTCLOUD_DETAILS_COMPLETE="yes"
|
|
122
|
+ fi
|
|
123
|
+ done
|
|
124
|
+
|
|
125
|
+ # remove any invalid characters
|
|
126
|
+ if [ ${#NEXTCLOUD_TITLE} -gt 0 ]; then
|
|
127
|
+ new_title=$(echo "$NEXTCLOUD_TITLE" | sed "s|'||g")
|
|
128
|
+ NEXTCLOUD_TITLE="$new_title"
|
|
129
|
+ fi
|
|
130
|
+
|
|
131
|
+ # save the results in the config file
|
|
132
|
+ write_config_param "NEXTCLOUD_CODE" "$NEXTCLOUD_CODE"
|
|
133
|
+ fi
|
|
134
|
+ write_config_param "NEXTCLOUD_DOMAIN_NAME" "$NEXTCLOUD_DOMAIN_NAME"
|
|
135
|
+ APP_INSTALLED=1
|
|
136
|
+}
|
|
137
|
+
|
|
138
|
+function change_password_nextcloud {
|
|
139
|
+ curr_username="$1"
|
|
140
|
+ new_user_password="$2"
|
|
141
|
+
|
|
142
|
+ read_config_param ${NEXTCLOUD_DOMAIN_NAME}
|
|
143
|
+
|
|
144
|
+ ${PROJECT_NAME}-pass -u "$curr_username" -a nextcloud -p "$new_user_password"
|
|
145
|
+}
|
|
146
|
+
|
|
147
|
+function nextcloud_create_database {
|
|
148
|
+ if [ -f $IMAGE_PASSWORD_FILE ]; then
|
|
149
|
+ NEXTCLOUD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
|
150
|
+ else
|
|
151
|
+ if [ ! $NEXTCLOUD_ADMIN_PASSWORD ]; then
|
|
152
|
+ NEXTCLOUD_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
|
153
|
+ fi
|
|
154
|
+ fi
|
|
155
|
+ if [ ! $NEXTCLOUD_ADMIN_PASSWORD ]; then
|
|
156
|
+ return
|
|
157
|
+ fi
|
|
158
|
+
|
|
159
|
+ function_check create_database
|
|
160
|
+ create_database nextcloud "$NEXTCLOUD_ADMIN_PASSWORD" $MY_USERNAME
|
|
161
|
+}
|
|
162
|
+
|
|
163
|
+function reconfigure_nextcloud {
|
|
164
|
+ echo -n ''
|
|
165
|
+}
|
|
166
|
+
|
|
167
|
+function configure_interactive_nextcloud {
|
|
168
|
+ echo -n ''
|
|
169
|
+}
|
|
170
|
+
|
|
171
|
+function upgrade_nextcloud {
|
|
172
|
+ if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
|
173
|
+ NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
174
|
+ fi
|
|
175
|
+
|
|
176
|
+ # update to the next commit
|
|
177
|
+ function_check set_repo_commit
|
|
178
|
+ set_repo_commit /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs "nextcloud commit" "$NEXTCLOUD_COMMIT" $NEXTCLOUD_REPO
|
|
179
|
+}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+function backup_local_nextcloud {
|
|
183
|
+ NEXTCLOUD_DOMAIN_NAME='nextcloud'
|
|
184
|
+ if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
|
185
|
+ NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
186
|
+ fi
|
|
187
|
+
|
|
188
|
+ source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
|
189
|
+ if [ -d $source_directory ]; then
|
|
190
|
+ dest_directory=nextcloud
|
|
191
|
+ function_check suspend_site
|
|
192
|
+ suspend_site ${NEXTCLOUD_DOMAIN_NAME}
|
|
193
|
+
|
|
194
|
+ function_check backup_directory_to_usb
|
|
195
|
+ backup_directory_to_usb $source_directory $dest_directory
|
|
196
|
+
|
|
197
|
+ function_check backup_database_to_usb
|
|
198
|
+ backup_database_to_usb nextcloud
|
|
199
|
+
|
|
200
|
+ function_check restart_site
|
|
201
|
+ restart_site
|
|
202
|
+ fi
|
|
203
|
+}
|
|
204
|
+
|
|
205
|
+function restore_local_nextcloud {
|
|
206
|
+ if ! grep -q "nextcloud domain" $COMPLETION_FILE; then
|
|
207
|
+ return
|
|
208
|
+ fi
|
|
209
|
+ NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
210
|
+ if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
211
|
+ temp_restore_dir=/root/tempnextcloud
|
|
212
|
+ nextcloud_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
|
213
|
+
|
|
214
|
+ function_check nextcloud_create_database
|
|
215
|
+ nextcloud_create_database
|
|
216
|
+
|
|
217
|
+ restore_database nextcloud ${NEXTCLOUD_DOMAIN_NAME}
|
|
218
|
+ if [ -d $temp_restore_dir ]; then
|
|
219
|
+ rm -rf $temp_restore_dir
|
|
220
|
+ fi
|
|
221
|
+ fi
|
|
222
|
+}
|
|
223
|
+
|
|
224
|
+function backup_remote_nextcloud {
|
|
225
|
+ if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
|
226
|
+ NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
227
|
+ temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
|
228
|
+ if [ -d $temp_backup_dir ]; then
|
|
229
|
+ function_check suspend_site
|
|
230
|
+ suspend_site ${NEXTCLOUD_DOMAIN_NAME}
|
|
231
|
+
|
|
232
|
+ function_check backup_database_to_friend
|
|
233
|
+ backup_database_to_friend nextcloud
|
|
234
|
+
|
|
235
|
+ echo $"Backing up GNU social installation"
|
|
236
|
+
|
|
237
|
+ function_check backup_directory_to_friend
|
|
238
|
+ backup_directory_to_friend $temp_backup_dir nextcloud
|
|
239
|
+
|
|
240
|
+ function_check restart_site
|
|
241
|
+ restart_site
|
|
242
|
+ else
|
|
243
|
+ echo $"nextcloud domain specified but not found in ${temp_backup_dir}"
|
|
244
|
+ fi
|
|
245
|
+ fi
|
|
246
|
+}
|
|
247
|
+
|
|
248
|
+function restore_remote_nextcloud {
|
|
249
|
+ if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
|
250
|
+ echo $"Restoring nextcloud"
|
|
251
|
+ NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
252
|
+
|
|
253
|
+ function_check nextcloud_create_database
|
|
254
|
+ nextcloud_create_database
|
|
255
|
+
|
|
256
|
+ function_check restore_database_from_friend
|
|
257
|
+ restore_database_from_friend nextcloud ${NEXTCLOUD_DOMAIN_NAME}
|
|
258
|
+ if [ -d /root/tempnextcloud ]; then
|
|
259
|
+ rm -rf /root/tempnextcloud
|
|
260
|
+ fi
|
|
261
|
+ fi
|
|
262
|
+}
|
|
263
|
+
|
|
264
|
+function remove_nextcloud {
|
|
265
|
+ if [ ${#NEXTCLOUD_DOMAIN_NAME} -eq 0 ]; then
|
|
266
|
+ return
|
|
267
|
+ fi
|
|
268
|
+ function_check remove_nodejs
|
|
269
|
+ remove_nodejs pleroma-nextcloud
|
|
270
|
+
|
|
271
|
+ read_config_param "NEXTCLOUD_DOMAIN_NAME"
|
|
272
|
+ read_config_param "MY_USERNAME"
|
|
273
|
+ echo "Removing $NEXTCLOUD_DOMAIN_NAME"
|
|
274
|
+ nginx_dissite $NEXTCLOUD_DOMAIN_NAME
|
|
275
|
+ remove_certs $NEXTCLOUD_DOMAIN_NAME
|
|
276
|
+ if [ -d /var/www/$NEXTCLOUD_DOMAIN_NAME ]; then
|
|
277
|
+ rm -rf /var/www/$NEXTCLOUD_DOMAIN_NAME
|
|
278
|
+ fi
|
|
279
|
+ if [ -f /etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME ]; then
|
|
280
|
+ rm /etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
|
281
|
+ fi
|
|
282
|
+ function_check drop_database
|
|
283
|
+ drop_database nextcloud
|
|
284
|
+ function_check remove_onion_service
|
|
285
|
+ remove_onion_service nextcloud ${NEXTCLOUD_ONION_PORT}
|
|
286
|
+ if grep -q "nextcloud" /etc/crontab; then
|
|
287
|
+ sed -i "/nextcloud/d" /etc/crontab
|
|
288
|
+ fi
|
|
289
|
+ remove_app nextcloud
|
|
290
|
+ remove_completion_param install_nextcloud
|
|
291
|
+ sed -i '/nextcloud/d' $COMPLETION_FILE
|
|
292
|
+ remove_backup_database_local nextcloud
|
|
293
|
+
|
|
294
|
+ function_check remove_ddns_domain
|
|
295
|
+ remove_ddns_domain $NEXTCLOUD_DOMAIN_NAME
|
|
296
|
+}
|
|
297
|
+
|
|
298
|
+function install_nextcloud_main {
|
|
299
|
+ if [ ! $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
300
|
+ echo $'No domain name was given for nextcloud'
|
|
301
|
+ exit 7359
|
|
302
|
+ fi
|
|
303
|
+
|
|
304
|
+ if [[ $(app_is_installed nextcloud_main) == "1" ]]; then
|
|
305
|
+ return
|
|
306
|
+ fi
|
|
307
|
+
|
|
308
|
+ function_check install_mariadb
|
|
309
|
+ install_mariadb
|
|
310
|
+
|
|
311
|
+ function_check get_mariadb_password
|
|
312
|
+ get_mariadb_password
|
|
313
|
+
|
|
314
|
+ function_check repair_databases_script
|
|
315
|
+ repair_databases_script
|
|
316
|
+
|
|
317
|
+ apt-get -yq install php-gettext php5-curl php5-gd php5-mysql git curl php-xml-parser
|
|
318
|
+ apt-get -yq install php5-memcached php5-intl
|
|
319
|
+
|
|
320
|
+ if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME ]; then
|
|
321
|
+ mkdir /var/www/$NEXTCLOUD_DOMAIN_NAME
|
|
322
|
+ fi
|
|
323
|
+ if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs ]; then
|
|
324
|
+ function_check git_clone
|
|
325
|
+ git_clone $NEXTCLOUD_REPO /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
|
326
|
+ if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs ]; then
|
|
327
|
+ echo $'Unable to clone nextcloud repo'
|
|
328
|
+ exit 87525
|
|
329
|
+ fi
|
|
330
|
+ fi
|
|
331
|
+
|
|
332
|
+ cd /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
|
333
|
+ git submodule update --init
|
|
334
|
+ git checkout $NEXTCLOUD_COMMIT -b $NEXTCLOUD_COMMIT
|
|
335
|
+ set_completion_param "nextcloud commit" "$NEXTCLOUD_COMMIT"
|
|
336
|
+
|
|
337
|
+ chmod g+w /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
|
338
|
+ chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
|
339
|
+
|
|
340
|
+ function_check nextcloud_create_database
|
|
341
|
+ nextcloud_create_database
|
|
342
|
+
|
|
343
|
+ if [ ! -f "/etc/aliases" ]; then
|
|
344
|
+ touch /etc/aliases
|
|
345
|
+ fi
|
|
346
|
+ if ! grep -q "www-data: root" /etc/aliases; then
|
|
347
|
+ echo 'www-data: root' >> /etc/aliases
|
|
348
|
+ fi
|
|
349
|
+
|
|
350
|
+ function_check add_ddns_domain
|
|
351
|
+ add_ddns_domain $NEXTCLOUD_DOMAIN_NAME
|
|
352
|
+
|
|
353
|
+ nextcloud_nginx_site=/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
|
354
|
+ if [[ $ONION_ONLY == "no" ]]; then
|
|
355
|
+ function_check nginx_http_redirect
|
|
356
|
+ nginx_http_redirect $NEXTCLOUD_DOMAIN_NAME
|
|
357
|
+ echo 'server {' >> $nextcloud_nginx_site
|
|
358
|
+ echo ' listen 443 ssl;' >> $nextcloud_nginx_site
|
|
359
|
+ echo ' listen [::]:443 ssl;' >> $nextcloud_nginx_site
|
|
360
|
+ echo " server_name $NEXTCLOUD_DOMAIN_NAME;" >> $nextcloud_nginx_site
|
|
361
|
+ echo '' >> $nextcloud_nginx_site
|
|
362
|
+ echo ' # Security' >> $nextcloud_nginx_site
|
|
363
|
+ function_check nginx_ssl
|
|
364
|
+ nginx_ssl $NEXTCLOUD_DOMAIN_NAME
|
|
365
|
+
|
|
366
|
+ function_check nginx_disable_sniffing
|
|
367
|
+ nginx_disable_sniffing $NEXTCLOUD_DOMAIN_NAME
|
|
368
|
+
|
|
369
|
+ echo ' add_header Strict-Transport-Security max-age=15768000;' >> $nextcloud_nginx_site
|
|
370
|
+ echo '' >> $nextcloud_nginx_site
|
|
371
|
+ echo ' # Logs' >> $nextcloud_nginx_site
|
|
372
|
+ echo ' access_log /dev/null;' >> $nextcloud_nginx_site
|
|
373
|
+ echo ' error_log /dev/null;' >> $nextcloud_nginx_site
|
|
374
|
+ echo '' >> $nextcloud_nginx_site
|
|
375
|
+ echo ' # Root' >> $nextcloud_nginx_site
|
|
376
|
+ echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;" >> $nextcloud_nginx_site
|
|
377
|
+ echo '' >> $nextcloud_nginx_site
|
|
378
|
+ echo ' # Index' >> $nextcloud_nginx_site
|
|
379
|
+ echo ' index index.php;' >> $nextcloud_nginx_site
|
|
380
|
+ echo '' >> $nextcloud_nginx_site
|
|
381
|
+ echo ' # PHP' >> $nextcloud_nginx_site
|
|
382
|
+ echo ' location ~ \.php {' >> $nextcloud_nginx_site
|
|
383
|
+ echo ' include snippets/fastcgi-php.conf;' >> $nextcloud_nginx_site
|
|
384
|
+ echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $nextcloud_nginx_site
|
|
385
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
386
|
+ echo '' >> $nextcloud_nginx_site
|
|
387
|
+ echo ' # Location' >> $nextcloud_nginx_site
|
|
388
|
+ echo ' location / {' >> $nextcloud_nginx_site
|
|
389
|
+ function_check nginx_limits
|
|
390
|
+ nginx_limits $NEXTCLOUD_DOMAIN_NAME '15m'
|
|
391
|
+ echo ' try_files $uri $uri/ @nextcloud;' >> $nextcloud_nginx_site
|
|
392
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
393
|
+ echo '' >> $nextcloud_nginx_site
|
|
394
|
+ echo ' # Fancy URLs' >> $nextcloud_nginx_site
|
|
395
|
+ echo ' location @nextcloud {' >> $nextcloud_nginx_site
|
|
396
|
+ echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $nextcloud_nginx_site
|
|
397
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
398
|
+ echo '' >> $nextcloud_nginx_site
|
|
399
|
+ echo ' # Restrict access that is unnecessary anyway' >> $nextcloud_nginx_site
|
|
400
|
+ echo ' location ~ /\.(ht|git) {' >> $nextcloud_nginx_site
|
|
401
|
+ echo ' deny all;' >> $nextcloud_nginx_site
|
|
402
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
403
|
+ echo '' >> $nextcloud_nginx_site
|
|
404
|
+ # DO NOT ENABLE KEYBASE. nextcloud really doesn't like having a .well-known directory
|
|
405
|
+ echo '}' >> $nextcloud_nginx_site
|
|
406
|
+ else
|
|
407
|
+ echo -n '' > $nextcloud_nginx_site
|
|
408
|
+ fi
|
|
409
|
+ echo 'server {' >> $nextcloud_nginx_site
|
|
410
|
+ echo " listen 127.0.0.1:$NEXTCLOUD_ONION_PORT default_server;" >> $nextcloud_nginx_site
|
|
411
|
+ echo " server_name $NEXTCLOUD_DOMAIN_NAME;" >> $nextcloud_nginx_site
|
|
412
|
+ echo '' >> $nextcloud_nginx_site
|
|
413
|
+ function_check nginx_disable_sniffing
|
|
414
|
+ nginx_disable_sniffing $NEXTCLOUD_DOMAIN_NAME
|
|
415
|
+ echo '' >> $nextcloud_nginx_site
|
|
416
|
+ echo ' # Logs' >> $nextcloud_nginx_site
|
|
417
|
+ echo ' access_log /dev/null;' >> $nextcloud_nginx_site
|
|
418
|
+ echo ' error_log /dev/null;' >> $nextcloud_nginx_site
|
|
419
|
+ echo '' >> $nextcloud_nginx_site
|
|
420
|
+ echo ' # Root' >> $nextcloud_nginx_site
|
|
421
|
+ echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;" >> $nextcloud_nginx_site
|
|
422
|
+ echo '' >> $nextcloud_nginx_site
|
|
423
|
+ echo ' # Index' >> $nextcloud_nginx_site
|
|
424
|
+ echo ' index index.php;' >> $nextcloud_nginx_site
|
|
425
|
+ echo '' >> $nextcloud_nginx_site
|
|
426
|
+ echo ' # PHP' >> $nextcloud_nginx_site
|
|
427
|
+ echo ' location ~ \.php {' >> $nextcloud_nginx_site
|
|
428
|
+ echo ' include snippets/fastcgi-php.conf;' >> $nextcloud_nginx_site
|
|
429
|
+ echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $nextcloud_nginx_site
|
|
430
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
431
|
+ echo '' >> $nextcloud_nginx_site
|
|
432
|
+ echo ' # Location' >> $nextcloud_nginx_site
|
|
433
|
+ echo ' location / {' >> $nextcloud_nginx_site
|
|
434
|
+ function_check nginx_limits
|
|
435
|
+ nginx_limits $NEXTCLOUD_DOMAIN_NAME '15m'
|
|
436
|
+ echo ' try_files $uri $uri/ @nextcloud;' >> $nextcloud_nginx_site
|
|
437
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
438
|
+ echo '' >> $nextcloud_nginx_site
|
|
439
|
+ echo ' # Fancy URLs' >> $nextcloud_nginx_site
|
|
440
|
+ echo ' location @nextcloud {' >> $nextcloud_nginx_site
|
|
441
|
+ echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $nextcloud_nginx_site
|
|
442
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
443
|
+ echo '' >> $nextcloud_nginx_site
|
|
444
|
+ echo ' # Restrict access that is unnecessary anyway' >> $nextcloud_nginx_site
|
|
445
|
+ echo ' location ~ /\.(ht|git) {' >> $nextcloud_nginx_site
|
|
446
|
+ echo ' deny all;' >> $nextcloud_nginx_site
|
|
447
|
+ echo ' }' >> $nextcloud_nginx_site
|
|
448
|
+ echo '' >> $nextcloud_nginx_site
|
|
449
|
+ echo '}' >> $nextcloud_nginx_site
|
|
450
|
+
|
|
451
|
+ function_check configure_php
|
|
452
|
+ configure_php
|
|
453
|
+
|
|
454
|
+ function_check create_site_certificate
|
|
455
|
+ create_site_certificate $NEXTCLOUD_DOMAIN_NAME 'yes'
|
|
456
|
+
|
|
457
|
+ # Ensure that the database gets backed up locally, if remote
|
|
458
|
+ # backups are not being used
|
|
459
|
+ function_check backup_databases_script_header
|
|
460
|
+ backup_databases_script_header
|
|
461
|
+
|
|
462
|
+ function_check backup_database_local
|
|
463
|
+ backup_database_local nextcloud
|
|
464
|
+
|
|
465
|
+ function_check nginx_ensite
|
|
466
|
+ nginx_ensite $NEXTCLOUD_DOMAIN_NAME
|
|
467
|
+
|
|
468
|
+ # NOTE: For the typical case always enable SSL and only
|
|
469
|
+ # disable it if in onion only mode. This is due to complexities
|
|
470
|
+ # with the way URLs are generated by nextcloud
|
|
471
|
+ nextcloud_ssl='always'
|
|
472
|
+ if [[ $ONION_ONLY != 'no' ]]; then
|
|
473
|
+ nextcloud_ssl='never'
|
|
474
|
+ fi
|
|
475
|
+
|
|
476
|
+ NEXTCLOUD_ONION_HOSTNAME=$(add_onion_service nextcloud 80 ${NEXTCLOUD_ONION_PORT})
|
|
477
|
+
|
|
478
|
+ NEXTCLOUD_SERVER=${NEXTCLOUD_DOMAIN_NAME}
|
|
479
|
+ if [[ $ONION_ONLY != 'no' ]]; then
|
|
480
|
+ NEXTCLOUD_SERVER=${NEXTCLOUD_ONION_HOSTNAME}
|
|
481
|
+ fi
|
|
482
|
+
|
|
483
|
+ systemctl restart php5-fpm
|
|
484
|
+ systemctl restart nginx
|
|
485
|
+
|
|
486
|
+ ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$NEXTCLOUD_DOMAIN_NAME" -g nextcloud --public no
|
|
487
|
+
|
|
488
|
+ ${PROJECT_NAME}-pass -u $MY_USERNAME -a nextcloud -p "$NEXTCLOUD_ADMIN_PASSWORD"
|
|
489
|
+
|
|
490
|
+ cd /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
|
491
|
+ ./occ maintenance:install --database-name nextcloud --admin-user ${MY_USERNAME} --admin-pass "${NEXTCLOUD_ADMIN_PASSWORD}" --database mysql --database-user root --database-pass "${MARIADB_PASSWORD}"
|
|
492
|
+ ./occ check
|
|
493
|
+ ./occ status
|
|
494
|
+ ./occ app:list
|
|
495
|
+ ./occ app:enable passman
|
|
496
|
+ ./occ config:system:set defaultapp --value=passman
|
|
497
|
+ ./occ config:system:set appstoreenabled --value=true
|
|
498
|
+ ./occ config:system:set trusted_domains 2 --value=$NEXTCLOUD_DOMAIN_NAME
|
|
499
|
+
|
|
500
|
+ set_completion_param "nextcloud domain" "$NEXTCLOUD_DOMAIN_NAME"
|
|
501
|
+
|
|
502
|
+ install_completed nextcloud_main
|
|
503
|
+}
|
|
504
|
+
|
|
505
|
+function install_nextcloud {
|
|
506
|
+ if [ ! $ONION_ONLY ]; then
|
|
507
|
+ ONION_ONLY='no'
|
|
508
|
+ fi
|
|
509
|
+
|
|
510
|
+ install_nextcloud_main
|
|
511
|
+
|
|
512
|
+ APP_INSTALLED=1
|
|
513
|
+}
|
|
514
|
+
|
|
515
|
+# NOTE: deliberately there is no "exit 0"
|