#!/bin/bash # This script adds cloud.boilerhaus.org to Nextcloud's trusted domains using the occ command # Load environment variables if [ -f .env ]; then source .env else echo "Error: .env file not found. Please create it based on .env.example." exit 1 fi # Check if sshpass is installed if ! command -v sshpass &> /dev/null; then echo "Error: sshpass is not installed. Please run 'sudo apt-get install sshpass' first." exit 1 fi # Set SSH command with password SSH_CMD="sshpass -p $SERVER_PASSWORD ssh -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP" echo "Adding cloud.boilerhaus.org to Nextcloud's trusted domains using occ command..." # Find the Nextcloud directory $SSH_CMD "sudo find /var/www -name occ 2>/dev/null" > nextcloud_occ_path.txt OCC_PATH=$(cat nextcloud_occ_path.txt) if [ -z "$OCC_PATH" ]; then echo "Error: Could not find Nextcloud occ command." echo "Trying alternative approach..." # Try to directly edit the config.php file $SSH_CMD "sudo bash -c 'echo \" /var/www/nextcloud/config/config.php.additional'" $SSH_CMD "sudo bash -c 'cat /var/www/nextcloud/config/config.php.additional >> /var/www/nextcloud/config/config.php'" $SSH_CMD "sudo rm /var/www/nextcloud/config/config.php.additional" else echo "Found Nextcloud occ at: $OCC_PATH" # Get the directory containing occ NEXTCLOUD_DIR=$(dirname "$OCC_PATH") # Use the occ command to add the trusted domain $SSH_CMD "cd $NEXTCLOUD_DIR && sudo -u www-data php occ config:system:set trusted_domains 3 --value=cloud.boilerhaus.org" fi # Restart Apache to apply changes $SSH_CMD "sudo systemctl restart apache2" # Clean up rm -f nextcloud_occ_path.txt echo "Trusted domains configuration updated. You should now be able to access your Nextcloud instance at https://cloud.boilerhaus.org" echo "If you still see the 'untrusted domain' error, try clearing your browser cache or using a private/incognito window."