Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script for trusted domains #2482

Merged
merged 6 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lets-encrypt/test-new-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ then
sed -i "s|env\[HOSTNAME\] = .*|env[HOSTNAME] = $(hostname -f)|g" "$PHP_POOL_DIR"/nextcloud.conf
fi

# Set trusted domains
nextcloud_occ config:system:set trusted_domains 0 --value="localhost"
nextcloud_occ config:system:set trusted_domains 1 --value="$ADDRESS"
nextcloud_occ config:system:set trusted_domains 2 --value="$(hostname -f)"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$(hostname --fqdn)"
# Set the domain as trusted
add_to_trusted_domains "$1"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$1"
nextcloud_occ maintenance:update:htaccess

# Add crontab
Expand Down
6 changes: 1 addition & 5 deletions nextcloud-startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,7 @@ mesg n
ROOTNEWPROFILE

# Set trusted domains
nextcloud_occ config:system:set trusted_domains 0 --value="localhost"
nextcloud_occ config:system:set trusted_domains 1 --value="$ADDRESS"
nextcloud_occ config:system:set trusted_domains 2 --value="$(hostname -f)"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$(hostname --fqdn)"
nextcloud_occ maintenance:update:htaccess
run_script STATIC trusted_domains

# Upgrade system
print_text_in_color "$ICyan" "System will now upgrade..."
Expand Down
36 changes: 36 additions & 0 deletions static/trusted_domains.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
true
SCRIPT_NAME="Set trusted domain"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh

# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode

# Set trusted domains default
if [ -n "$ADDRESS" ]
then
nextcloud_occ config:system:set trusted_domains 0 --value="localhost"
nextcloud_occ config:system:set trusted_domains 1 --value="$ADDRESS"
nextcloud_occ config:system:set trusted_domains 2 --value="$(hostname)"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$(hostname --fqdn)"
# Also set WAN address if it exists
if [ -n "$WANIP4" ]
then
nextcloud_occ config:system:set trusted_domains 3 --value="$WANIP4"
fi
else
nextcloud_occ config:system:set trusted_domains 0 --value="localhost"
nextcloud_occ config:system:set trusted_domains 1 --value="$(hostname)"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$(hostname --fqdn)"
# Also set WAN address if it exists
if [ -n "$WANIP4" ]
then
nextcloud_occ config:system:set trusted_domains 2 --value="$WANIP4"
fi
fi