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

86 lines
2.8 KiB
Text
Raw Normal View History

2017-11-14 16:05:26 +01:00
#!/bin/bash
#=================================================
# 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
2022-03-13 15:22:35 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
2017-11-14 16:05:26 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Installing sources files..." --weight=10
2017-11-16 21:10:21 +01:00
setup_dir
install_source
2022-03-13 15:22:35 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
# ...
#=================================================
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Configuring application..."
2017-11-16 21:10:21 +01:00
# CONFIGURE PGADMIN
config_pgadmin
# Config uwsgi
2024-01-30 11:36:14 +01:00
ynh_add_uwsgi_service
2017-11-14 16:05:26 +01:00
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Configuring sqlite database..."
2017-11-16 21:10:21 +01:00
# initialisation sqlite database for pgadmin
chmod +x ../conf/setup.exp
2020-07-29 23:14:43 +02:00
set +u;
2024-01-30 11:36:14 +01:00
source $install_dir/bin/activate
2020-07-29 23:14:43 +02:00
set -u;
2019-06-06 22:39:49 +02:00
ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$admin_pwd" --target_file "../conf/setup.exp"
2024-01-30 11:36:14 +01:00
../conf/setup.exp "$install_dir/bin/python3" "$install_dir/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email"
2017-11-14 16:05:26 +01:00
# POPULATE THE DATABASE
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Configuring Postgresql database..."
2024-01-30 11:36:14 +01:00
#REMOVEME? ynh_psql_test_if_first_run
2019-06-06 22:39:49 +02:00
ynh_psql_execute_as_root \
--sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Add Server In PGadmin database
2024-01-30 11:36:14 +01:00
$install_dir/bin/python3 config_database.py "$db_user" "$db_pwd"
2020-07-29 23:14:43 +02:00
set +u;
2017-11-16 21:10:21 +01:00
deactivate
2020-07-29 23:14:43 +02:00
set -u;
2017-11-14 16:05:26 +01:00
2022-03-13 15:22:35 +01:00
# Set permission after initialisation
ynh_script_progression --message="Protecting directory"
set_permission
#=================================================
2024-01-30 11:36:14 +01:00
# SYSTEM CONFIGURATION
#=================================================
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
2022-03-13 15:22:35 +01:00
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
#=================================================
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Installation of $app completed" --last