1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/funkwhale_ynh.git synced 2024-09-03 18:36:24 +02:00

Fix database connection error

This commit is contained in:
yalh76 2019-04-12 01:46:28 +02:00
parent d70e3050ea
commit 10c7da29fc
4 changed files with 8 additions and 10 deletions

View file

@ -81,9 +81,7 @@ ynh_app_setting_set "$app" db_name "$db_name"
ynh_app_setting_set "$app" psqlpwd "$db_pwd"
# Initialize database and store postgres password for upgrade
ynh_psql_create_db "$db_name" "$db_user" "$db_pwd"
systemctl reload postgresql
ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -183,9 +181,9 @@ admin_mail=$(ynh_user_get_info "$admin" "mail")
cd "$final_path/code/"
# needed for enabling the 'unaccent' extension
ynh_psql_execute_as_root "ALTER USER $db_user WITH SUPERUSER;"
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name"
python api/manage.py migrate
ynh_psql_execute_as_root "ALTER USER $db_user WITH NOSUPERUSER;"
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name"
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$admin', '$admin_mail', 'funkwhale') " | python api/manage.py shell
python api/manage.py collectstatic
)

View file

@ -68,7 +68,7 @@ ynh_secure_remove "/etc/systemd/system/$app.target"
ynh_print_info "Removing the PostgreSQL database"
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db "$db_name" "$app"
ynh_psql_remove_db --db_name="$db_name" --db_user="$app"
#=================================================
# REMOVE THE REDIS DATABASE

View file

@ -103,8 +103,8 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#=================================================
# RESTORE USER RIGHTS

View file

@ -206,9 +206,9 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile"
cd "$final_path/code"
# needed for enabling the 'unaccent' extension
ynh_psql_execute_as_root "ALTER USER $db_user WITH SUPERUSER;"
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name"
python api/manage.py migrate
ynh_psql_execute_as_root "ALTER USER $db_user WITH NOSUPERUSER;"
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name"
python api/manage.py collectstatic --clear --noinput