mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
Don't save the password. dump the hashed password on backup.
This commit is contained in:
parent
59bd4bc0ce
commit
c3912a4858
3 changed files with 8 additions and 3 deletions
|
@ -38,6 +38,9 @@ ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
ynh_backup --src_path="/var/lib/pgadmin"
|
ynh_backup --src_path="/var/lib/pgadmin"
|
||||||
|
|
||||||
|
# Backup hashed password
|
||||||
|
ynh_psql_execute_as_root --sql="SELECT rolpassword FROM pg_authid WHERE rolname='$app';" | head -3 | tail -1 > hashed_password.txt
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -44,12 +44,13 @@ chmod +x "$install_dir/setup.exp"
|
||||||
# Postgresql superuser
|
# Postgresql superuser
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Postgresql superuser..."
|
ynh_script_progression --message="Configuring Postgresql superuser..."
|
||||||
ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
# We overwrite the existing db_pwd
|
||||||
|
ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
|
|
||||||
# Add Server In PGadmin database
|
# Add Server In PGadmin database
|
||||||
ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py"
|
ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py"
|
||||||
chmod +x "$install_dir/setup_database.py"
|
chmod +x "$install_dir/setup_database.py"
|
||||||
"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd"
|
"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$password"
|
||||||
|
|
||||||
# Set permission after initialisation
|
# Set permission after initialisation
|
||||||
ynh_script_progression --message="Protecting directory"
|
ynh_script_progression --message="Protecting directory"
|
||||||
|
|
|
@ -27,7 +27,8 @@ chown -R "$app:www-data" "$install_dir"
|
||||||
# RESTORE THE POSTGRESQL SUPERUSER
|
# RESTORE THE POSTGRESQL SUPERUSER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1
|
ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1
|
||||||
ynh_psql_execute_as_root --sql "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
password=$(cat hashed_password.txt)
|
||||||
|
ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
|
|
Loading…
Reference in a new issue