diff --git a/conf/settings.py b/conf/ihatemoney.cfg similarity index 100% rename from conf/settings.py rename to conf/ihatemoney.cfg diff --git a/scripts/_common.sh b/scripts/_common.sh index c370238..061d0b2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ 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/settings.py" +ihatemoney_conf_path="/etc/ihatemoney/ihatemoney.cfg" INSTALL_DIR="/opt/yunohost/ihatemoney" diff --git a/scripts/backup b/scripts/backup index 0a8fb3d..f9cbb36 100644 --- a/scripts/backup +++ b/scripts/backup @@ -32,7 +32,7 @@ mkdir ./conf ynh_backup "$nginx_conf_path" "conf/nginx.conf" ynh_backup "$gunicorn_conf_path" "conf/gunicorn.conf.py" ynh_backup "$supervisor_conf_path" "conf/supervisor.conf" -ynh_backup "$ihatemoney_conf_path" "conf/settings.py" +ynh_backup "$ihatemoney_conf_path" "conf/ihatemoney.cfg" # Dump the database mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql diff --git a/scripts/install b/scripts/install index e4d986f..e5e47e1 100755 --- a/scripts/install +++ b/scripts/install @@ -83,17 +83,14 @@ sudo install -o root -g root -m 644 \ sudo yunohost service add supervisor # 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 -sed -i "s@MY_PATH@$path@" ../conf/settings.py +sed -i "s@MY_SECRET_KEY@$secret_key@" ../conf/ihatemoney.cfg +sed -i "s/MY_EMAIL/$mails_sender/" ../conf/ihatemoney.cfg +sed -i "s@MY_MYSQL_PW@$db_pwd@" ../conf/ihatemoney.cfg +sed -i "s@MY_PATH@$path@" ../conf/ihatemoney.cfg # Remove the conf directive if served at root -sed -i "/APPLICATION_ROOT='\/'/d" ../conf/settings.py +sed -i "/APPLICATION_ROOT='\/'/d" ../conf/ihatemoney.cfg 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 - + ../conf/ihatemoney.cfg /etc/ihatemoney/ihatemoney.cfg # If app is public, add url to SSOWat conf as skipped_uris if [[ "$is_public" -ne 0 ]]; diff --git a/scripts/restore b/scripts/restore index 9a358eb..b66f5c3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -64,7 +64,7 @@ create_system_dirs sudo cp -a "conf/nginx.conf" "$nginx_conf_path" sudo cp -a "conf/gunicorn.conf.py" "$gunicorn_conf_path" sudo cp -a "conf/supervisor.conf" "$supervisor_conf_path" -sudo cp -a "conf/settings.py" "$ihatemoney_conf_path" +sudo cp -a "conf/ihatemoney.cfg" "$ihatemoney_conf_path" # Reload sudo systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 205cd23..501a948 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,8 +46,20 @@ sudo ${PIP} install -r ${NEW_REQUIREMENTS} sudo rm -rf ${INSTALL_DIR}/src sudo mv ${INSTALL_DIR}/src-new ${INSTALL_DIR}/src -# Re-create settings symlink -sudo ln -s /etc/ihatemoney/settings.py ${INSTALL_DIR}/src/budget/settings.py + +## Migration from old versions of the package + + +if [ -e /etc/ihatemoney/settings.py ]; then + # Strip out the no longer used part of the settings + sudo python2 -c"d = open('/etc/ihatemoney/settings.py').read().replace('try:\n from settings import *\nexcept ImportError:\n pass\n', ''); open('/etc/ihatemoney/settings.py', 'w').write(d)" + # Rename + sudo mv /etc/ihatemoney/settings.py ${ihatemoney_conf_path} +fi + +# Remove no longer used symlink +# (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.