2017-03-14 22:40:40 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# nextcloud application
|
2017-03-15 00:45:05 +01:00
|
|
|
# In tests this is much too slow, and it appeared to self-destruct after a few minutes
|
|
|
|
# i.e. becoming totally unusable.
|
2017-03-14 22:40:40 +01:00
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2018-01-25 19:35:39 +01:00
|
|
|
# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
|
2017-03-14 22:40:40 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-05-08 12:27:14 +02:00
|
|
|
VARIANTS='full full-vim cloud'
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
IN_DEFAULT_INSTALL=0
|
2017-05-08 12:27:14 +02:00
|
|
|
SHOW_ON_ABOUT=1
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
NEXTCLOUD_DOMAIN_NAME=
|
|
|
|
NEXTCLOUD_CODE=
|
2017-03-14 23:06:02 +01:00
|
|
|
NEXTCLOUD_ONION_PORT=8112
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_REPO="https://github.com/nextcloud/server"
|
2018-02-06 20:16:45 +01:00
|
|
|
# Stable 13 branch
|
|
|
|
NEXTCLOUD_COMMIT='b16824db31cd00e26e72216bf995d52389b9c93c'
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_ADMIN_PASSWORD=
|
|
|
|
|
|
|
|
nextcloud_variables=(ONION_ONLY
|
|
|
|
NEXTCLOUD_DOMAIN_NAME
|
|
|
|
NEXTCLOUD_CODE
|
|
|
|
DDNS_PROVIDER
|
|
|
|
MY_USERNAME)
|
|
|
|
|
2017-07-01 20:14:28 +02:00
|
|
|
function logging_on_nextcloud {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function logging_off_nextcloud {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
function remove_user_nextcloud {
|
|
|
|
remove_username="$1"
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp nextcloud
|
2017-03-14 22:40:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_user_nextcloud {
|
|
|
|
new_username="$1"
|
|
|
|
new_user_password="$2"
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$new_username" -a nextcloud -p "$new_user_password"
|
2017-03-14 22:40:40 +01:00
|
|
|
echo '0'
|
|
|
|
}
|
|
|
|
|
2017-05-09 13:03:49 +02:00
|
|
|
function change_password_nextcloud {
|
|
|
|
curr_username="$1"
|
|
|
|
|
|
|
|
export OC_PASS="$2"
|
|
|
|
su -s /bin/sh www-data -c "php occ user:resetpassword --password-from-env $curr_username"
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a nextcloud -p "$OC_PASS"
|
2017-05-09 13:03:49 +02:00
|
|
|
export OC_PASS=""
|
|
|
|
}
|
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
function install_interactive_nextcloud {
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$ONION_ONLY" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
ONION_ONLY='no'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
NEXTCLOUD_DOMAIN_NAME='nextcloud.local'
|
|
|
|
else
|
|
|
|
NEXTCLOUD_DETAILS_COMPLETE=
|
|
|
|
while [ ! $NEXTCLOUD_DETAILS_COMPLETE ]
|
|
|
|
do
|
2018-03-01 00:17:49 +01:00
|
|
|
data=$(mktemp 2>/dev/null)
|
2017-03-14 22:40:40 +01:00
|
|
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
|
|
|
dialog --backtitle $"Freedombone Configuration" \
|
|
|
|
--title $"NextCloud Configuration" \
|
2018-03-01 00:17:49 +01:00
|
|
|
--form $"\\nPlease enter your NextCloud details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 3 \
|
2017-03-14 22:52:28 +01:00
|
|
|
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
|
|
|
$"Code:" 2 1 "$(grep 'NEXTCLOUD_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 40 255 \
|
2018-03-01 00:17:49 +01:00
|
|
|
2> "$data"
|
2017-03-14 22:40:40 +01:00
|
|
|
else
|
|
|
|
dialog --backtitle $"Freedombone Configuration" \
|
|
|
|
--title $"NextCloud Configuration" \
|
2018-03-01 00:17:49 +01:00
|
|
|
--form $"\\nPlease enter your NextCloud details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 2 \
|
2017-03-14 22:52:28 +01:00
|
|
|
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
2018-03-01 00:17:49 +01:00
|
|
|
2> "$data"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
|
|
|
sel=$?
|
|
|
|
case $sel in
|
2018-03-01 00:17:49 +01:00
|
|
|
1) rm -f "$data"
|
|
|
|
exit 1;;
|
|
|
|
255) rm -f "$data"
|
|
|
|
exit 1;;
|
2017-03-14 22:40:40 +01:00
|
|
|
esac
|
2018-03-01 00:17:49 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(sed -n 1p < "$data")
|
|
|
|
if [ "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
TEST_DOMAIN_NAME=$NEXTCLOUD_DOMAIN_NAME
|
|
|
|
validate_domain_name
|
2018-03-01 00:17:49 +01:00
|
|
|
if [[ "$TEST_DOMAIN_NAME" != "$NEXTCLOUD_DOMAIN_NAME" ]]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=
|
|
|
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
|
|
|
else
|
|
|
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
2018-03-01 00:17:49 +01:00
|
|
|
NEXTCLOUD_CODE=$(sed -n 2p < "$data")
|
2017-03-14 22:40:40 +01:00
|
|
|
validate_freedns_code "$NEXTCLOUD_CODE"
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$VALID_CODE" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
|
|
NEXTCLOUD_DETAILS_COMPLETE="yes"
|
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
rm -f "$data"
|
2017-03-14 22:40:40 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# remove any invalid characters
|
|
|
|
if [ ${#NEXTCLOUD_TITLE} -gt 0 ]; then
|
2018-03-06 17:18:20 +01:00
|
|
|
new_title=${NEXTCLOUD_TITLE//\'/}
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_TITLE="$new_title"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# save the results in the config file
|
|
|
|
write_config_param "NEXTCLOUD_CODE" "$NEXTCLOUD_CODE"
|
|
|
|
fi
|
|
|
|
write_config_param "NEXTCLOUD_DOMAIN_NAME" "$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
APP_INSTALLED=1
|
|
|
|
}
|
|
|
|
|
|
|
|
function change_password_nextcloud {
|
|
|
|
curr_username="$1"
|
|
|
|
new_user_password="$2"
|
|
|
|
|
|
|
|
read_config_param ${NEXTCLOUD_DOMAIN_NAME}
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a nextcloud -p "$new_user_password"
|
2017-03-14 22:40:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function nextcloud_create_database {
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
|
|
|
NEXTCLOUD_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
2017-03-14 22:40:40 +01:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$NEXTCLOUD_ADMIN_PASSWORD" ]; then
|
|
|
|
NEXTCLOUD_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$NEXTCLOUD_ADMIN_PASSWORD" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check create_database
|
2018-03-01 00:17:49 +01:00
|
|
|
create_database nextcloud "$NEXTCLOUD_ADMIN_PASSWORD" "$MY_USERNAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function reconfigure_nextcloud {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function configure_interactive_nextcloud {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
2017-08-07 22:29:31 +02:00
|
|
|
function upgrade_nextcloud_base {
|
|
|
|
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
|
|
|
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/data
|
2018-03-01 00:17:49 +01:00
|
|
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 232547985
|
2017-08-07 22:29:31 +02:00
|
|
|
sudo -u www-data ./occ maintenance:repair
|
|
|
|
sudo -u www-data ./occ files:cleanup
|
|
|
|
sudo -u www-data ./occ files:scan --all
|
|
|
|
sudo -u www-data ./occ maintenance:mode --off
|
|
|
|
}
|
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
function upgrade_nextcloud {
|
2017-06-12 23:59:25 +02:00
|
|
|
CURR_NEXTCLOUD_COMMIT=$(get_completion_param "nextcloud commit")
|
|
|
|
if [[ "$CURR_NEXTCLOUD_COMMIT" == "$NEXTCLOUD_COMMIT" ]]; then
|
2017-08-07 22:29:31 +02:00
|
|
|
upgrade_nextcloud_base
|
2017-06-12 23:59:25 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
|
|
fi
|
|
|
|
|
|
|
|
# update to the next commit
|
|
|
|
function_check set_repo_commit
|
2018-03-01 00:17:49 +01:00
|
|
|
set_repo_commit "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" "nextcloud commit" "$NEXTCLOUD_COMMIT" "$NEXTCLOUD_REPO"
|
2017-03-14 23:31:40 +01:00
|
|
|
|
2017-08-07 22:29:31 +02:00
|
|
|
upgrade_nextcloud_base
|
2017-08-08 20:24:47 +02:00
|
|
|
sudo -u www-data ./occ upgrade
|
2017-03-14 22:40:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function backup_local_nextcloud {
|
|
|
|
NEXTCLOUD_DOMAIN_NAME='nextcloud'
|
2018-03-01 00:17:49 +01:00
|
|
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
|
|
fi
|
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$source_directory" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check suspend_site
|
2018-03-01 00:17:49 +01:00
|
|
|
suspend_site "${NEXTCLOUD_DOMAIN_NAME}"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
dest_directory=nextcloudfiles
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check backup_directory_to_usb
|
2018-03-01 00:17:49 +01:00
|
|
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
|
|
|
dest_directory=nextcloudconfig
|
2018-03-01 00:17:49 +01:00
|
|
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
2017-05-08 22:30:19 +02:00
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check backup_database_to_usb
|
|
|
|
backup_database_to_usb nextcloud
|
|
|
|
|
|
|
|
function_check restart_site
|
|
|
|
restart_site
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function restore_local_nextcloud {
|
2018-03-01 00:17:49 +01:00
|
|
|
if ! grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
2017-03-14 22:40:40 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
temp_restore_dir=/root/tempnextcloud
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check nextcloud_create_database
|
|
|
|
nextcloud_create_database
|
2018-03-01 00:17:49 +01:00
|
|
|
restore_database nextcloud "${NEXTCLOUD_DOMAIN_NAME}"
|
2017-05-08 22:30:19 +02:00
|
|
|
|
|
|
|
temp_restore_dir=/root/tempnextcloudfiles
|
|
|
|
restore_directory_from_usb $temp_restore_dir nextcloudfiles
|
2017-08-25 18:35:33 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" ]; then
|
|
|
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
2017-08-25 18:35:33 +02:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
2017-08-25 18:35:33 +02:00
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
# shellcheck disable=SC2181
|
2017-05-08 22:30:19 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
set_user_permissions
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 346723
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
2017-05-08 22:30:19 +02:00
|
|
|
rm -rf ${temp_restore_dir}
|
|
|
|
|
|
|
|
temp_restore_dir=/root/tempnextcloudconfig
|
|
|
|
restore_directory_from_usb $temp_restore_dir nextcloudconfig
|
2017-08-25 18:35:33 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" ]; then
|
|
|
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
2017-08-25 18:35:33 +02:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/"
|
2017-08-25 18:35:33 +02:00
|
|
|
fi
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
# shellcheck disable=SC2181
|
2017-05-08 22:30:19 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
set_user_permissions
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 3467343
|
|
|
|
fi
|
|
|
|
rm -rf ${temp_restore_dir}
|
2017-05-08 19:50:48 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
|
|
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 14893545875
|
2017-05-08 19:57:41 +02:00
|
|
|
sudo -u www-data ./occ maintenance:repair
|
2017-05-08 19:50:48 +02:00
|
|
|
sudo -u www-data ./occ files:cleanup
|
|
|
|
sudo -u www-data ./occ files:scan --all
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function backup_remote_nextcloud {
|
2018-03-01 00:17:49 +01:00
|
|
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
2017-03-14 22:40:40 +01:00
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
2017-05-08 22:30:19 +02:00
|
|
|
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$temp_backup_dir" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check suspend_site
|
2018-03-01 00:17:49 +01:00
|
|
|
suspend_site "${NEXTCLOUD_DOMAIN_NAME}"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
function_check backup_database_to_friend
|
|
|
|
backup_database_to_friend nextcloud
|
|
|
|
|
|
|
|
function_check backup_directory_to_friend
|
2018-03-01 00:17:49 +01:00
|
|
|
backup_directory_to_friend "$temp_backup_dir" nextclouddata
|
2017-05-08 22:30:19 +02:00
|
|
|
|
|
|
|
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
2018-03-01 00:17:49 +01:00
|
|
|
backup_directory_to_friend "$temp_backup_dir" nextcloudconfig
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
function_check restart_site
|
|
|
|
restart_site
|
|
|
|
else
|
|
|
|
echo $"nextcloud domain specified but not found in ${temp_backup_dir}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function restore_remote_nextcloud {
|
2018-03-01 00:17:49 +01:00
|
|
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
2017-03-14 22:40:40 +01:00
|
|
|
echo $"Restoring nextcloud"
|
|
|
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
|
|
|
|
|
|
|
function_check nextcloud_create_database
|
|
|
|
nextcloud_create_database
|
|
|
|
|
|
|
|
function_check restore_database_from_friend
|
2018-03-01 00:17:49 +01:00
|
|
|
restore_database_from_friend nextcloud "${NEXTCLOUD_DOMAIN_NAME}"
|
2017-03-14 22:40:40 +01:00
|
|
|
if [ -d /root/tempnextcloud ]; then
|
|
|
|
rm -rf /root/tempnextcloud
|
|
|
|
fi
|
2017-05-08 19:50:48 +02:00
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
temp_restore_dir=/root/tempnextcloudfiles
|
|
|
|
restore_directory_from_friend $temp_restore_dir nextcloudfiles
|
2017-08-25 18:35:33 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" ]; then
|
|
|
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
2017-08-25 18:35:33 +02:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
2017-08-25 18:35:33 +02:00
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
# shellcheck disable=SC2181
|
2017-05-08 22:30:19 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 768254
|
|
|
|
fi
|
|
|
|
rm -rf ${temp_restore_dir}
|
|
|
|
|
|
|
|
temp_restore_dir=/root/tempnextcloudconfig
|
|
|
|
restore_directory_from_friend $temp_restore_dir nextcloudconfig
|
2017-08-25 18:35:33 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" ]; then
|
|
|
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
2017-08-25 18:35:33 +02:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/"
|
2017-08-25 18:35:33 +02:00
|
|
|
fi
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
# shellcheck disable=SC2181
|
2017-05-08 22:30:19 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 573427
|
|
|
|
fi
|
|
|
|
rm -rf ${temp_restore_dir}
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
|
|
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 2642846824
|
2017-05-08 19:57:41 +02:00
|
|
|
sudo -u www-data ./occ maintenance:repair
|
2017-05-08 19:50:48 +02:00
|
|
|
sudo -u www-data ./occ files:cleanup
|
|
|
|
sudo -u www-data ./occ files:scan --all
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_nextcloud {
|
|
|
|
if [ ${#NEXTCLOUD_DOMAIN_NAME} -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
function_check remove_nodejs
|
|
|
|
remove_nodejs pleroma-nextcloud
|
|
|
|
|
2017-06-03 13:43:06 +02:00
|
|
|
sed -i 's|env[PATH]|;env[PATH]|g' /etc/php/7.0/fpm/pool.d/www.conf
|
2017-05-08 18:45:26 +02:00
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
read_config_param "NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
read_config_param "MY_USERNAME"
|
|
|
|
echo "Removing $NEXTCLOUD_DOMAIN_NAME"
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_dissite "$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
remove_certs "$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
if [ -d "/var/www/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
|
|
|
rm -rf "/var/www/$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ -f "/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
|
|
|
rm "/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
|
|
|
function_check drop_database
|
|
|
|
drop_database nextcloud
|
|
|
|
function_check remove_onion_service
|
|
|
|
remove_onion_service nextcloud ${NEXTCLOUD_ONION_PORT}
|
|
|
|
remove_app nextcloud
|
|
|
|
remove_completion_param install_nextcloud
|
2018-03-01 00:17:49 +01:00
|
|
|
sed -i '/nextcloud/d' "$COMPLETION_FILE"
|
2017-03-14 22:40:40 +01:00
|
|
|
remove_backup_database_local nextcloud
|
|
|
|
|
|
|
|
function_check remove_ddns_domain
|
2018-03-01 00:17:49 +01:00
|
|
|
remove_ddns_domain "$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 23:09:12 +01:00
|
|
|
systemctl restart nginx
|
2017-06-01 20:05:15 +02:00
|
|
|
systemctl restart php7.0-fpm
|
2017-03-14 22:40:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function install_nextcloud_main {
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
echo $'No domain name was given for nextcloud'
|
|
|
|
exit 7359
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(app_is_installed nextcloud_main) == "1" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check install_mariadb
|
|
|
|
install_mariadb
|
|
|
|
|
|
|
|
function_check get_mariadb_password
|
|
|
|
get_mariadb_password
|
|
|
|
|
|
|
|
function_check repair_databases_script
|
|
|
|
repair_databases_script
|
|
|
|
|
2017-05-29 15:40:34 +02:00
|
|
|
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
|
2017-06-04 10:56:08 +02:00
|
|
|
apt-get -yq install php-intl memcached php-memcached libfcgi0ldbl
|
|
|
|
apt-get -yq install php-zip
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2017-05-08 18:45:26 +02:00
|
|
|
# Ensure PATH is available to php
|
2017-06-03 13:43:06 +02:00
|
|
|
if [ ! -f /etc/php/7.0/fpm/pool.d/www.conf ]; then
|
2017-05-08 18:45:26 +02:00
|
|
|
echo $'No php www configuration file found'
|
|
|
|
exit 628757
|
|
|
|
fi
|
2017-06-03 13:43:06 +02:00
|
|
|
sed -i 's|;env[PATH]|env[PATH]|g' /etc/php/7.0/fpm/pool.d/www.conf
|
2017-05-08 18:45:26 +02:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
|
|
|
mkdir "/var/www/$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" ]; then
|
2017-06-15 13:33:16 +02:00
|
|
|
|
|
|
|
if [ -d /repos/nextcloud ]; then
|
2018-03-01 00:17:49 +01:00
|
|
|
mkdir "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
|
|
|
cp -r -p /repos/nextcloud/. "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
|
|
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 2783539793
|
2017-06-15 13:33:16 +02:00
|
|
|
git pull
|
|
|
|
else
|
|
|
|
function_check git_clone
|
2018-03-01 00:17:49 +01:00
|
|
|
git_clone "$NEXTCLOUD_REPO" "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
2017-06-15 13:33:16 +02:00
|
|
|
fi
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
echo $'Unable to clone nextcloud repo'
|
|
|
|
exit 87525
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 3468346834
|
2017-03-14 22:40:40 +01:00
|
|
|
git submodule update --init
|
|
|
|
git checkout $NEXTCLOUD_COMMIT -b $NEXTCLOUD_COMMIT
|
|
|
|
set_completion_param "nextcloud commit" "$NEXTCLOUD_COMMIT"
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
chmod g+w "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
|
|
|
chown -R www-data:www-data "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
function_check nextcloud_create_database
|
|
|
|
nextcloud_create_database
|
|
|
|
|
|
|
|
if [ ! -f "/etc/aliases" ]; then
|
|
|
|
touch /etc/aliases
|
|
|
|
fi
|
|
|
|
if ! grep -q "www-data: root" /etc/aliases; then
|
|
|
|
echo 'www-data: root' >> /etc/aliases
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check add_ddns_domain
|
2018-03-01 00:17:49 +01:00
|
|
|
add_ddns_domain "$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
nextcloud_nginx_site=/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
|
|
|
if [[ $ONION_ONLY == "no" ]]; then
|
|
|
|
function_check nginx_http_redirect
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_http_redirect "$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
{ echo 'server {';
|
|
|
|
echo ' listen 443 ssl;';
|
|
|
|
echo ' #listen [::]:443 ssl;';
|
|
|
|
echo " server_name $NEXTCLOUD_DOMAIN_NAME;";
|
|
|
|
echo '';
|
|
|
|
echo ' # Security'; } >> "$nextcloud_nginx_site"
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check nginx_ssl
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_ssl "$NEXTCLOUD_DOMAIN_NAME" mobile
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2018-03-05 19:15:29 +01:00
|
|
|
function_check nginx_security_options
|
|
|
|
nginx_security_options "$NEXTCLOUD_DOMAIN_NAME"
|
2018-03-01 00:17:49 +01:00
|
|
|
|
|
|
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
|
|
|
echo '';
|
|
|
|
echo ' # Logs';
|
|
|
|
echo ' access_log /dev/null;';
|
|
|
|
echo ' error_log /dev/null;';
|
|
|
|
echo '';
|
|
|
|
echo ' # Root';
|
|
|
|
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;";
|
|
|
|
echo '';
|
|
|
|
echo ' # Index';
|
|
|
|
echo ' index index.php;';
|
|
|
|
echo '';
|
|
|
|
|
|
|
|
# By default nextcloud advertises highly specific version information
|
|
|
|
# on status.php, which can obviously be used by adversaries.
|
|
|
|
# Blocking status.php prevents this information leak
|
|
|
|
echo ' location = /status.php {';
|
|
|
|
echo ' return 404;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
|
|
|
|
echo ' # PHP';
|
|
|
|
echo ' location ~ \.php {';
|
|
|
|
echo ' include snippets/fastcgi-php.conf;';
|
|
|
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
|
|
|
echo ' fastcgi_read_timeout 30;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Location';
|
|
|
|
echo ' location / {'; } >> "$nextcloud_nginx_site"
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check nginx_limits
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_limits "$NEXTCLOUD_DOMAIN_NAME" '15m'
|
|
|
|
{ echo " try_files \$uri \$uri/ @nextcloud;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Fancy URLs';
|
|
|
|
echo ' location @nextcloud {';
|
|
|
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Restrict access that is unnecessary anyway';
|
|
|
|
echo ' location ~ /\.(ht|git) {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location = /.well-known/carddav {';
|
|
|
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
|
|
|
echo ' }';
|
|
|
|
echo ' location = /.well-known/caldav {';
|
|
|
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location /.well-known/acme-challenge { }';
|
|
|
|
echo '}'; } >> "$nextcloud_nginx_site"
|
2017-03-14 22:40:40 +01:00
|
|
|
else
|
2018-03-01 00:17:49 +01:00
|
|
|
echo -n '' > "$nextcloud_nginx_site"
|
2017-03-14 22:40:40 +01:00
|
|
|
fi
|
2018-03-01 00:17:49 +01:00
|
|
|
{ echo 'server {';
|
|
|
|
echo " listen 127.0.0.1:$NEXTCLOUD_ONION_PORT default_server;";
|
|
|
|
echo " server_name $NEXTCLOUD_DOMAIN_NAME;";
|
|
|
|
echo ''; } >> "$nextcloud_nginx_site"
|
2018-03-05 19:15:29 +01:00
|
|
|
function_check nginx_security_options
|
|
|
|
nginx_security_options "$NEXTCLOUD_DOMAIN_NAME"
|
2018-03-01 00:17:49 +01:00
|
|
|
{ echo '';
|
|
|
|
echo ' # Logs';
|
|
|
|
echo ' access_log /dev/null;';
|
|
|
|
echo ' error_log /dev/null;';
|
|
|
|
echo '';
|
|
|
|
echo ' # Root';
|
|
|
|
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;";
|
|
|
|
echo '';
|
|
|
|
echo ' # Index';
|
|
|
|
echo ' index index.php;';
|
|
|
|
echo '';
|
|
|
|
|
|
|
|
# By default nextcloud advertises highly specific version information
|
|
|
|
# on status.php, which can obviously be used by adversaries.
|
|
|
|
# Blocking status.php prevents this information leak
|
|
|
|
echo ' location = /status.php {';
|
|
|
|
echo ' return 404;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
|
|
|
|
echo ' # PHP';
|
|
|
|
echo ' location ~ \.php {';
|
|
|
|
echo ' include snippets/fastcgi-php.conf;';
|
|
|
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
|
|
|
echo ' fastcgi_read_timeout 30;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Location';
|
|
|
|
echo ' location / {'; } >> "$nextcloud_nginx_site"
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check nginx_limits
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_limits "$NEXTCLOUD_DOMAIN_NAME" '15m'
|
|
|
|
{ echo " try_files \$uri \$uri/ @nextcloud;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Fancy URLs';
|
|
|
|
echo ' location @nextcloud {';
|
|
|
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # Restrict access that is unnecessary anyway';
|
|
|
|
echo ' location ~ /\.(ht|git) {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location = /.well-known/carddav {';
|
|
|
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
|
|
|
echo ' }';
|
|
|
|
echo ' location = /.well-known/caldav {';
|
|
|
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location /.well-known/acme-challenge { }';
|
|
|
|
echo '}'; } >> "$nextcloud_nginx_site"
|
|
|
|
|
|
|
|
sed -i 's| DENY;| SAMEORIGIN;|g' "$nextcloud_nginx_site"
|
2017-05-08 17:38:02 +02:00
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
# NextCloud doesn't like content-security-policy at all
|
2018-03-01 00:17:49 +01:00
|
|
|
sed -i '/Content-Security-Policy/d' "$nextcloud_nginx_site"
|
2017-05-08 22:30:19 +02:00
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
function_check configure_php
|
|
|
|
configure_php
|
|
|
|
|
|
|
|
function_check create_site_certificate
|
2018-03-01 00:17:49 +01:00
|
|
|
create_site_certificate "$NEXTCLOUD_DOMAIN_NAME" 'yes'
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
if [[ "$ONION_ONLY" == "no" ]]; then
|
|
|
|
if [ ! -f "/etc/ssl/certs/${NEXTCLOUD_DOMAIN_NAME}.pem" ]; then
|
2017-05-08 12:27:14 +02:00
|
|
|
echo $'Certificate not generated for nextcloud'
|
|
|
|
exit 725762
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
# Ensure that the database gets backed up locally, if remote
|
|
|
|
# backups are not being used
|
|
|
|
function_check backup_databases_script_header
|
|
|
|
backup_databases_script_header
|
|
|
|
|
|
|
|
function_check backup_database_local
|
|
|
|
backup_database_local nextcloud
|
|
|
|
|
|
|
|
function_check nginx_ensite
|
2018-03-01 00:17:49 +01:00
|
|
|
nginx_ensite "$NEXTCLOUD_DOMAIN_NAME"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
|
|
|
NEXTCLOUD_ONION_HOSTNAME=$(add_onion_service nextcloud 80 ${NEXTCLOUD_ONION_PORT})
|
|
|
|
|
2017-06-01 20:05:15 +02:00
|
|
|
systemctl restart php7.0-fpm
|
2017-03-14 22:40:40 +01:00
|
|
|
systemctl restart nginx
|
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-addemail" -u "$MY_USERNAME" -e "noreply@$NEXTCLOUD_DOMAIN_NAME" -g nextcloud --public no
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a nextcloud -p "$NEXTCLOUD_ADMIN_PASSWORD"
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2018-03-01 00:17:49 +01:00
|
|
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 2467245247
|
2017-06-04 11:09:00 +02:00
|
|
|
if [ -d config ]; then
|
|
|
|
chown -R www-data:www-data config
|
|
|
|
fi
|
|
|
|
if [ -d data ]; then
|
|
|
|
chown -R www-data:www-data data
|
|
|
|
fi
|
|
|
|
|
2017-05-08 17:38:02 +02:00
|
|
|
chmod +x occ
|
2018-03-01 00:17:49 +01:00
|
|
|
./occ maintenance:install --database-name nextcloud --admin-user "${MY_USERNAME}" --admin-pass "${NEXTCLOUD_ADMIN_PASSWORD}" --database mysql --database-user root --database-pass "${MARIADB_PASSWORD}"
|
2017-06-04 11:17:52 +02:00
|
|
|
if [ ! -d data ]; then
|
|
|
|
echo $'Nextcloud data directory was not found. This probably means that the installation failed.'
|
|
|
|
echo ''
|
|
|
|
echo $'Install command was:'
|
|
|
|
echo "./occ maintenance:install --database-name nextcloud --admin-user ${MY_USERNAME} --admin-pass \"${NEXTCLOUD_ADMIN_PASSWORD}\" --database mysql --database-user root --database-pass \"${MARIADB_PASSWORD}\""
|
|
|
|
exit 83522
|
|
|
|
fi
|
2017-06-04 11:09:00 +02:00
|
|
|
chown -R www-data:www-data config
|
|
|
|
chown -R www-data:www-data data
|
2017-11-01 12:11:45 +01:00
|
|
|
sudo -u www-data ./occ check
|
|
|
|
sudo -u www-data ./occ status
|
|
|
|
sudo -u www-data ./occ app:list
|
|
|
|
sudo -u www-data ./occ app:enable encryption
|
2018-03-01 00:17:49 +01:00
|
|
|
if ! sudo -u www-data ./occ encryption:enable; then
|
2017-11-01 11:45:19 +01:00
|
|
|
echo $'Encryption not enabled'
|
|
|
|
exit 73527
|
|
|
|
fi
|
2017-11-01 12:11:45 +01:00
|
|
|
sudo -u www-data ./occ encryption:status
|
|
|
|
sudo -u www-data ./occ config:system:set appstoreenabled --value=false
|
2018-03-01 00:17:49 +01:00
|
|
|
chmod g+w "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php"
|
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
2017-05-08 19:50:48 +02:00
|
|
|
chmod 0644 .htaccess
|
|
|
|
chmod 0750 data
|
2018-03-01 00:17:49 +01:00
|
|
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
|
|
|
sudo -u www-data ./occ config:system:set trusted_domains 1 --value="$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
sudo -u www-data ./occ config:system:set trusted_domains 2 --value="$NEXTCLOUD_ONION_HOSTNAME"
|
2017-05-08 19:50:48 +02:00
|
|
|
sudo -u www-data ./occ files:cleanup
|
|
|
|
sudo -u www-data ./occ files:scan --all
|
2017-05-08 19:57:41 +02:00
|
|
|
sudo -u www-data ./occ maintenance:repair
|
2017-05-12 14:00:31 +02:00
|
|
|
sudo -u www-data ./occ maintenance:mode --off
|
2017-03-14 22:40:40 +01:00
|
|
|
|
2017-06-06 15:26:57 +02:00
|
|
|
systemctl restart mariadb
|
|
|
|
|
2017-05-08 22:30:19 +02:00
|
|
|
# move the data directory
|
2018-03-03 13:36:02 +01:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
mv /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
2018-03-01 00:17:49 +01:00
|
|
|
sed -i "s|'datadirectory'.*|'datadirectory' => '/var/www/$NEXTCLOUD_DOMAIN_NAME/data',|g" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php"
|
2017-05-08 22:30:19 +02:00
|
|
|
|
2017-03-14 22:40:40 +01:00
|
|
|
set_completion_param "nextcloud domain" "$NEXTCLOUD_DOMAIN_NAME"
|
|
|
|
|
|
|
|
install_completed nextcloud_main
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_nextcloud {
|
2018-03-01 00:17:49 +01:00
|
|
|
if [ ! "$ONION_ONLY" ]; then
|
2017-03-14 22:40:40 +01:00
|
|
|
ONION_ONLY='no'
|
|
|
|
fi
|
|
|
|
|
|
|
|
install_nextcloud_main
|
|
|
|
|
|
|
|
APP_INSTALLED=1
|
|
|
|
}
|
|
|
|
|
|
|
|
# NOTE: deliberately there is no "exit 0"
|