1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00
ihatemoney_ynh/scripts/_common.sh

70 lines
2 KiB
Bash
Raw Normal View History

2017-06-17 17:28:57 +02:00
### Constants
nginx_conf_path="/etc/nginx/conf.d/${domain}.d/ihatemoney.conf"
supervisor_conf_path="/etc/supervisor/conf.d/ihatemoney.conf"
gunicorn_conf_path="/etc/ihatemoney/gunicorn.conf.py"
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
install_apt_dependencies() {
ynh_install_app_dependencies \
python3-dev \
python3-virtualenv \
2018-11-25 17:12:44 +01:00
libffi-dev \
libssl-dev \
supervisor \
virtualenv
}
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"
}
create_system_dirs() {
2020-07-01 17:14:15 +02:00
install -o ihatemoney -g ihatemoney -m 755 -d \
/var/log/ihatemoney \
/etc/ihatemoney
2020-07-01 17:14:15 +02:00
mkdir -p /opt/yunohost
}
init_virtualenv () {
2020-07-01 17:14:15 +02:00
virtualenv /opt/yunohost/ihatemoney/venv --python /usr/bin/python3
# PyMySQL → cryptography → setuptools>=18.5
# Required on Jessie, Stretch has setuptools>=18.5
/opt/yunohost/ihatemoney/venv/bin/pip install 'setuptools>=18.5'
}
pip_install () {
2020-04-02 16:52:45 +02:00
# Werkzeug stuff is workaround https://github.com/spiral-project/ihatemoney/issues/540
2020-07-01 17:14:15 +02:00
/opt/yunohost/ihatemoney/venv/bin/pip install --upgrade \
'gunicorn>=19.3.0' \
'PyMySQL>=0.9,<0.10' \
2019-03-19 12:05:43 +01:00
'ihatemoney>=4,<5' \
2020-04-02 16:52:45 +02:00
'Werkzeug==0.16' \
}
configure_nginx () {
local domain=$1
local path=$2
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
# 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 \
../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 \
../conf/supervisord.conf /etc/supervisor/conf.d/ihatemoney.conf
}