mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Switchs to python3
rebuilds the venv from scratch on upgrade.
This commit is contained in:
parent
d2bd054afc
commit
d738df4875
4 changed files with 26 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql://ihatemoney:MY_MYSQL_PW@localhost/ihatemoney'
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://ihatemoney:MY_MYSQL_PW@localhost/ihatemoney'
|
||||
SQLACHEMY_ECHO = DEBUG
|
||||
SECRET_KEY = "MY_SECRET_KEY"
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ fix_permissions() {
|
|||
|
||||
|
||||
install_apt_dependencies() {
|
||||
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
|
||||
sudo apt-get install -y -qq python3-dev python3-virtualenv supervisor libmysqlclient-dev
|
||||
}
|
||||
|
||||
create_unix_user() {
|
||||
|
@ -58,6 +58,10 @@ create_system_dirs() {
|
|||
sudo mkdir -p /opt/yunohost
|
||||
}
|
||||
|
||||
init_virtualenv () {
|
||||
sudo virtualenv /opt/yunohost/ihatemoney/venv --python /usr/bin/python3
|
||||
}
|
||||
|
||||
### Backported helpers (from testing)
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ create_unix_user
|
|||
fetch_and_extract /opt/yunohost/ihatemoney/src/ ihatemoney
|
||||
|
||||
# Prepare venv
|
||||
sudo virtualenv /opt/yunohost/ihatemoney/venv
|
||||
init_virtualenv
|
||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install -r /opt/yunohost/ihatemoney/src/requirements.txt
|
||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install gunicorn>=19.3.0 MySQL-python
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@ fix_permissions ${INSTALL_DIR}/src-new/
|
|||
|
||||
# Upgrade dependencies
|
||||
sudo ${PIP} install -r ${NEW_REQUIREMENTS}
|
||||
sudo ${PIP} install gunicorn>=19.3.0 MySQL-python
|
||||
|
||||
# Everything went ok ? Let's keep this code.
|
||||
sudo rm -rf ${INSTALL_DIR}/src
|
||||
sudo rm -rf ${INSTALL_DIR}/venv-old
|
||||
sudo mv ${INSTALL_DIR}/src-new ${INSTALL_DIR}/src
|
||||
|
||||
|
||||
|
@ -61,8 +63,23 @@ fi
|
|||
# (ihatemoney now read its conf by default from /etc/ihatemoney/ihatemoney.cfg)
|
||||
sudo rm -f ${INSTALL_DIR}/src/budget/settings.py
|
||||
|
||||
# Settings are not very likely to change, and that script may be
|
||||
# adapted to handle it in case.
|
||||
|
||||
|
||||
# MIGRATION: Optionaly switch to a python3 venv
|
||||
|
||||
if [ ${INSTALL_DIR}/venv/bin/python -ef ${INSTALL_DIR}/venv/bin/python2 ]
|
||||
then
|
||||
install_apt_dependencies
|
||||
# Trash py2 venv
|
||||
sudo mv ${INSTALL_DIR}/venv ${INSTALL_DIR}/venv-old
|
||||
init_virtualenv
|
||||
|
||||
# Clears all cookie-sessions, because py2 & py3 sessions are incompatible
|
||||
# Relates https://github.com/lepture/flask-wtf/issues/279 (fix unreleased)
|
||||
new_secret_key=`openssl rand -base64 32`
|
||||
sudo sed -i "s/SECRET_KEY = \".*\"/SECRET_KEY = \"${new_secret_key}\"/g" /etc/ihatemoney/ihatemoney.cfg
|
||||
fi
|
||||
|
||||
|
||||
# Restart backend
|
||||
sudo supervisorctl restart budget
|
||||
|
|
Loading…
Add table
Reference in a new issue