1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diacamma_ynh.git synced 2024-09-03 18:26:10 +02:00
diacamma_ynh/scripts/install
2023-12-17 18:45:44 +01:00

79 lines
2.7 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL APP
#=================================================
ynh_script_progression --message="Installing app..." --weight=5
pushd $install_dir
python3 -m venv venv
if [ $develop -eq 1 ]
then
ynh_add_config --template="../conf/extra_url" --destination="./extra_url"
pip_option='--extra-index-url https://pypi.diacamma.org/simple'
else
pip_option=''
fi
venv/bin/pip3 install -U lucterios lucterios-standard lucterios-contacts lucterios-documents $pip_option
venv/bin/pip3 install -U diacamma-asso diacamma-syndic diacamma-financial $pip_option
venv/bin/pip3 install -U gunicorn psycopg2-binary psycopg2 django-auth-ldap3-ad
sed -i 's|member=%s|inheritPermission=%s|g' venv/lib/python*/site-packages/django_auth_ldap3_ad/auth.py
venv/bin/lucterios_admin.py installed
ynh_add_config --template="../conf/extra_diacamma.json" --destination="/tmp/extra.json"
if [ "$path" == "/" ]
then
sed -i "/USE_X_FORWARDED_HOST/d" /tmp/extra.json
sed -i "/FORCE_SCRIPT_NAME/d" /tmp/extra.json
fi
extra_json=$(jq -c . /tmp/extra.json)
venv/bin/lucterios_admin.py add -n inst-${app} -p "${APPLITYPE}" -m "${MODULES}" -d "${DATABASE}" -e ''$extra_json''
popd
if [ ! -z "$archive" ]
then
curl $archive > /tmp/diacamma_archive.lbk
pushd $install_dir
venv/bin/lucterios_admin.py restore -n inst-${app} -f /tmp/diacamma_archive.lbk
popd
fi
refresh_collect
check_params
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to ${app}..."
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config
### `ynh_systemd_config` is used to configure a systemd script for an app, using the conf/systemd.service template
# Create a dedicated sypervisor config
ynh_add_config --template="../conf/supervisor.conf" --destination="/etc/supervisor/conf.d/${app}.conf"
supervisorctl reread
supervisorctl add ${app}
sleep 2
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting app's supervisor service..."
# Start a systemd service
supervisorctl restart ${app}
sleep 2 # Maybe the service needs a few seconds to actually start ...
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of ${app} completed" --last