#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers #================================================= # INITIALIZE AND STORE SETTINGS #================================================= email=$(ynh_user_get_info --username $admin --key 'mail') #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." _install_pgadmin_venv setup_dir #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding 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" ynh_script_progression --message="Configuring $app..." ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" #================================================= # Postgresql superuser #================================================= ynh_script_progression --message="Configuring Postgresql superuser..." ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" # Set permission after initialisation ynh_script_progression --message="Protecting directory" set_permission #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Config uwsgi ynh_add_uwsgi_service "python_version" ynh_use_logrotate --logfile="/var/log/pgadmin" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" sleep 10 #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last