2017-11-14 16:05:26 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
2017-11-14 16:05:26 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source experimental_helper.sh
|
|
|
|
source _common.sh
|
2017-11-14 16:05:26 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-01-30 15:32:09 +01:00
|
|
|
#=================================================
|
|
|
|
# INITIALIZE AND STORE SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2024-01-31 12:17:37 +01:00
|
|
|
# Used in expect script
|
2024-01-30 13:23:29 +01:00
|
|
|
email=$(ynh_user_get_info --username $admin --key 'mail')
|
|
|
|
|
2024-01-31 14:38:11 +01:00
|
|
|
#=================================================
|
|
|
|
# Postgresql superuser
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring Postgresql superuser..."
|
|
|
|
|
2024-01-31 15:56:14 +01:00
|
|
|
ynh_psql_execute_as_root --sql "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
2024-01-31 14:38:11 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2024-01-30 16:48:42 +01:00
|
|
|
ynh_install_venv
|
2022-03-13 15:22:35 +01:00
|
|
|
|
2024-01-30 16:48:42 +01:00
|
|
|
_install_pgadmin_pip
|
2024-01-31 16:41:58 +01:00
|
|
|
mkdir -p "$install_dir/data"
|
2024-01-30 15:32:09 +01:00
|
|
|
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" "$install_dir"
|
|
|
|
|
2024-01-31 15:31:53 +01:00
|
|
|
mkdir -p /var/log/pgadmin
|
|
|
|
chown -R "$app:root" /var/log/pgadmin
|
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2024-01-30 16:22:11 +01:00
|
|
|
# ADD A CONFIGURATION
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2024-01-31 14:38:11 +01:00
|
|
|
ynh_script_progression --message="Configuring pgAdmin..." --weight=1
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2024-01-30 16:22:11 +01:00
|
|
|
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" "$install_dir"
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2024-01-30 16:22:11 +01:00
|
|
|
ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp"
|
2024-01-30 16:37:46 +01:00
|
|
|
chmod +x "$install_dir/setup.exp"
|
2024-01-31 17:10:33 +01:00
|
|
|
ynh_exec_as "$app" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" setup-db
|
2024-01-31 12:23:49 +01:00
|
|
|
|
|
|
|
ynh_add_config --template="server.json" --destination="$install_dir/server.json"
|
2024-01-31 17:28:18 +01:00
|
|
|
ynh_exec_as "$app" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" load-servers --user "$email" "$install_dir/server.json"
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2024-01-31 15:56:14 +01:00
|
|
|
# looks like we need to run one command as pgadmin to get access to the dbs ?
|
2024-01-31 17:36:47 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" <<< '\list' >/dev/null
|
2024-01-31 15:56:14 +01:00
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
2024-01-30 11:36:14 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
2024-01-30 11:36:14 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2018-01-31 16:08:58 +01:00
|
|
|
|
2024-01-30 16:22:11 +01:00
|
|
|
# Config uwsgi
|
|
|
|
ynh_add_uwsgi_service "python_version"
|
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
ynh_use_logrotate --logfile="/var/log/pgadmin"
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" /var/log/pgadmin
|
2022-03-13 15:22:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
#=================================================
|
2019-06-06 22:39:49 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|