From 1d133781713317481e4d30ac2e76fb793911b0fa Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Wed, 9 Dec 2020 12:05:24 +0100 Subject: [PATCH] Use own urls.py to support $YNH_APP_ARG_PATH --- README.md | 6 ++++-- conf/ynh_pyinventory_settings.py | 4 ++++ conf/ynh_urls.py | 6 ++++++ manifest.json | 12 +++++++++++- scripts/_common.sh | 4 ++-- scripts/install | 6 ++++++ scripts/upgrade | 6 ++++++ 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 conf/ynh_urls.py diff --git a/README.md b/README.md index 6719244..e4b4976 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ drwxr-xr-x 6 pyinventory pyinventory 6 Dec 8 08:37 venv root@yunohost:~# cd /opt/yunohost/pyinventory/ root@yunohost:/opt/yunohost/pyinventory# source venv/bin/activate (venv) root@yunohost:/opt/yunohost/pyinventory# ./manage.py check -PyInventory v0.8.1rc1 (Django v2.2.17) +PyInventory v0.8.1rc2 (Django v2.2.17) DJANGO_SETTINGS_MODULE='ynh_pyinventory_settings' PROJECT_PATH:/opt/yunohost/pyinventory/venv/lib/python3.7/site-packages BASE_PATH:/opt/yunohost/pyinventory @@ -99,5 +99,7 @@ System check identified no issues (0 silenced). root@yunohost:~# tail -f /var/log/pyinventory/pyinventory.log root@yunohost:~# cat /etc/systemd/system/pyinventory.service -root@yunohost:~# ynh_systemd_action --service_name="pyinventory" --action="restart" + +root@yunohost:~# systemctl reload-or-restart pyinventory +root@yunohost:~# journalctl --unit=pyinventory --follow ``` \ No newline at end of file diff --git a/conf/ynh_pyinventory_settings.py b/conf/ynh_pyinventory_settings.py index dfab0db..c3728b0 100644 --- a/conf/ynh_pyinventory_settings.py +++ b/conf/ynh_pyinventory_settings.py @@ -28,6 +28,10 @@ assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}' # ----------------------------------------------------------------------------- +ROOT_URLCONF = 'ynh_urls' # /opt/yunohost/pyinventory/ynh_urls.py + +# ----------------------------------------------------------------------------- + ADMINS = ( ('__ADMIN__', '__ADMINMAIL__'), ) diff --git a/conf/ynh_urls.py b/conf/ynh_urls.py new file mode 100644 index 0000000..6b6fd78 --- /dev/null +++ b/conf/ynh_urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import include +from django.urls import path + +urlpatterns = [ + path('__PATH_URL__/', include('inventory_project.urls')) +] \ No newline at end of file diff --git a/manifest.json b/manifest.json index a081c8a..0035b61 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Web based management to catalog things including state and location etc." }, - "version": "0.8.1rc1~ynh2", + "version": "0.8.1rc2~ynh1", "url": "https://github.com/jedie/PyInventory", "license": "GPL-3.0", "maintainer": { @@ -31,6 +31,16 @@ }, "example": "domain.org" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for PyInventory", + "fr": "Choisissez un chemin pour PyInventory" + }, + "example": "/pyinventory", + "default": "/pyinventory" + }, { "name": "admin", "type": "user", diff --git a/scripts/_common.sh b/scripts/_common.sh index 8db757c..bf76472 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url="/" +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -28,7 +28,7 @@ pkg_dependencies="build-essential python3-dev python3-pip python3-virtualenv vir postgresql postgresql-contrib" # PyInventory's version for PIP and settings file -pyinventory_version="0.8.1rc1" +pyinventory_version="0.8.1rc2" #================================================= diff --git a/scripts/install b/scripts/install index c4b20fa..80f17d2 100755 --- a/scripts/install +++ b/scripts/install @@ -125,6 +125,7 @@ cp "../conf/gunicorn.conf.py" "$gunicorn_conf" ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$gunicorn_conf" ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$gunicorn_conf" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$gunicorn_conf" +ynh_store_file_checksum --file="$gunicorn_conf" cp ../conf/manage.py "$final_path/manage.py" chmod +x "$final_path/manage.py" @@ -151,6 +152,11 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" touch "$final_path/local_settings.py" +ynh_urls="$final_path/ynh_urls.py" +cp "../conf/ynh_urls.py" "$ynh_urls" +ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$ynh_urls" +ynh_store_file_checksum --file="$ynh_urls" + #================================================= # MIGRATE / COLLECTSTATIC / CREATEADMIN #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8c27a58..296e375 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,6 +140,12 @@ ynh_store_file_checksum --file="$settings" touch "$final_path/local_settings.py" +ynh_urls="$final_path/ynh_urls.py" +ynh_backup_if_checksum_is_different --file="$ynh_urls" +cp "../conf/ynh_urls.py" "$ynh_urls" +ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$ynh_urls" +ynh_store_file_checksum --file="$ynh_urls" + #================================================= # MIGRATE PYINVENTORY #=================================================