mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
78 lines
2.8 KiB
Bash
78 lines
2.8 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source experimental_helper.sh
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# Postgresql superuser
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Postgresql superuser..." --weight=1
|
|
|
|
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
|
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
|
|
|
install_source
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
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"
|
|
ynh_add_config --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
|
|
ynh_string_random --length=60 > "$data_dir"/master_pwd
|
|
set_permission
|
|
|
|
$install_dir/venv/bin/python3 "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" setup-db
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
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'
|
|
|
|
ynh_use_logrotate --logfile="/var/log/$app"
|
|
set_permission
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|