From cef22ac5634565cecd2d8545229efe3fe79d85bc Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 17:21:00 +0100 Subject: [PATCH] Add local_settings.py cf #24 --- README.md | 20 +------------------- conf/settings.py | 19 +++++++++++++++++++ scripts/install | 5 +++++ scripts/restore | 3 +++ scripts/upgrade | 3 +++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d6c2620..543651f 100644 --- a/README.md +++ b/README.md @@ -29,33 +29,15 @@ An admin user is created at installation, the login is what you provided at inst You'll need to give Weblate a GitHub user and a token. Please read [GitHub's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). This user will only be used to open the pull-request, each translation keep his author. -**Careful**, You will have to **manually** move your hub binary file from `/var/www/$app/bin/` to `/usr/bin` to enable pull request on GitHub. - **SSH keys**, you will have to go in administration, and generate a public key for Weblate and add github.com so Weblate knows the fingerprint. Please note if your account already have a public key (ssh-rsa), you will have to manually add the Weblate's one to your GitHub account. ## Settings and upgrades Almost everything related to Weblate's configuration is handled in a `settings.py` file. -You will probably edit it to enable or disable diverse features, it is stored in `$final_path/venv/lib/python2.7/site-packages/weblate/settings.py`. - -Unfortunatly, this settings file also gets upgrades for each release. - -This package will: - -* generate a default settings file for your current installation, -* send you a diff with your actual settings (the content will be sent to *root*, and only basic information for weblate's admin), -* generate a default settings file the new weblate's version, that will **replace** your actual `settings.py`. - -You'll have to **manually** add your previous changes to this new `settings.py`. +You can edit the file `$final_path/local_settings.py` to enable or disable features. # Miscellaneous -## Weblate and databases - -Weblate [recommands PostgreSQL](https://docs.weblate.org/en/latest/admin/install.html#database-setup-for-weblate), but YunoHost uses Mysql. - -Carefull, this application install PostgreSQL and change the default configuration to ask for every connexion and every user a password (*local all all password*). - ## LDAP connexion It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP. diff --git a/conf/settings.py b/conf/settings.py index 1d768eb..8f0465a 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -1,4 +1,18 @@ # -*- coding: utf-8 -*- +################################################################################ +################################################################################ +## FOR YUNOHOST USERS ## +################################################################################ +################################################################################ + +# Please do not modify this file, it will be reset at the next update. +# You can edit the file /var/www/weblate/local_settings.py and add/modify the settings you need. +# The parameters you add in local_settings.py will overwrite these, +# but you can use the options and documentation in this file to find out what can be done. + +################################################################################ +################################################################################ + # # Copyright © 2012 - 2020 Michal Čihař # @@ -857,3 +871,8 @@ MATOMO_URL = None GOOGLE_ANALYTICS_ID = None SENTRY_DSN = None AKISMET_API_KEY = None + +try: + from .local_settings import * +except ImportError: + pass diff --git a/scripts/install b/scripts/install index 5d75178..1f99ff8 100755 --- a/scripts/install +++ b/scripts/install @@ -116,6 +116,8 @@ EOF ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 virtualenv --python=python3 "${final_path}/venv" +chown -R "$app": "$final_path" + #run source in a 'sub shell' ( set +o nounset @@ -162,6 +164,9 @@ ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +touch "$final_path/local_settings.py" +ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" + #================================================= # SPECIFIC SETUP Filling up the database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database diff --git a/scripts/restore b/scripts/restore index fa8079b..c890e2e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -54,6 +54,9 @@ ynh_script_progression --message="Restoring the app main directory..." --time -- ynh_restore_file --origin_path="$final_path" +touch "$final_path/local_settings.py" +ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" + #================================================= # RECREATE THE DEDICATED USER #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b969ac4..9c4f2cb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -198,6 +198,9 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$settings" +touch "$final_path/local_settings.py" +ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" + #================================================= # MIGRATE WEBLATE #=================================================