2024-01-30 11:37:53 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# SET ALL CONSTANTS
|
|
|
|
#=================================================
|
|
|
|
|
2020-04-20 15:32:01 +02:00
|
|
|
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
2022-03-13 15:22:35 +01:00
|
|
|
|
|
|
|
# dependencies used by the app
|
2024-01-30 11:36:14 +01:00
|
|
|
#REMOVEME? pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev"
|
2017-11-16 21:10:21 +01:00
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# DEFINE ALL COMMON FONCTIONS
|
|
|
|
#=================================================
|
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
setup_dir() {
|
|
|
|
# Create empty dir for pgadmin
|
|
|
|
mkdir -p /var/lib/pgadmin
|
|
|
|
mkdir -p /var/log/pgadmin
|
2024-01-30 11:36:14 +01:00
|
|
|
mkdir -p $install_dir
|
2017-11-16 21:10:21 +01:00
|
|
|
}
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
install_source() {
|
2024-01-30 11:37:53 +01:00
|
|
|
# # Clean venv is it was on python with an old version in case major upgrade of debian
|
|
|
|
# if [ ! -e $install_dir/lib/python$python_version ]; then
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/bin
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/lib
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/lib64
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/include
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/share
|
|
|
|
# #REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg
|
|
|
|
# fi
|
2020-07-29 22:48:16 +02:00
|
|
|
|
2024-01-30 11:36:14 +01:00
|
|
|
mkdir -p $install_dir
|
|
|
|
chown $app:root -R $install_dir
|
2020-07-29 22:48:16 +02:00
|
|
|
|
2018-05-27 00:53:49 +02:00
|
|
|
if [ -n "$(uname -m | grep arm)" ]
|
|
|
|
then
|
2020-01-26 15:50:06 +01:00
|
|
|
# Clean old file, sometime it could make some big issues if we don't do this !!
|
2024-01-30 11:36:14 +01:00
|
|
|
#REMOVEME? ynh_secure_remove --file=$install_dir/bin
|
|
|
|
#REMOVEME? ynh_secure_remove --file=$install_dir/lib
|
|
|
|
#REMOVEME? ynh_secure_remove --file=$install_dir/include
|
|
|
|
#REMOVEME? ynh_secure_remove --file=$install_dir/share
|
|
|
|
ynh_setup_source --dest_dir $install_dir/ --source_id "armv7_$(lsb_release --codename --short)"
|
2018-05-27 00:53:49 +02:00
|
|
|
else
|
2017-11-16 21:10:21 +01:00
|
|
|
# Install virtualenv if it don't exist
|
2024-01-30 11:38:11 +01:00
|
|
|
test -e $install_dir/bin/python3 || python3 -m venv $install_dir
|
2017-11-16 21:10:21 +01:00
|
|
|
|
|
|
|
# Install pgadmin in virtualenv
|
2021-04-01 22:15:00 +02:00
|
|
|
u_arg='u'
|
|
|
|
set +$u_arg;
|
2024-01-30 11:36:14 +01:00
|
|
|
source $install_dir/bin/activate
|
2021-04-09 21:27:54 +02:00
|
|
|
set -$u_arg;
|
2023-02-20 08:22:24 +01:00
|
|
|
pip3 install --upgrade pip wheel
|
2023-04-28 00:18:20 +02:00
|
|
|
pip3 install -I --upgrade "psycopg[c]"
|
2023-03-10 07:58:06 +01:00
|
|
|
pip3 install --upgrade -r $YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt
|
2021-04-01 22:15:00 +02:00
|
|
|
set +$u_arg;
|
2018-05-27 00:53:49 +02:00
|
|
|
deactivate
|
2021-04-01 22:15:00 +02:00
|
|
|
set -$u_arg;
|
2018-05-27 00:53:49 +02:00
|
|
|
fi
|
2017-11-16 21:10:21 +01:00
|
|
|
}
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
set_permission() {
|
|
|
|
# Set permission
|
2024-01-30 11:36:14 +01:00
|
|
|
chown $app:root -R $install_dir
|
|
|
|
chown $app:root -R /var/lib/pgadmin
|
2022-03-19 12:19:38 +01:00
|
|
|
mkdir -p /var/log/pgadmin
|
2024-01-30 11:36:14 +01:00
|
|
|
chown $app:root -R /var/log/pgadmin
|
|
|
|
chown $app:root /var/log/uwsgi/$app
|
|
|
|
chown $app:root /etc/uwsgi/apps-available/$app.ini
|
2018-01-29 18:48:14 +01:00
|
|
|
chmod u=rwX,g=rX,o= -R /var/lib/pgadmin
|
2017-11-16 21:10:21 +01:00
|
|
|
}
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
config_pgadmin() {
|
2024-01-30 11:36:14 +01:00
|
|
|
cp ../conf/config_local.py $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py
|
|
|
|
ynh_replace_string --match_string __USER__ --replace_string $app --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py
|
|
|
|
ynh_replace_string --match_string __DOMAIN__ --replace_string $domain --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py
|
2017-11-16 21:10:21 +01:00
|
|
|
}
|