2017-06-17 17:28:57 +02:00
|
|
|
### Constants
|
|
|
|
|
|
|
|
supervisor_conf_path="/etc/supervisor/conf.d/ihatemoney.conf"
|
|
|
|
gunicorn_conf_path="/etc/ihatemoney/gunicorn.conf.py"
|
2017-06-21 13:30:48 +02:00
|
|
|
ihatemoney_conf_path="/etc/ihatemoney/ihatemoney.cfg"
|
2017-06-17 17:28:57 +02:00
|
|
|
INSTALL_DIR="/opt/yunohost/ihatemoney"
|
|
|
|
|
|
|
|
|
|
|
|
### Functions
|
|
|
|
|
2017-06-18 17:11:10 +02:00
|
|
|
|
2017-06-19 09:35:17 +02:00
|
|
|
install_apt_dependencies() {
|
2018-07-08 01:28:26 +02:00
|
|
|
ynh_install_app_dependencies \
|
|
|
|
python3-dev \
|
|
|
|
python3-virtualenv \
|
2018-11-25 17:12:44 +01:00
|
|
|
libffi-dev \
|
2018-07-08 01:28:26 +02:00
|
|
|
libssl-dev \
|
|
|
|
supervisor \
|
|
|
|
virtualenv
|
2017-06-19 09:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
create_unix_user() {
|
2020-07-01 17:14:15 +02:00
|
|
|
mkdir -p /opt/yunohost
|
|
|
|
useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home || ynh_die "User creation failed"
|
2017-06-19 09:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
create_system_dirs() {
|
2020-07-01 17:14:15 +02:00
|
|
|
install -o ihatemoney -g ihatemoney -m 755 -d \
|
2017-06-19 09:35:17 +02:00
|
|
|
/var/log/ihatemoney \
|
|
|
|
/etc/ihatemoney
|
2020-07-01 17:14:15 +02:00
|
|
|
mkdir -p /opt/yunohost
|
2017-06-19 09:35:17 +02:00
|
|
|
}
|
|
|
|
|
2018-02-17 00:20:10 +01:00
|
|
|
init_virtualenv () {
|
2020-07-01 17:14:15 +02:00
|
|
|
virtualenv /opt/yunohost/ihatemoney/venv --python /usr/bin/python3
|
2018-12-18 19:23:09 +01:00
|
|
|
|
2018-07-08 01:28:26 +02:00
|
|
|
# PyMySQL → cryptography → setuptools>=18.5
|
|
|
|
# Required on Jessie, Stretch has setuptools>=18.5
|
|
|
|
/opt/yunohost/ihatemoney/venv/bin/pip install 'setuptools>=18.5'
|
2018-02-17 00:20:10 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 08:07:30 +01:00
|
|
|
pip_install () {
|
2021-05-04 11:20:33 +02:00
|
|
|
# SQLAlchemy requirement is workaround https://github.com/pallets/flask-sqlalchemy/issues/910
|
|
|
|
# Might be removed later when IHM dependency set will no longer prevent working installation.
|
2020-07-01 17:14:15 +02:00
|
|
|
/opt/yunohost/ihatemoney/venv/bin/pip install --upgrade \
|
2018-12-20 08:07:30 +01:00
|
|
|
'gunicorn>=19.3.0' \
|
|
|
|
'PyMySQL>=0.9,<0.10' \
|
2019-03-19 12:05:43 +01:00
|
|
|
'ihatemoney>=4,<5' \
|
2021-05-04 11:20:33 +02:00
|
|
|
'SQLAlchemy<1.4' \
|
2018-12-20 08:07:30 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:24:15 +02:00
|
|
|
configure_nginx () {
|
|
|
|
local domain=$1
|
|
|
|
local path=$2
|
2018-12-18 18:24:07 +01:00
|
|
|
local python_version="$(readlink /usr/bin/python3|sed s/.*python//)"
|
|
|
|
|
2020-07-01 17:14:15 +02:00
|
|
|
ynh_replace_string "PATHTOCHANGE" "$path" ../conf/nginx.conf
|
|
|
|
ynh_replace_string "PYTHON_VERSION" "$python_version" ../conf/nginx.conf
|
2018-06-24 01:24:15 +02:00
|
|
|
# Fix double-slash for domain-root install
|
2020-07-01 17:14:15 +02:00
|
|
|
ynh_replace_string "location //" "location /" ../conf/nginx.conf
|
|
|
|
install -o root -g root -m644 \
|
2018-06-24 01:24:15 +02:00
|
|
|
../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ihatemoney.conf
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_supervisor () {
|
2020-07-01 17:14:15 +02:00
|
|
|
install -o root -g root -m 644 \
|
2018-06-24 01:24:15 +02:00
|
|
|
../conf/supervisord.conf /etc/supervisor/conf.d/ihatemoney.conf
|
|
|
|
}
|