mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Work in progress : installation is working but upstream app lacks url prefix support
This commit is contained in:
parent
3192681226
commit
14c1789a26
6 changed files with 156 additions and 0 deletions
7
conf/gunicorn.conf.py
Normal file
7
conf/gunicorn.conf.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
backlog = 2048
|
||||
daemon = False
|
||||
debug = True
|
||||
workers = 3
|
||||
logfile = "/var/log/ihatemoney/budget.gunicorn.log"
|
||||
loglevel = "info"
|
||||
bind = "unix:/var/run/ihatemoney/budget.gunicorn.sock"
|
19
conf/nginx.conf
Normal file
19
conf/nginx.conf
Normal file
|
@ -0,0 +1,19 @@
|
|||
location PATHTOCHANGE/static/ {
|
||||
alias /path/to/app/budget/static/;
|
||||
}
|
||||
location PATHTOCHANGE/ {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 180;
|
||||
proxy_read_timeout 180;
|
||||
proxy_buffer_size 16k;
|
||||
proxy_buffers 8 16k;
|
||||
proxy_busy_buffers_size 32k;
|
||||
proxy_intercept_errors on;
|
||||
if (!-f $request_filename) {
|
||||
proxy_pass http://unix:/var/run/ihatemoney/budget.gunicorn.sock;
|
||||
break;
|
||||
}
|
||||
}
|
11
conf/settings.py
Normal file
11
conf/settings.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql://ihatemoney:MY_MYSQL_PW@localhost/ihatemoney'
|
||||
SQLACHEMY_ECHO = DEBUG
|
||||
SECRET_KEY = "MY_SECRET_KEY"
|
||||
|
||||
DEFAULT_MAIL_SENDER = ("Budget manager", "MY_EMAIL")
|
||||
|
||||
try:
|
||||
from settings import *
|
||||
except ImportError:
|
||||
pass
|
7
conf/supervisord.conf
Normal file
7
conf/supervisord.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
[program:budget]
|
||||
command=/opt/yunohost/ihatemoney/venv/bin/gunicorn -c /etc/ihatemoney/gunicorn.conf.py run:app
|
||||
directory=/opt/yunohost/ihatemoney/src/budget
|
||||
user=ihatemoney
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=True
|
36
manifest.json
Normal file
36
manifest.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "I Hate Money",
|
||||
"id": "ihatemoney",
|
||||
"description": {
|
||||
"en": "A simple shared budget manager web application",
|
||||
"fr": "Une application web de comptes partagés à plusieurs"
|
||||
},
|
||||
"licence": "BSD custom beerware",
|
||||
"developer": {
|
||||
"name": "Jocelyn Delalande",
|
||||
"email": "jocelyn@crapouillou.net",
|
||||
"url": "http://jocelyn.delalande.fr"
|
||||
},
|
||||
"multi_instance": "false",
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for ihatemoney",
|
||||
"fr": "Choisir un domaine pour ihatemoney"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for ihatemoney",
|
||||
"fr": "Choisir un chemin pour ihatemoney"
|
||||
},
|
||||
"example": "/example",
|
||||
"default": "/ihatemoney"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
76
scripts/install
Normal file
76
scripts/install
Normal file
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
# Constants
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
|
||||
# Constant arguments
|
||||
db_user=ihatemoney
|
||||
secret_key=`openssl rand -base64 32`
|
||||
mails_sender="no-reply@${domain}"
|
||||
|
||||
sudo yunohost app checkurl $domain$path -a ihatemoney
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
|
||||
# Install debian packages dependencies
|
||||
sudo apt-get install -y -qq python-virtualenv supervisor
|
||||
|
||||
# Create the dedicated user
|
||||
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/
|
||||
|
||||
# Prepare venv
|
||||
sudo virtualenv /opt/yunohost/ihatemoney/venv
|
||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install -r ../sources/budget/requirements.txt
|
||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install gunicorn>=19.3.0
|
||||
|
||||
|
||||
# Install source
|
||||
sudo cp -r ../sources/ /opt/yunohost/ihatemoney/src/
|
||||
sudo find /opt/yunohost/ihatemoney/src/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||
sudo find /opt/yunohost/ihatemoney/src/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||
sudo chown -R ihatemoney:ihatemoney /opt/yunohost/ihatemoney/src
|
||||
|
||||
|
||||
# Create various dirs
|
||||
sudo install -o ihatemoney -g ihatemoney -m 755 \
|
||||
-d /var/log/ihatemoney /etc/ihatemoney /var/run/ihatemoney/
|
||||
|
||||
# Configure supervisor
|
||||
sudo install -o root -g root -m 644 \
|
||||
../conf/supervisord.conf /etc/supervisor/conf.d/ihatemoney.conf
|
||||
sudo service supervisor restart
|
||||
sudo yunohost service add supervisor
|
||||
|
||||
# Configure gunicorn
|
||||
sudo install -o ihatemoney -g ihatemoney -m 644 \
|
||||
../conf/gunicorn.conf.py /etc/ihatemoney/gunicorn.conf.py
|
||||
|
||||
# Configure database
|
||||
db_pwd=`sudo yunohost app initdb $db_user`
|
||||
sudo yunohost app setting ihatemoney mysqlpwd -v $db_pwd
|
||||
|
||||
# Configure ihatemoney
|
||||
sed -i "s/MY_SECRET_KEY/$secret_key/" ../conf/settings.py
|
||||
sed -i "s/MY_EMAIL/$mails_sender/" ../conf/settings.py
|
||||
sed -i "s/MY_MYSQL_PW/$db_pwd/" ../conf/settings.py
|
||||
sudo install -o ihatemoney -g ihatemoney -m 640 \
|
||||
../conf/settings.py /etc/ihatemoney/settings.py
|
||||
# The settings have to be stored here (on python path)
|
||||
sudo ln -s /etc/ihatemoney/settings.py /opt/yunohost/ihatemoney/src/budget/settings.py
|
||||
|
||||
# Reconfigure sso
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
# Configure Nginx and reload
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||
sudo install -o root -g root -m644 \
|
||||
../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ihatemoney.conf
|
||||
sudo service nginx reload
|
||||
echo $?
|
Loading…
Add table
Reference in a new issue