Adjusting trusted_domains and support multiple ip

This commit is contained in:
philippe lhardy
2025-07-29 13:59:26 +02:00
parent 52703c2313
commit 340c040f1f

View File

@@ -15,10 +15,21 @@ rel_bind_folder=bind_folder
bind_folder=$(pwd)/$rel_bind_folder bind_folder=$(pwd)/$rel_bind_folder
#lazzy detection base on first local ip #lazzy detection base on first local ip
listen_host=$(ip a | grep 192.168.1 |awk '{ gsub("/24","",$2); print $2 ; }') declare -a possible_hosts=($(ip a | grep 192.168.1 |awk '{ gsub("/24","",$2); print $2 ; }'))
hosts_n=${#possible_hosts[@]}
if (( hosts_n > 1 ))
then
log_warn "multiple hosts $hosts_n"
fi
listen_host=${possible_hosts[0]}
log_info "liston on $listen_host"
declare -a podman_args declare -a podman_args
podman_args+=(-p $listen_host:8080:80 --name=$container_name --replace)
host_free_port=8081
log_warn "[TODO] detect free port on $listen_host, use $host_free_port"
podman_args+=(-p $listen_host:$host_free_port:80 --name=$container_name --replace)
# container 33 www-data => current user. # container 33 www-data => current user.
current_uid=$(id -u) current_uid=$(id -u)
@@ -64,7 +75,13 @@ then
podman_args+=(-d) podman_args+=(-d)
fi fi
log_info 'Adjusting trusted_domains in ${bind_folder}/config/config.php'
# assumes a php is installed locally, could be changed to use a podman image or container
sudo cp ${bind_folder}/config/config.php .
php patch_config.php "$listen_host:$host_free_port" | sudo tee ${bind_folder}/config/config.php
echo "run podman with args ${podman_args[@]}" log_info "run podman with args ${podman_args[@]}"
log_info "now you can start a browser on http://$listen_host:$host_free_port"
$defer $podman run "${podman_args[@]}" $nextcloud_image $defer $podman run "${podman_args[@]}" $nextcloud_image