mirror of
https://github.com/nextcloud/vm.git
synced 2025-08-16 16:04:36 +00:00
Trusted domains (#2477)
This commit is contained in:
@ -35,7 +35,11 @@ then
|
||||
fi
|
||||
|
||||
# Set trusted domains
|
||||
run_script NETWORK trusted
|
||||
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
|
||||
|
||||
# Add crontab
|
||||
cat << CRONTAB > "$SCRIPTS/letsencryptrenew.sh"
|
||||
|
@ -1,28 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/
|
||||
|
||||
true
|
||||
SCRIPT_NAME="Trusted"
|
||||
SCRIPT_NAME="Set trusted domain"
|
||||
# shellcheck source=lib.sh
|
||||
source /var/scripts/fetch_lib.sh
|
||||
source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||
|
||||
# Check for errors + debug code and abort if something isn't right
|
||||
# 1 = ON
|
||||
# 0 = OFF
|
||||
DEBUG=0
|
||||
debug_mode
|
||||
# Removed in NC 26.0.0.
|
||||
|
||||
download_script NETWORK update-config
|
||||
if [ -f $SCRIPTS/update-config.php ]
|
||||
then
|
||||
# Change config.php
|
||||
php $SCRIPTS/update-config.php $NCPATH/config/config.php 'trusted_domains[]' localhost "${ADDRESS[@]}" "$(hostname)" "$(hostname --fqdn)" >/dev/null 2>&1
|
||||
php $SCRIPTS/update-config.php $NCPATH/config/config.php overwrite.cli.url https://"$(hostname --fqdn)"/ >/dev/null 2>&1
|
||||
|
||||
# Change .htaccess accordingly
|
||||
sed -i "s|RewriteBase /nextcloud|RewriteBase /|g" $NCPATH/.htaccess
|
||||
|
||||
# Cleanup
|
||||
rm -f $SCRIPTS/update-config.php
|
||||
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)"
|
||||
nextcloud_occ maintenance:update:htaccess
|
||||
|
@ -1,53 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
|
||||
# Credit to: https://github.com/jnweiger
|
||||
|
||||
<?php
|
||||
|
||||
#
|
||||
# Update or delete an entry in config.php.
|
||||
# Called by kiwi's config.sh
|
||||
#
|
||||
if ($argc < 3)
|
||||
{
|
||||
print "Example Usage:\n\t". __FILE__." path/to/config.php overwritewebroot /nextcloud\n";
|
||||
print "\t".__FILE__." path/to/config.php trusted_domains[] 17.0.2.15 localhost\n";
|
||||
# nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!is_file($argv[1]))
|
||||
{
|
||||
# do not create the file, if missing.
|
||||
# Wrong permissions are deadly for nextcloud.
|
||||
## FIXME: get some proper errno or strerror() please?
|
||||
print($argv[1] . ": \$CONFIG cannot be loaded?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
include "$argv[1]";
|
||||
|
||||
if ($argc > 3)
|
||||
{
|
||||
# append [] to the key name, if you need to pass an array object.
|
||||
if (substr($argv[2], -2) === '[]')
|
||||
{
|
||||
$CONFIG[substr($argv[2],0,-2)] = array_slice($argv,3);
|
||||
}
|
||||
else
|
||||
{
|
||||
$CONFIG[$argv[2]] = $argv[3];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# exactly two parameter given -- means delete.
|
||||
unset($CONFIG[$argv[2]]);
|
||||
}
|
||||
|
||||
$text = var_export($CONFIG, true);
|
||||
## A warning is printed, if argv[1] is not writable.
|
||||
## PHP does not issue proper errno or strerror() does it?
|
||||
file_put_contents($argv[1], "<?php\n\$CONFIG = $text;\n");
|
||||
?>
|
@ -553,8 +553,12 @@ mesg n
|
||||
|
||||
ROOTNEWPROFILE
|
||||
|
||||
# Set trusted domain in config.php
|
||||
run_script NETWORK trusted
|
||||
# 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
|
||||
|
||||
# Upgrade system
|
||||
print_text_in_color "$ICyan" "System will now upgrade..."
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
true
|
||||
SCRIPT_NAME="Set trusted domain"
|
||||
# shellcheck source=lib.sh
|
||||
source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||
|
||||
# This is needed since we removed this from the startup script, or changed name so it can't be downloaded anymore
|
||||
msg_box "You are running an outdated release.
|
||||
|
||||
You see this message only to make it possible to run the first startup script, but as time goes, more and more will we incompatible.
|
||||
|
||||
We urge you to download the latest version as soon as possible: https://github.com/nextcloud/vm/releases"
|
Reference in New Issue
Block a user