1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00

Cleanup permissions

This commit is contained in:
Félix Piédallu 2024-01-31 14:52:39 +01:00
parent 39cbd3f07e
commit 66d63af2db
5 changed files with 24 additions and 31 deletions

View file

@ -10,21 +10,6 @@ python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
# DEFINE ALL COMMON FONCTIONS
#=================================================
setup_dir() {
# Create empty dir for pgadmin
mkdir -p /var/lib/pgadmin
mkdir -p /var/log/pgadmin
}
set_permission() {
# Set permission
chown $app:root -R $install_dir
chown $app:root -R /var/lib/pgadmin
mkdir -p /var/log/pgadmin
chown $app:root -R /var/log/pgadmin
chmod u=rwX,g=rX,o= -R /var/lib/pgadmin
}
ynh_install_venv() {
if [ -f "$install_dir/venv/bin/python" ]; then
ynh_exec_as "$app" python3 -m venv "$install_dir/venv" --upgrade

View file

@ -41,6 +41,8 @@ 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
ynh_backup --src_path="/var/log/pgadmin"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -32,7 +32,11 @@ ynh_install_venv
_install_pgadmin_pip
setup_dir
chown -R "$app:root" "$install_dir"
mkdir -p /var/lib/pgadmin
chmod -R 750 /var/lib/pgadmin
chown -R "$app:root" /var/lib/pgadmin
#=================================================
# ADD A CONFIGURATION
@ -40,6 +44,7 @@ setup_dir
ynh_script_progression --message="Configuring pgAdmin..." --weight=1
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
chown -R "$app:root" "$install_dir"
ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp"
chmod +x "$install_dir/setup.exp"
@ -48,10 +53,6 @@ ynh_exec_as "$app" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$in
ynh_add_config --template="server.json" --destination="$install_dir/server.json"
ynh_exec_as "$app" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json"
# Set permission after initialisation
ynh_script_progression --message="Protecting directory"
set_permission
#=================================================
# SYSTEM CONFIGURATION
#=================================================
@ -64,6 +65,7 @@ ynh_add_nginx_config
ynh_add_uwsgi_service "python_version"
ynh_use_logrotate --logfile="/var/log/pgadmin"
chown -R "$app:root" /var/log/pgadmin
#=================================================
# START SYSTEMD SERVICE

View file

@ -25,10 +25,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
### $install_dir will automatically be initialized with some decent
### permissions by default ... however, you may need to recursively reapply
### ownership to all files such as after the ynh_setup_source step
chown -R "$app:www-data" "$install_dir"
chown -R "$app:root" "$install_dir"
#=================================================
# REINSTALL DEPENDENCIES
@ -54,15 +51,18 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/var/lib/pgadmin"
chmod -R 750 /var/lib/pgadmin
chown -R "$app:root" /var/lib/pgadmin
ynh_restore_file --origin_path="/var/log/$app/"
chmod -R 750 /var/log/pgadmin
chown -R "$app:root" /var/log/pgadmin
# Restore systemd configuration
ynh_script_progression --message="Reconfiguring application..."
ynh_restore_uwsgi_service
# Set the permission
ynh_script_progression --message="Protecting directory..."
set_permission
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -48,7 +48,11 @@ ynh_install_venv
_install_pgadmin_pip
setup_dir
chown -R "$app:root" "$install_dir"
mkdir -p /var/lib/pgadmin
chmod -R 750 /var/lib/pgadmin
chown -R "$app:root" /var/lib/pgadmin
#=================================================
# UPDATE A CONFIG FILE
@ -57,8 +61,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
# CONFIGURE PGADMIN
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
set_permission
chown -R "$app:root" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
@ -73,6 +76,7 @@ ynh_add_uwsgi_service "python_version"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
chown -R "$app:root" /var/log/pgadmin
#=================================================
# START SYSTEMD SERVICE