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/_common.sh
2020-02-24 23:24:30 +01:00

65 lines
2.5 KiB
Bash

#=================================================
# SET ALL CONSTANTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app
pgadmin_user="pgadmin"
python_version="3.5"
dependances="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev"
if [[ -e "../settings/manifest.json" ]] || [[ -e "../manifest.json" ]]; then
APP_VERSION=$(ynh_app_upstream_version)
app_main_version=$(echo $APP_VERSION | cut -d'-' -f1)
app_sub_version=$(echo $APP_VERSION | cut -d'-' -f2)
fi
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
setup_dir() {
# Create empty dir for pgadmin
mkdir -p /var/lib/pgadmin
mkdir -p /var/log/pgadmin
mkdir -p $final_path
}
install_source() {
if [ -n "$(uname -m | grep arm)" ]
then
# Clean old file, sometime it could make some big issues if we don't do this !!
ynh_secure_remove --file=$final_path/bin
ynh_secure_remove --file=$final_path/lib
ynh_secure_remove --file=$final_path/include
ynh_secure_remove --file=$final_path/share
ynh_setup_source --dest_dir $final_path/ --source_id "armv7_stretch"
else
# Install virtualenv if it don't exist
test -e $final_path/bin/python3 || python3 -m venv $final_path
# Install pgadmin in virtualenv
PS1=""
cp ../conf/virtualenv_activate $final_path/bin/activate
source $final_path/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade 'Werkzeug<1.0'
pip3 install --upgrade https://ftp.postgresql.org/pub/pgadmin/pgadmin$app_main_version/v$app_sub_version/pip/pgadmin${APP_VERSION}-py2.py3-none-any.whl
deactivate
fi
}
set_permission() {
# Set permission
chown $pgadmin_user:root -R $final_path
chown $pgadmin_user:root -R /var/lib/pgadmin
chown $pgadmin_user:root -R /var/log/pgadmin
chown $pgadmin_user:root /var/log/uwsgi/$app
chmod u=rwX,g=rX,o= -R /var/lib/pgadmin
}
config_pgadmin() {
cp ../conf/config_local.py $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
ynh_replace_string --match_string __USER__ --replace_string $pgadmin_user --target_file $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
ynh_replace_string --match_string __DOMAIN__ --replace_string $domain --target_file $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
}