Browse Source

fix: minio use ip by default

pull/9162/merge
DarkPhoenix2704 3 months ago committed by Anbarasu
parent
commit
04b34486dc
  1. 39
      docker-compose/setup-script/noco.sh

39
docker-compose/setup-script/noco.sh

@ -56,6 +56,15 @@ print_box_message() {
echo "$edge" echo "$edge"
} }
print_note() {
local note_text="$1"
local note_color='\033[0;33m' # Yellow color
local bold='\033[1m'
local reset='\033[0m'
echo -e "${note_color}${bold}NOTE:${reset} ${note_text}"
}
command_exists() { command -v "$1" >/dev/null 2>&1; } command_exists() { command -v "$1" >/dev/null 2>&1; }
is_valid_domain() { is_valid_domain() {
@ -252,22 +261,37 @@ install_package() {
fi fi
} }
reload_hosts() {
# Flush DNS cache on macOS
if [ "$(uname)" == "Darwin" ]; then
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
# Flush DNS cache on Linux (Debian/Ubuntu)
elif [ -f /etc/debian_version ]; then
sudo systemd-resolve --flush-caches >/dev/null 2>&1 || sudo service network-manager restart >/dev/null 2>&1
# Flush DNS cache on Linux (RHEL/CentOS)
elif [ -f /etc/redhat-release ]; then
sudo systemctl restart NetworkManager >/dev/null 2>&1
fi
}
add_to_hosts() { add_to_hosts() {
local IP="127.0.0.1" local IP="127.0.0.1"
local HOSTS_FILE="/etc/hosts" local HOSTS_FILE="/etc/hosts"
local TEMP_HOSTS_FILE="/tmp/hosts.tmp" local TEMP_HOSTS_FILE="/tmp/hosts.tmp"
if [ "${CONFIG_MINIO_DOMAIN_NAME}" != "minio" ]; then
return 0
fi
if sudo grep -q "${CONFIG_MINIO_DOMAIN_NAME}" "$HOSTS_FILE"; then if is_valid_domain "CONFIG_MINIO_DOMAIN_NAME"; then
return 0
elif sudo grep -q "${CONFIG_MINIO_DOMAIN_NAME}" "$HOSTS_FILE"; then
return 0 return 0
else else
sudo cp "$HOSTS_FILE" "$TEMP_HOSTS_FILE" sudo cp "$HOSTS_FILE" "$TEMP_HOSTS_FILE"
echo "$IP ${CONFIG_MINIO_DOMAIN_NAME}" | sudo tee -a "$TEMP_HOSTS_FILE" > /dev/null echo "$IP ${CONFIG_MINIO_DOMAIN_NAME}" | sudo tee -a "$TEMP_HOSTS_FILE" > /dev/null
if sudo mv "$TEMP_HOSTS_FILE" "$HOSTS_FILE"; then if sudo mv "$TEMP_HOSTS_FILE" "$HOSTS_FILE"; then
print_info "Added ${CONFIG_MINIO_DOMAIN_NAME} to $HOSTS_FILE" print_info "Added ${CONFIG_MINIO_DOMAIN_NAME} to $HOSTS_FILE"
reload_hosts
print_note "You may need to reboot your system"
else else
print_error "Failed to update $HOSTS_FILE. Please check your permissions." print_error "Failed to update $HOSTS_FILE. Please check your permissions."
return 1 return 1
@ -447,7 +471,8 @@ get_advanced_options() {
CONFIG_MINIO_ENABLED=$(confirm "Do you want to enable Minio for file storage?" "Y" && echo "Y" || echo "N" "Y") CONFIG_MINIO_ENABLED=$(confirm "Do you want to enable Minio for file storage?" "Y" && echo "Y" || echo "N" "Y")
if [ "$CONFIG_MINIO_ENABLED" = "Y" ] || [ "$CONFIG_MINIO_ENABLED" = "y" ]; then if [ "$CONFIG_MINIO_ENABLED" = "Y" ] || [ "$CONFIG_MINIO_ENABLED" = "y" ]; then
CONFIG_MINIO_DOMAIN_NAME=$(prompt "Enter the MinIO domain name" "minio")
CONFIG_MINIO_DOMAIN_NAME=$(prompt "Enter the MinIO domain name" "$(get_public_ip)")
if is_valid_domain "$CONFIG_MINIO_DOMAIN_NAME"; then if is_valid_domain "$CONFIG_MINIO_DOMAIN_NAME"; then
if confirm "Do you want to configure SSL for $CONFIG_MINIO_DOMAIN_NAME?"; then if confirm "Do you want to configure SSL for $CONFIG_MINIO_DOMAIN_NAME?"; then
@ -471,7 +496,7 @@ set_default_options() {
CONFIG_EDITION="CE" CONFIG_EDITION="CE"
CONFIG_REDIS_ENABLED="Y" CONFIG_REDIS_ENABLED="Y"
CONFIG_MINIO_ENABLED="Y" CONFIG_MINIO_ENABLED="Y"
CONFIG_MINIO_DOMAIN_NAME="minio" CONFIG_MINIO_DOMAIN_NAME=$(get_public_ip)
CONFIG_MINIO_SSL_ENABLED="N" CONFIG_MINIO_SSL_ENABLED="N"
CONFIG_WATCHTOWER_ENABLED="Y" CONFIG_WATCHTOWER_ENABLED="Y"
CONFIG_NUM_INSTANCES=1 CONFIG_NUM_INSTANCES=1
@ -703,7 +728,7 @@ NC_S3_ACCESS_KEY=${CONFIG_MINIO_ACCESS_KEY}
NC_S3_ACCESS_SECRET=${CONFIG_MINIO_ACCESS_SECRET} NC_S3_ACCESS_SECRET=${CONFIG_MINIO_ACCESS_SECRET}
NC_S3_FORCE_PATH_STYLE=true NC_S3_FORCE_PATH_STYLE=true
EOF EOF
if [ "${CONFIG_MINIO_SSL_ENABLED}" = "Y" ]; then if [ "$CONFIG_MINIO_SSL_ENABLED" = "Y" ]; then
echo "NC_S3_ENDPOINT=https://${CONFIG_MINIO_DOMAIN_NAME}" >> "$env_file" echo "NC_S3_ENDPOINT=https://${CONFIG_MINIO_DOMAIN_NAME}" >> "$env_file"
else else
echo "NC_S3_ENDPOINT=http://${CONFIG_MINIO_DOMAIN_NAME}:9000" >> "$env_file" echo "NC_S3_ENDPOINT=http://${CONFIG_MINIO_DOMAIN_NAME}:9000" >> "$env_file"

Loading…
Cancel
Save