diff --git a/LICENSE b/LICENSE index 7d1e40b..2fbf60f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,21 @@ -File containing the license of your package. +MIT License -More information here: -https://yunohost.org/packaging_apps_guidelines#yep-1-3 +Copyright (c) 2022 YunoHost-Apps + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 06579aa..1d22369 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ a public page. **Shipped version:** 1.3.3~ynh1 + **Demo:** https://app.tandoor.dev/accounts/login/?demo ## Screenshots @@ -54,19 +55,6 @@ a public page. ## Disclaimers / important information -* Any known limitations, constrains or stuff not working, such as (but not limited to): - * requiring a full dedicated domain ? - * architectures not supported ? - * not-working single-sign on or LDAP integration ? - * the app requires an important amount of RAM / disk / .. to install or to work properly - * etc... - -* Other infos that people should be aware of, such as: - * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) - * how to configure / administrate the application if it ain't obvious - * upgrade process / specificities / things to be aware of ? - * security considerations ? - * Known limitations: * Requires a full dedicated domain for now diff --git a/README_fr.md b/README_fr.md index 69bf7a0..9637611 100644 --- a/README_fr.md +++ b/README_fr.md @@ -44,7 +44,8 @@ a public page. - 📥️ **Import your collection** from many other [recipe managers](https://docs.tandoor.dev/features/import_export/) - ➕ Many more like recipe scaling, image compression, printing views and supermarkets -**Version incluse :** 1.3.3~ynh1 +**Version incluse :** 1.3.3~ynh1 + **Démo :** https://app.tandoor.dev/accounts/login/?demo @@ -54,19 +55,6 @@ a public page. ## Avertissements / informations importantes -* Any known limitations, constrains or stuff not working, such as (but not limited to): - * requiring a full dedicated domain ? - * architectures not supported ? - * not-working single-sign on or LDAP integration ? - * the app requires an important amount of RAM / disk / .. to install or to work properly - * etc... - -* Other infos that people should be aware of, such as: - * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) - * how to configure / administrate the application if it ain't obvious - * upgrade process / specificities / things to be aware of ? - * security considerations ? - * Known limitations: * Requires a full dedicated domain for now diff --git a/check_process b/check_process index f41c4c9..6cd9557 100644 --- a/check_process +++ b/check_process @@ -1,30 +1,20 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" - path="/path" is_public=1 - language="fr" - admin="john" - password="1Strong-Password" port="666" ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Options Email= Notification=none diff --git a/conf/systemd.service b/conf/systemd.service index 92202ee..fd3ab1d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=gunicorn daemon for recipes +Description=Tandoor, smart recipe mangement After=network.target [Service] @@ -7,10 +7,12 @@ Type=simple Restart=always RestartSec=3 User=__APP__ -Group=www-data +Group=__APP__ WorkingDirectory=__FINALPATH__ EnvironmentFile=__FINALPATH__/.env -ExecStart=__FINALPATH__/venv/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind 127.0.0.1:__PORT__ recipes.wsgi:application +ExecStart=__FINALPATH__/venv/bin/gunicorn --bind 127.0.0.1:__PORT__ recipes.wsgi:application +Restart=on-failure +RestartSec=10 [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index baa5263..421957b 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,16 +1,3 @@ -* Any known limitations, constrains or stuff not working, such as (but not limited to): - * requiring a full dedicated domain ? - * architectures not supported ? - * not-working single-sign on or LDAP integration ? - * the app requires an important amount of RAM / disk / .. to install or to work properly - * etc... - -* Other infos that people should be aware of, such as: - * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) - * how to configure / administrate the application if it ain't obvious - * upgrade process / specificities / things to be aware of ? - * security considerations ? - * Known limitations: * Requires a full dedicated domain for now diff --git a/manifest.json b/manifest.json index d84967b..9fc40c4 100644 --- a/manifest.json +++ b/manifest.json @@ -16,7 +16,7 @@ "userdoc": "https://docs.tandoor.dev", "code": "https://github.com/TandoorRecipes/recipes" }, - "license": "free", + "license": "MIT", "maintainer": { "name": "Navan Chauhan", "email": "tandoor@navan.email" @@ -37,7 +37,10 @@ { "name": "is_public", "type": "boolean", - "default": true + "default": false, + "help": { + "en": "Should the login be exposed to public?" + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 01f8228..81163c5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,14 +5,99 @@ #================================================= # dependencies used by the app (must be on a single line) -pkg_dependencies="git curl python3 python3-pip python3-venv libpq-dev postgresql libsasl2-dev python3-dev libldap2-dev libssl-dev" +pkg_dependencies="git curl python3 python3-pip python3-venv libpq-dev postgresql libsasl2-dev python3-dev libldap2-dev libssl-dev libffi-dev autoconf build-essential" nodejs_version=16 +py_required_version=3.9.2 #================================================= # PERSONAL HELPERS #================================================= +# Install specific python version +# usage: myynh_install_python --python="3.8.6" +# | arg: -p, --python= - the python version to install +myynh_install_python () { + # Declare an array to define the options of this helper. + local legacy_args=u + local -A args_array=( [p]=python= ) + local python + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + # Check python version from APT + local py_apt_version=$(python3 --version | cut -d ' ' -f 2) + + # Check existing built version of python in /usr/local/bin + if [ -e "/usr/local/bin/python${python:0:3}" ] + then + local py_built_version=$(/usr/local/bin/python${python:0:3} --version \ + | cut -d ' ' -f 2) + else + local py_built_version=0 + fi + + # Compare version + if $(dpkg --compare-versions $py_apt_version ge $python) + then + # APT >= Required + ynh_print_info --message="Using provided python3..." + + py_app_version="python3" + + else + # Either python already built or to build + if $(dpkg --compare-versions $py_built_version ge $python) + then + # Built >= Required + ynh_print_info --message="Using already used python3 built version..." + + py_app_version="/usr/local/bin/python${py_built_version:0:3}" + + else + ynh_print_info --message="Installing additional dependencies to build python..." + + pkg_dependencies="${pkg_dependencies} tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libbz2-dev libexpat1-dev liblzma-dev wget tar" + ynh_install_app_dependencies "${pkg_dependencies}" + + # APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin + ynh_print_info --message="Building python (may take a while)..." + + # Store current direcotry + local MY_DIR=$(pwd) + + # Create a temp direcotry + tmpdir="$(mktemp --directory)" + cd "$tmpdir" + + # Download + wget --output-document="Python-$python.tar.xz" \ + "https://www.python.org/ftp/python/$python/Python-$python.tar.xz" 2>&1 + + # Extract + tar xf "Python-$python.tar.xz" + + # Install + cd "Python-$python" + ./configure --enable-optimizations + ynh_exec_warn_less make -j4 + ynh_exec_warn_less make altinstall + + # Go back to working directory + cd "$MY_DIR" + + # Clean + ynh_secure_remove "$tmpdir" + + # Set version + py_app_version="/usr/local/bin/python${python:0:3}" + fi + fi + # Save python version in settings + ynh_app_setting_set --app=$app --key=python --value="$python" +} + + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index b167f73..b8e7c4c 100755 --- a/scripts/install +++ b/scripts/install @@ -94,6 +94,7 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_psql_execute_as_root --sql="GRANT ALL PRIVILEGES ON DATABASE $db_user TO $db_user;" @@ -136,21 +137,27 @@ chown $app:$app "$final_path/.env" #================================================= ynh_script_progression --message="Setting up Tandoor venv..." --weight=1 -ynh_exec_as $app python3 -m venv "$final_path/venv" +if [[ $(ynh_get_debian_release) == "bullseye" ]]; then + py_app_version="python3" +else + myynh_install_python --python="$py_required_version" +fi + +ynh_exec_as $app $py_app_version -m venv "$final_path/venv" ynh_script_progression --message="Installing dependencies via pip..." --weight=4 pushd "$final_path" - ynh_exec_as $app "$final_path/venv/bin/pip3" install -r requirements.txt + ynh_exec_warn_less ynh_exec_as $app "$final_path/venv/bin/pip3" install -r requirements.txt popd ynh_script_progression --message="Building frontend..." --weight=5 pushd "$final_path/vue" ynh_use_nodejs - yarn install - yarn build + ynh_exec_warn_less yarn install + ynh_exec_warn_less yarn build popd -ynh_script_progression --message="Running migrations and generatic static files..." --weight=2 +ynh_script_progression --message="Running migrations and generating static files..." --weight=2 pushd "$final_path" # load environment variables export $(cat "/var/www/$app/.env" |grep "^[^#]" | xargs) @@ -182,7 +189,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Smart recuoe management" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Smart recipe management" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index dc4a283..5f2ef60 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,12 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) db_user=$db_name #================================================= @@ -92,6 +95,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql @@ -115,7 +119,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Smart recipe management" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 0b7f6b8..52d3ab8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,9 +17,12 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) #================================================= # CHECK VERSION @@ -104,14 +107,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config - #================================================= # NGINX CONFIGURATION #================================================= @@ -130,8 +125,8 @@ ynh_add_config --template=".env.template" --destination="$final_path/.env" # FIXME: this should be handled by the core in the future # You may need to use chmod 600 instead of 400, # for example if the app is expected to be able to modify its own config -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" #================================================= # SPECIFIC UPGRADE @@ -140,11 +135,10 @@ chown $app:$app "$final_path/some_config_file" if [ "$upgrade_type" == "UPGRADE_APP" ] then - # load environment variables - export $(cat "/var/www/$app/.env" |grep "^[^#]" | xargs) - ynh_script_progression --message="Running migrations and generatic static files..." --weight=2 pushd "$final_path" + # load environment variables + export $(cat "/var/www/$app/.env" |grep "^[^#]" | xargs) ynh_exec_as $app "$final_path/venv/bin/python3" manage.py migrate ynh_exec_as $app "$final_path/venv/bin/python3" manage.py collectstatic --no-input ynh_exec_as $app "$final_path/venv/bin/python3" manage.py collectstatic_js_reverse @@ -181,7 +175,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Smart recipe management" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE