diff --git a/check_process b/check_process index da70422..42b7020 100644 --- a/check_process +++ b/check_process @@ -1,21 +1,19 @@ ;; 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_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash + #upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 port_already_use=0 @@ -23,7 +21,3 @@ ;;; Options Email= Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666& diff --git a/conf/nginx.conf b/conf/nginx.conf index e4af803..20f3b08 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -24,9 +24,6 @@ location __PATH__/assets { # Path to source alias __FINALPATH__/frontend/dist/assets ; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - #client_max_body_size 50M; - try_files $uri $uri/; } @@ -35,9 +32,6 @@ location __PATH__/app { # Path to source alias __FINALPATH__/frontend/dist/app ; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - #client_max_body_size 50M; - try_files $uri $uri/; } diff --git a/manifest.json b/manifest.json index bc7aa48..18de9f2 100644 --- a/manifest.json +++ b/manifest.json @@ -24,9 +24,7 @@ }, "multi_instance": true, "services": [ - "nginx", - "php7.3-fpm", - "mysql" + "nginx" ], "arguments": { "install": [ @@ -34,12 +32,6 @@ "name": "domain", "type": "domain" }, - { - "name": "path", - "type": "path", - "example": "/example", - "default": "/example" - }, { "name": "is_public", "type": "boolean", diff --git a/scripts/backup b/scripts/backup index 2d4981d..b3f2b18 100755 --- a/scripts/backup +++ b/scripts/backup @@ -30,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= @@ -55,25 +54,22 @@ ynh_backup --src_path="$datadir" --is_big #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -"/etc/uwsgi/apps-available/$app-web.ini" -"/etc/uwsgi/apps-available/$app-web.ini" -"/etc/uwsgi/apps-available/$app-web.ini" - #================================================= # SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" - -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="/etc/cron.d/$app" - -ynh_backup --src_path="/etc/$app/" +ynh_backup --src_path="/etc/uwsgi/apps-available/$app-web.ini" +ynh_backup --src_path="/etc/uwsgi/apps-available/$app-webdav.ini" +ynh_backup --src_path="/etc/uwsgi/apps-available/$app-caldav.ini" +ynh_backup --src_path="/etc/supervisor/conf.d/$app.conf" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/change_url b/scripts/change_url index bb9d67a..1895aa0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -17,7 +18,7 @@ old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +new_path="/" app=$YNH_APP_INSTANCE_NAME @@ -30,9 +31,14 @@ ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +language=$(ynh_app_setting_get --app=$app --key=language) +admin=$(ynh_app_setting_get --app=$app --key=admin) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +api_key=$(ynh_app_setting_get --app=$app --key=api_key) +session_secret=$(ynh_app_setting_get --app=$app --key=session_secret) +website_title=$(ynh_app_setting_get --app=$app --key=website_title) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP @@ -75,7 +81,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" #================================================= # MODIFY URL IN NGINX CONF @@ -109,8 +115,20 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... +# UPDATE A CONFIG FILE #================================================= +ynh_script_progression --message="Updating a configuration file..." + +domain=$new_domain +path_url=$new_path + +ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini" +chmod 400 "$final_path/backend/development.ini" +chown $app:$app "$final_path/backend/development.ini" + +ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json" +chmod 400 "$final_path/frontend/configEnv.json" +chown $app:$app "$final_path/frontend/configEnv.json" #================================================= # GENERIC FINALISATION @@ -120,7 +138,8 @@ fi ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 6faf19c..8c3a656 100755 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH +path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE admin=$YNH_APP_ARG_ADMIN @@ -36,6 +36,7 @@ app=$YNH_APP_INSTANCE_NAME api_key=$(ynh_string_random --length=8) session_secret=$(ynh_string_random --length=8) website_title="YunoHost Tracim" +admin_mail=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -146,36 +147,13 @@ chown -R $app:www-data "$datadir" ynh_script_progression --message="Adding a configuration file..." ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini" - chmod 400 "$final_path/backend/development.ini" chown $app:$app "$final_path/backend/development.ini" ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json" - chmod 400 "$final_path/frontend/configEnv.json" chown $app:$app "$final_path/frontend/configEnv.json" -ynh_add_config --template="../conf/web.ini" --destination="/etc/uwsgi/apps-available/$app-web.ini" - -chmod 400 "/etc/uwsgi/apps-available/$app-web.ini" -chown $app:$app "/etc/uwsgi/apps-available/$app-web.ini" - -ln -s /etc/uwsgi/apps-available/$app-web.ini /etc/uwsgi/apps-enabled/$app-web.ini - -ynh_add_config --template="../conf/webdav.ini" --destination="/etc/uwsgi/apps-available/$app-webdav.ini" - -chmod 400 "/etc/uwsgi/apps-available/$app-webdav.ini" -chown $app:$app "/etc/uwsgi/apps-available/$app-webdav.ini" - -ln -s /etc/uwsgi/apps-available/$app-webdav.ini /etc/uwsgi/apps-enabled/$app-webdav.ini - -ynh_add_config --template="../conf/caldav.ini" --destination="/etc/uwsgi/apps-available/$app-caldav.ini" - -chmod 400 "/etc/uwsgi/apps-available/$app-caldav.ini" -chown $app:$app "/etc/uwsgi/apps-available/$app-caldav.ini" - -ln -s /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-caldav.ini - #================================================= # BUILD APP #================================================= @@ -196,6 +174,8 @@ pushd "$final_path/backend" pip install -e "." mkdir sessions_data sessions_lock previews tracimcli db init + tracimcli user create -e $admin_mail -u $admin --lang $language -p $password --profile administrators + tracimcli user delete -l admin@admin.admin set +u; deactivate set -u; @@ -222,9 +202,21 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_supervisor_config --service="$app" --template="supervisord.conf" -#ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" -#ynh_add_uwsgi_service --service="$app-webdav" --template="webdav.ini" -#ynh_add_uwsgi_service --service="$app-caldav" --template="caldav.ini" + +ynh_add_config --template="../conf/web.ini" --destination="/etc/uwsgi/apps-available/$app-web.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-web.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-web.ini" +ln -sf /etc/uwsgi/apps-available/$app-web.ini /etc/uwsgi/apps-enabled/$app-web.ini + +ynh_add_config --template="../conf/webdav.ini" --destination="/etc/uwsgi/apps-available/$app-webdav.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-webdav.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-webdav.ini" +ln -sf /etc/uwsgi/apps-available/$app-webdav.ini /etc/uwsgi/apps-enabled/$app-webdav.ini + +ynh_add_config --template="../conf/caldav.ini" --destination="/etc/uwsgi/apps-available/$app-caldav.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-caldav.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-caldav.ini" +ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-caldav.ini #================================================= # GENERIC FINALIZATION @@ -245,8 +237,6 @@ ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" -#yunohost service add $app-webdav --log="/var/log/uwsgi/$app-webdav/$app-webdav.log" -#yunohost service add $app-caldav --log="/var/log/uwsgi/$app-caldav/$app-caldav.log" #================================================= # START SYSTEMD SERVICE @@ -254,12 +244,9 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" #--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" -#ynh_systemd_action --service_name="uwsgi-app@$app-webdav.service" --action="start" --log_path="/var/log/uwsgi/$app-webdav/$app-webdav.log" #--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" -#ynh_systemd_action --service_name="uwsgi-app@$app-caldav.service" --action="start" --log_path="/var/log/uwsgi/$app-caldav/$app-caldav.log" #--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 87e3427..0f81f72 100755 --- a/scripts/remove +++ b/scripts/remove @@ -54,9 +54,22 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_supervisor_config --service="$app" -#ynh_remove_uwsgi_service --service="$app" -#ynh_remove_uwsgi_service --service="$app-webdav" -#ynh_remove_uwsgi_service --service="$app-caldav" + +ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-web.ini" +ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-web.ini" +ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-webdav.ini" +ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-webdav.ini" +ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-caldav.ini" +ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" + +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate #================================================= # REMOVE THE POSTGRESQL DATABASE @@ -102,16 +115,6 @@ ynh_script_progression --message="Removing dependencies..." ynh_remove_nodejs ynh_remove_app_dependencies -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= @@ -119,24 +122,9 @@ fi #================================================= ynh_script_progression --message="Removing various files..." -# Remove a cron file -ynh_secure_remove --file="/etc/cron.d/$app" - -# Remove a directory securely -ynh_secure_remove --file="/etc/$app" - # Remove the log files ynh_secure_remove --file="/var/log/$app" -ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-web.ini" -ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-web.ini" - -ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-webdav.ini" -ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-webdav.ini" - -ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-caldav.ini" -ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 60bfae0..7a88236 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,7 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -32,7 +33,6 @@ 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_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= @@ -79,6 +79,8 @@ ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p $datadir +mkdir -p $datadir/depot +mkdir -p $datadir/radicale_storage chmod 750 "$datadir" chmod -R o-rwx "$datadir" @@ -106,36 +108,42 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name -#================================================= -# RESTORE VARIOUS FILES -#================================================= -ynh_script_progression --message="Restoring various files..." - -ynh_restore_file --origin_path="/etc/cron.d/$app" - -ynh_restore_file --origin_path="/etc/$app/" - #================================================= # RESTORE SYSTEMD #================================================= ynh_script_progression --message="Restoring the systemd configuration..." -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app-web.ini" +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app-webdav.ini" +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app-caldav.ini" +ynh_restore_file --origin_path="/etc/supervisor/conf.d/$app.conf" + +supervisorctl reread +supervisorctl update + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" +yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +# Start a systemd service +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index f2b3581..a694357 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -22,6 +23,11 @@ language=$(ynh_app_setting_get --app=$app --key=language) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +api_key=$(ynh_app_setting_get --app=$app --key=api_key) +session_secret=$(ynh_app_setting_get --app=$app --key=session_secret) +website_title=$(ynh_app_setting_get --app=$app --key=website_title) #================================================= # CHECK VERSION @@ -52,7 +58,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -66,16 +72,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - #================================================= # CREATE DEDICATED USER #================================================= @@ -93,7 +89,7 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="backend/development.ini frontend/configEnv.json" fi chmod 750 "$final_path" @@ -113,25 +109,63 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" +ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini" +chmod 400 "$final_path/backend/development.ini" +chown $app:$app "$final_path/backend/development.ini" -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +ynh_add_config --template="../conf/configEnv.json.sample" --destination="$final_path/frontend/configEnv.json" +chmod 400 "$final_path/frontend/configEnv.json" +chown $app:$app "$final_path/frontend/configEnv.json" + +#================================================= +# BUILD APP +#================================================= +ynh_script_progression --message="Building app..." + +cp -r $final_path/frontend/dist/assets/branding.sample $final_path/frontend/dist/assets/branding + +pushd "$final_path/backend" + ynh_use_nodejs + ynh_secure_remove --file="$final_path/backend/env" + python3 -m venv env + set +u; + source env/bin/activate + set -u; + pip install -r requirements-build.txt + pip install -r requirements.txt + pip install -r requirements-full-preview-generator.txt + pip install -r requirements-db-postgres.txt + pip install -e "." + mkdir sessions_data sessions_lock previews + set +u; + deactivate + set -u; + $ynh_npm install "i18next-conv@<8" -g + ./update_i18n_json_file.sh || exit 1 +popd + +pushd "$final_path" + echo 'nodeLinker: node-modules' >> .yarnrc.yml + yarn install + ./build_full_frontend.sh +popd + +ynh_install_app_dependencies $pkg_dependencies + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SETUP SYSTEMD @@ -139,23 +173,49 @@ chown $app:$app "$final_path/some_config_file" ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_systemd_config +ynh_add_supervisor_config --service="$app" --template="supervisord.conf" + +ynh_add_config --template="../conf/web.ini" --destination="/etc/uwsgi/apps-available/$app-web.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-web.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-web.ini" +ln -sf /etc/uwsgi/apps-available/$app-web.ini /etc/uwsgi/apps-enabled/$app-web.ini + +ynh_add_config --template="../conf/webdav.ini" --destination="/etc/uwsgi/apps-available/$app-webdav.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-webdav.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-webdav.ini" +ln -sf /etc/uwsgi/apps-available/$app-webdav.ini /etc/uwsgi/apps-enabled/$app-webdav.ini + +ynh_add_config --template="../conf/caldav.ini" --destination="/etc/uwsgi/apps-available/$app-caldav.ini" +chmod 400 "/etc/uwsgi/apps-available/$app-caldav.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app-caldav.ini" +ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-caldav.ini #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" +yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +# Start a systemd service +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" #================================================= # UPGRADE FAIL2BAN