#!/usr/bin/env bash config_php='/var/www/html/config/config.php' dbhost="<%= @dbhost %>" mysql_user_password="<%= @mysql_user_password %>" admin_password="<%= @admin_password %>" location="<%= @location %>" bucket="<%= @s3_bucket %>" echo "Input 'IKnowWhatIAmDoing' if you are sure you want to delete everything and reinstall Nextcloud: " read -r user_input if [[ "${user_input}" == "IKnowWhatIAmDoing" ]]; then echo "WARNING: This will delete everything in the database and reinstall Nextcloud." echo "You have 10 seconds to abort by hitting CTRL/C" sleep 10s echo "Ok, proceeding." echo "Dropping database in 3 seconds" sleep 3s /usr/bin/mysql -e "drop database nextcloud" -u nextcloud -p"${mysql_user_password}" -h "${dbhost}" /usr/bin/mysql -e "create database nextcloud" -u nextcloud -p"${mysql_user_password}" -h "${dbhost}" if [[ "x${location}" != "x" || "x${bucket}" != "x" ]]; then bucket_content=$(/usr/bin/rclone ls "${location}":"${bucket}" --config /rclone.conf) if [[ "x${bucket_content}" != "x" ]]; then echo "Deleting all files in ${location}:${bucket} in 3 seconds" sleep 3s /usr/bin/rclone purge "${location}:${bucket}" --config /rclone.conf /usr/bin/rclone mkdir "${location}:${bucket}" --config /rclone.conf fi fi : >${config_php} echo "Running maintenance:install" su - www-data -s /bin/bash <