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

79 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
2024-01-31 14:38:11 +01:00
#=================================================
# Postgresql superuser
#=================================================
2024-01-31 19:46:18 +01:00
ynh_script_progression --message="Configuring Postgresql superuser..." --weight 1
2024-01-31 14:38:11 +01:00
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
ynh_script_progression --message='Creating base directory...'
if [ -n "$(ls -A $data_dir)" ]; then
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path"
mkdir -p $old_data_dir_path
mv -t "$old_data_dir_path" "$data_dir"/*
fi
mkdir -p /var/log/$app
2022-03-13 15:22:35 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-01-30 15:32:09 +01:00
ynh_script_progression --message="Setting up source files..." --weight=5
2024-01-31 14:52:39 +01:00
install_source
2024-01-31 15:31:53 +01:00
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"
ynh_add_config --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
ynh_string_random --length=60 > "$data_dir"/master_pwd
set_permission
2019-06-06 22:39:49 +02:00
$install_dir/venv/bin/python3 "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" setup-db
2024-01-31 15:56:14 +01:00
#=================================================
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
# Add systemd config
ynh_add_systemd_config --service=$app --template=pgadmin.service
yunohost service add $app --log "/var/log/$app/$app.log" --description 'PgAdmin application'
2024-01-30 16:22:11 +01:00
ynh_use_logrotate --logfile="/var/log/$app"
set_permission
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 "$app.service" --action="restart" --line_match "Listening at: unix:/run/$app/app.socket" --log_path systemd
2022-03-13 15:22:35 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Installation of $app completed" --last