From e875185a31a6c2c1c1a6b3b1aa1c50870b7dfca5 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Fri, 15 Apr 2022 16:30:50 +0200 Subject: [PATCH] Pass $db_name / $db_user to django settings Because they may be different to '__APP__' ! --- conf/settings.py | 4 ++-- scripts/install | 2 ++ scripts/upgrade | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/settings.py b/conf/settings.py index 3ef6223..49bf1f6 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -75,8 +75,8 @@ MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': '__APP__', - 'USER': '__APP__', + 'NAME': '__DB_NAME__', + 'USER': '__DB_USER__', 'PASSWORD': '__DB_PWD__', 'HOST': '127.0.0.1', 'PORT': '5432', # Default Postgres Port diff --git a/scripts/install b/scripts/install index 6f1bdff..82f90c8 100755 --- a/scripts/install +++ b/scripts/install @@ -140,6 +140,8 @@ settings="$final_path/settings.py" cp "../conf/settings.py" "$settings" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$settings" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$settings" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings" diff --git a/scripts/upgrade b/scripts/upgrade index 552b643..5e48a57 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -129,6 +129,8 @@ ynh_backup_if_checksum_is_different --file="$settings" cp "../conf/settings.py" "$settings" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$settings" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$settings" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"