diff --git a/conf/nginx.conf b/conf/nginx.conf index eb0909d..3fee7fe 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ root __INSTALL_DIR__/static; location /media { - root /home/yunohost.app/__NAME__; + root /home/yunohost.app/__APP__; expires 336h; try_files $uri @proxy_to_app; } @@ -11,7 +11,7 @@ location /static/ { } location /logo { - root /home/yunohost.app/__NAME__; + root /home/yunohost.app/__APP__; try_files $uri @proxy_to_app; } @@ -31,7 +31,7 @@ location /api { } location @proxy_to_app { - proxy_pass http://unix:/run/__NAME__.sock; + proxy_pass http://unix:/run/__APP__.sock; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/manifest.toml b/manifest.toml index 6865c6b..a246075 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ admindoc = "https://gpoddernet.readthedocs.io/" code = "https://github.com/gpodder/mygpo" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false ldap = true @@ -51,6 +52,7 @@ ram.runtime = "100M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.data_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index 12c5b59..8b8f370 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,47 +1,43 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= env_path="$install_dir/envs/prod" -#================================================= -# PERSONAL HELPERS -#================================================= - function set_permissions { chmod 750 "$data_dir" chown -R "$app:$app" "$data_dir" setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx "$data_dir" - chmod 750 "$install_dir" - chown -R "$app:$app" "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir" setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx "$install_dir" setfacl -n -R -m user:www-data:- -m default:user:www-data:- "$install_dir/envs" } function set_up_virtualenv { mkdir -p "$env_path" - ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt" + ynh_config_add --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt" - ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements.txt" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements-setup.txt" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" + ynh_hide_warnings ynh_exec_as_app python3 -m venv "$install_dir/venv" + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements.txt" + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements-setup.txt" + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" } function collect_static { pushd "$install_dir" - chown -R "$app:$app" "$install_dir" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" collectstatic --noinput + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir" + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" collectstatic --noinput popd } function initialize_db { perform_db_migrations - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 } function upgrade_db { @@ -49,14 +45,6 @@ function upgrade_db { } function perform_db_migrations { - yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" makemigrations --merge - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" migrate + yes | ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" makemigrations --merge + ynh_hide_warnings ynh_exec_as_app "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" migrate } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 37e8cfa..4a526f7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,43 +8,40 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="/etc/systemd/system/$app-celery.service" -ynh_backup --src_path="/etc/systemd/system/$app-beat.service" -ynh_backup --src_path="/etc/systemd/system/$app.socket" +ynh_backup "/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app-celery.service" +ynh_backup "/etc/systemd/system/$app-beat.service" +ynh_backup "/etc/systemd/system/$app.socket" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index c2bd411..cb951d0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -10,24 +10,27 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 +ynh_script_progression "Stopping $app's systemd services..." -ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app-celery" --action="stop" + +ynh_systemctl --service="$app-beat" --action="stop" + +ynh_systemctl --service="$app.socket" --action="stop" + +ynh_systemctl --service="$app" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating $app's configuration files..." --weight=1 +ynh_script_progression "Updating $app's configuration files..." mkdir -p "$env_path" echo "$new_domain" > "$env_path/DEFAULT_BASE_URL" @@ -39,15 +42,18 @@ set_permissions #================================================= # START SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 +ynh_script_progression "Starting systemd services..." -ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app.socket" --action="start" + +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-celery" --action="start" + +ynh_systemctl --service="$app-beat" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index e67d8ee..ce18209 100755 --- a/scripts/install +++ b/scripts/install @@ -15,12 +15,12 @@ admin_email=$(ynh_user_get_info --username="$admin" --key="mail") secret_key=$(ynh_string_random --length=64) staff_token=$(ynh_string_random --length=64) -ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key" +ynh_app_setting_set --key="secret_key" --value="$secret_key" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/sources" @@ -28,7 +28,7 @@ ynh_setup_source --dest_dir="$install_dir/sources" #================================================= # APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." mkdir -p "$env_path" @@ -50,20 +50,20 @@ set_permissions #================================================= # SET UP VIRTUALENV #================================================= -ynh_script_progression --message="Initializing Python virtualenv..." --weight=20 +ynh_script_progression "Initializing Python virtualenv..." set_up_virtualenv -ynh_script_progression --message="Collecting static..." +ynh_script_progression "Collecting static..." collect_static #================================================= # INITIALIZE DATABASE #================================================= -ynh_script_progression --message="Initializing database..." +ynh_script_progression "Initializing database..." -ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000;" --database="$db_name" +ynh_psql_db_shell <<< "ALTER ROLE $db_user SET statement_timeout = 5000;" initialize_db @@ -72,18 +72,18 @@ set_permissions #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" -ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service -ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service +ynh_config_add_systemd --service="$app-celery" --template systemd-celery.service +ynh_config_add_systemd --service="$app-beat" --template systemd-beat.service # Some workaround bc ynh_add_system_config doesn't know sockets -ynh_add_systemd_config --service="$app-socket" --template systemd.socket +ynh_config_add_systemd --service="$app-socket" --template systemd.socket systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet @@ -91,16 +91,19 @@ systemctl daemon-reload --quiet #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd services..." --weight=1 +ynh_script_progression "Starting $app's systemd services..." # Start systemd services -ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app.socket" --action="start" + +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-celery" --action="start" + +ynh_systemctl --service="$app-beat" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index c3d569d..ca2f92d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,10 +10,10 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then +if ynh_hide_warnings yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi @@ -23,17 +23,17 @@ systemctl disable "$app.socket" --quiet rm "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet -ynh_remove_systemd_config -ynh_remove_systemd_config -s "$app-celery" -ynh_remove_systemd_config -s "$app-beat" +ynh_config_remove_systemd +ynh_config_remove_systemd -s "$app-celery" +ynh_config_remove_systemd -s "$app-beat" # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." # Remove the log files @@ -41,4 +41,4 @@ ynh_script_progression --message="Removing various files..." # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 45484f9..ac290c5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,16 +11,16 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chmod -R o-rwx "$data_dir" chown -R "$app:www-data" "$data_dir" @@ -28,9 +28,9 @@ chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R "$app:www-data" "$data_dir" @@ -40,21 +40,21 @@ set_permissions #================================================= # RESTORE THE PSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql +ynh_psql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app.socket" +ynh_restore "/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app-celery.service" +ynh_restore "/etc/systemd/system/$app-beat.service" +ynh_restore "/etc/systemd/system/$app.socket" systemctl enable "$app-celery" --quiet systemctl enable "$app-beat" --quiet @@ -65,17 +65,20 @@ yunohost service add "$app" --description="Manage podcast subscriptions, and syn #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app.socket" --action="start" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-celery" --action="start" + +ynh_systemctl --service="$app-beat" --action="start" + +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index a13e7cc..89e48f3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,12 +16,15 @@ admin_email=$(ynh_user_get_info --username="$admin" --key="mail") #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 +ynh_script_progression "Stopping $app's systemd services..." -ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app.socket" --action="stop" + +ynh_systemctl --service="$app" --action="stop" + +ynh_systemctl --service="$app-beat" --action="stop" + +ynh_systemctl --service="$app-celery" --action="stop" systemctl disable "$app.socket" --quiet systemctl disable "$app" --quiet @@ -31,18 +34,18 @@ systemctl disable "$app-celery" --quiet #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." if [ -n "${data_path:-}" ]; then - ynh_app_setting_delete --app="$app" --key=data_path - ynh_app_setting_delete --app="$app" --key=db_pwd - ynh_app_setting_delete --app="$app" --key=admin_email + ynh_app_setting_delete --key=data_path + ynh_app_setting_delete --key=db_pwd + ynh_app_setting_delete --key=admin_email fi if [[ -n "${random_key:-}" ]]; then secret_key="$random_key" - ynh_app_setting_delete --app="$app" --key=random_key - ynh_app_setting_set --app="$app" --key=secret_key --value="$random_key" + ynh_app_setting_delete --key=random_key + ynh_app_setting_set --key=secret_key --value="$random_key" fi if [ -f "$install_dir/requirements.txt" ]; then @@ -55,15 +58,15 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 +ynh_setup_source --dest_dir="$install_dir/sources" --full_replace #================================================= # APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." mkdir -p "$env_path" echo "$admin <$admin_email>" > "$env_path/ADMINS" @@ -83,18 +86,18 @@ set_permissions #================================================= # UPDATE VIRTUALENV #================================================= -ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2 +ynh_script_progression "Upgrading Python virtualenv..." set_up_virtualenv -ynh_script_progression --message="Collecting static..." +ynh_script_progression "Collecting static..." collect_static #================================================= # PERFORM DATABASE MIGRATIONS #================================================= -ynh_script_progression --message="Performing database migrations..." --weight=2 +ynh_script_progression "Performing database migrations..." upgrade_db @@ -103,18 +106,18 @@ set_permissions #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" -ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service -ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service +ynh_config_add_systemd --service="$app-celery" --template systemd-celery.service +ynh_config_add_systemd --service="$app-beat" --template systemd-beat.service # Some workaround bc ynh_add_system_config doesn't know sockets -ynh_add_systemd_config --service="$app-socket" --template systemd.socket +ynh_config_add_systemd --service="$app-socket" --template systemd.socket systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet @@ -122,15 +125,18 @@ systemctl daemon-reload --quiet #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app.socket" --action="start" + +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-celery" --action="start" + +ynh_systemctl --service="$app-beat" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/main-00-gunicorn.conf.py.patch b/sources/patches/main-00-gunicorn.conf.py.patch deleted file mode 100644 index 0ef5f62..0000000 --- a/sources/patches/main-00-gunicorn.conf.py.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/conf/gunicorn.conf.py b/conf/gunicorn.conf.py -index c5940616..28c84d79 100644 ---- a/conf/gunicorn.conf.py -+++ b/conf/gunicorn.conf.py -@@ -1,17 +1,17 @@ - # import multiprocessing - import os - --bind = "unix:/tmp/mygpo.sock" -+#bind = "unix:/tmp/mygpo.sock" - #workers = multiprocessing.cpu_count() - workers = 3 - - # The maximum number of requests a worker will process before restarting. - # max_requests = 1000 - --log_dir = os.getenv("LOGGING_DIR_GUNICRON", "/var/log/gunicorn/") --errorlog = log_dir + "error.log" --accesslog = log_dir + "access.log" --loglevel = "info" -+#log_dir = os.getenv("LOGGING_DIR_GUNICRON", "/var/log/gunicorn/") -+#errorlog = log_dir + "error.log" -+#accesslog = log_dir + "access.log" -+#loglevel = "info" - access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s %(T)s "%(f)s" "%(a)s"' - - timeout = 120 diff --git a/sources/patches/main-01-settings.py.patch b/sources/patches/main-01-settings.py.patch deleted file mode 100644 index 7069138..0000000 --- a/sources/patches/main-01-settings.py.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/mygpo/settings.py b/mygpo/settings.py -index b3927315..f295c326 100644 ---- a/mygpo/settings.py -+++ b/mygpo/settings.py -@@ -2,6 +2,7 @@ import re - import sys - import os.path - import dj_database_url -+import ldap - - - try: -@@ -209,10 +210,15 @@ except ImportError: - ACCOUNT_ACTIVATION_DAYS = int(os.getenv("ACCOUNT_ACTIVATION_DAYS", 7)) - - AUTHENTICATION_BACKENDS = ( -+ "django_auth_ldap.backend.LDAPBackend", - "mygpo.users.backend.CaseInsensitiveModelBackend", - "mygpo.web.auth.EmailAuthenticationBackend", - ) - -+AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=yunohost,dc=org" -+ -+AUTH_LDAP_USER_ATTR_MAP = {"username": "uid", "first_name": "givenName", "email": "mail", "last_name": "sn"} -+ - SESSION_ENGINE = "django.contrib.sessions.backends.cached_db" - - # TODO: use (default) JSON serializer for security - diff --git a/sources/patches/main-02-requirements-setup.txt.patch b/sources/patches/main-02-requirements-setup.txt.patch deleted file mode 100644 index bfa6997..0000000 --- a/sources/patches/main-02-requirements-setup.txt.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/requirements-setup.txt b/requirements-setup.txt -index 18ec5499..8c58b6cc 100644 ---- a/requirements-setup.txt -+++ b/requirements-setup.txt -@@ -1,3 +1,3 @@ - envdir --gevent==21.12.0 -+gevent==23.9.1 - sentry-sdk==1.9.10 -\ No newline at end of file