From d1719a2a2f72ece2cc3669430fe9f2b0ed264bad Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 15 Apr 2020 16:10:47 +0200 Subject: [PATCH 1/3] Fix hub on restore/upgrade --- scripts/restore | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 2fa8132..a347460 100755 --- a/scripts/restore +++ b/scripts/restore @@ -59,7 +59,7 @@ ynh_restore_file "$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create "$app" "/home/$app" +ynh_system_user_create "$app" "$final_path" # Allow bash for our user, so he can use hub chsh --shell /bin/bash "$app" diff --git a/scripts/upgrade b/scripts/upgrade index cc50c78..d6efa77 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,7 +140,7 @@ ynh_install_app_dependencies "$pkg_dependencies" ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 # Create a system user -ynh_system_user_create "$app" "/home/$app" +ynh_system_user_create "$app" "$final_path" chsh --shell /bin/bash "$app" #================================================= From 15c2d22385fa44037fa230cc6657ba282c263178 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Fri, 1 May 2020 22:09:37 +0200 Subject: [PATCH 2/3] use variable for python path for buster weblate uses Django, which requires to edit a configuration file in the filepath replace the string value by a varible --- conf/settings_history/settings.3.2.2.py | 2 +- conf/settings_history/settings.3.3.py | 2 +- conf/settings_history/settings.3.4.py | 2 +- conf/settings_history/settings.3.5.1.py | 2 +- conf/settings_history/settings.3.5.py | 2 +- conf/settings_history/settings.3.6.1.py | 2 +- conf/settings_history/settings.3.7.py | 2 +- conf/settings_history/settings.3.8.py | 2 +- conf/uwsgi.ini | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 10 ++++++++++ scripts/change_url | 2 +- scripts/install | 10 ++++++---- scripts/upgrade | 12 +++++++----- 14 files changed, 35 insertions(+), 21 deletions(-) diff --git a/conf/settings_history/settings.3.2.2.py b/conf/settings_history/settings.3.2.2.py index ffbe881..67dd6bc 100644 --- a/conf/settings_history/settings.3.2.2.py +++ b/conf/settings_history/settings.3.2.2.py @@ -56,7 +56,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.3.py b/conf/settings_history/settings.3.3.py index 3f69df4..4683a5b 100644 --- a/conf/settings_history/settings.3.3.py +++ b/conf/settings_history/settings.3.3.py @@ -56,7 +56,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.4.py b/conf/settings_history/settings.3.4.py index 6edec99..30e4d44 100644 --- a/conf/settings_history/settings.3.4.py +++ b/conf/settings_history/settings.3.4.py @@ -56,7 +56,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.5.1.py b/conf/settings_history/settings.3.5.1.py index 00fd17f..ca6f682 100644 --- a/conf/settings_history/settings.3.5.1.py +++ b/conf/settings_history/settings.3.5.1.py @@ -59,7 +59,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.5.py b/conf/settings_history/settings.3.5.py index 00fd17f..ca6f682 100644 --- a/conf/settings_history/settings.3.5.py +++ b/conf/settings_history/settings.3.5.py @@ -59,7 +59,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.6.1.py b/conf/settings_history/settings.3.6.1.py index ff77791..b231714 100644 --- a/conf/settings_history/settings.3.6.1.py +++ b/conf/settings_history/settings.3.6.1.py @@ -66,7 +66,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.7.py b/conf/settings_history/settings.3.7.py index 83343d6..cfe7067 100644 --- a/conf/settings_history/settings.3.7.py +++ b/conf/settings_history/settings.3.7.py @@ -67,7 +67,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/settings_history/settings.3.8.py b/conf/settings_history/settings.3.8.py index 19c6901..cf43ac2 100644 --- a/conf/settings_history/settings.3.8.py +++ b/conf/settings_history/settings.3.8.py @@ -68,7 +68,7 @@ BASE_DIR = '__FINALPATH__' # Data directory DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/python3.5/site-packages/weblate/ttf/' +TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index 33549a3..ca9a11f 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -6,7 +6,7 @@ socket = /var/run/__APP__/socket virtualenv = __FINALPATH__/venv # http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info -mount = __PATH__=__FINALPATH__/venv/lib/python3.5/site-packages/weblate/wsgi.py +mount = __PATH__=__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/wsgi.py # Needed for OAuth/OpenID buffer-size = 8192 @@ -23,4 +23,4 @@ close-on-exec = true # Do not log some errors caused by client disconnects ignore-sigpipe = true ignore-write-errors = true -disable-write-exception = true \ No newline at end of file +disable-write-exception = true diff --git a/manifest.json b/manifest.json index 0a8693f..7f842ea 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "description": { "en": "A translation platform using Git and Python" }, - "version": "3.8.0~ynh1", + "version": "3.8.0~ynh2", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index c8f2733..dc56bb5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,6 +15,15 @@ pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev \ # Weblate's version for PIP and settings file current_version="3.8" + +debian_maj_version=$(sed 's/\..*//' /etc/debian_version) + +if [ "$debian_maj_version" -eq 9 ] ; then + weblate_pypath="python3.5" +elif [ "$debian_maj_version" -eq 10 ] ; then + weblate_pypath="python3.7" +fi + #================================================= # PERSONAL HELPERS #================================================= @@ -31,6 +40,7 @@ weblate_fill_settings() { ynh_replace_string "__FINALPATH__" "$final_path" "$settings" ynh_replace_string "__GITHUBUSER__" "$github_account" "$settings" ynh_replace_string "__REDIS_DB__" "$redis_db" "$settings" + ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$settings" # root install as an empty PATHURL to prevent '//static' if [ "$path_url" == "/" ] diff --git a/scripts/change_url b/scripts/change_url index 40996aa..e93dee2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -85,7 +85,7 @@ fi #================================================= # Edit specific content from nginx configuration #================================================= -settings="$final_path/venv/lib/python3.5/site-packages/weblate/settings.py" +settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" if [ "$old_path" == "/" ] && [ "$new_path" != "/" ] then diff --git a/scripts/install b/scripts/install index 98bd281..0aad39b 100755 --- a/scripts/install +++ b/scripts/install @@ -207,7 +207,7 @@ admin_mail=$(ynh_user_get_info "$admin" mail) key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2) redis_db=$(ynh_redis_get_free_db) -settings="$final_path/venv/lib/python3.5/site-packages/weblate/settings.py" +settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" cp "../conf/settings_history/settings.$current_version.py" "$settings" weblate_fill_settings "$settings" @@ -259,9 +259,11 @@ ynh_script_progression --message="Configure uwsgi..." --time --weight=1 finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" -ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" -ynh_replace_string "__APP__" "$app" "$finaluwsgiini" +ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" +ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" +ynh_replace_string "__APP__" "$app" "$finaluwsgiini" +ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini" + # root install doesn't require uwsgi to handle script names diff --git a/scripts/upgrade b/scripts/upgrade index cc50c78..1430346 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -151,9 +151,11 @@ ynh_script_progression --message="Configure uwsgi..." --time --weight=1 finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" -ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" -ynh_replace_string "__APP__" "$app" "$finaluwsgiini" +ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" +ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" +ynh_replace_string "__APP__" "$app" "$finaluwsgiini" +ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini" + # root install doesn't require uwsgi to handle script names @@ -190,7 +192,7 @@ ynh_script_progression --message="Install weblate using PIP..." --time --weight= #================================================= ynh_script_progression --message="Create weblate configuration file..." --time --weight=1 # save old settings file -settings="$final_path/venv/lib/python3.5/site-packages/weblate/settings.py" +settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" old_settings="$final_path/settings.$previous_version.old.py" @@ -272,7 +274,7 @@ ynh_script_progression --message="Run migration scripts..." --time --weight=1 ) # Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/venv/lib/python3.5/site-packages/weblate/settings.py" +ynh_store_file_checksum "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" #================================================= # SETUP CRON From da23f491023f15c0fee9ec6fad156c60d3272936 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Fri, 1 May 2020 22:55:31 +0200 Subject: [PATCH 3/3] remove useless content follow package linter requests --- check_process | 13 +--------- manifest.json | 2 +- scripts/_common.sh | 65 ---------------------------------------------- scripts/backup | 22 ++++++++-------- scripts/change_url | 16 ++++++------ scripts/install | 36 ++++++++++++------------- scripts/remove | 22 ++++++++-------- scripts/restore | 22 ++++++++-------- scripts/upgrade | 36 ++++++++++++------------- 9 files changed, 79 insertions(+), 155 deletions(-) diff --git a/check_process b/check_process index 33788ce..9cde86a 100644 --- a/check_process +++ b/check_process @@ -24,22 +24,11 @@ upgrade=1 from_commit=31b82950959699478f2372259116b6d117a85d69 backup_restore=1 multi_instance=1 - incorrect_path=1 port_already_use=0 change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: https://github.com/YunoHost-Apps/weblate_ynh/issues/4 - Level 4=1 -# Level 5: + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email=jean-baptiste@holcroft.fr Notification=all diff --git a/manifest.json b/manifest.json index 7f842ea..b237c41 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "description": { "en": "A translation platform using Git and Python" }, - "version": "3.8.0~ynh2", + "version": "3.8.0~ynh3", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index dc56bb5..74bff58 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -175,69 +175,4 @@ ynh_redis_remove_db() { # EXPERIMENTAL HELPERS #================================================= -# Print a message as INFO and show progression during an app script -# -# usage: ynh_script_progression --message=message [--weight=weight] [--time] -# | arg: -m, --message= - The text to print -# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script. -# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights. -# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar. -increment_progression=0 -previous_weight=0 -ynh_script_progression () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last ) - local message - local weight - local time - local last - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - weight=${weight:-1} - time=${time:-0} - last=${last:-0} - - # Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented. - local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)" - # Get the number of call with a weight value - local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0) - - # Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight - local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')" - # Get the weight of each occurrences of 'ynh_script_progression' in the script using -w - local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')" - # Each value will be on a different line. - # Remove each 'end of line' and replace it by a '+' to sum the values. - local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 )) - - # max_progression is a total number of calls to this helper. - # Less the number of calls with a weight value. - # Plus the total of weight values - local max_progression=$(( $helper_calls - $weight_calls + $weight_values )) - - # Increment each execution of ynh_script_progression in this script by the weight of the previous call. - increment_progression=$(( $increment_progression + $previous_weight )) - # Store the weight of the current call in $previous_weight for next call - previous_weight=$weight - - # Set the scale of the progression bar - local scale=20 - # progress_string(1,2) should have the size of the scale. - local progress_string1="####################" - local progress_string0="...................." - - # Reduce $increment_progression to the size of the scale - if [ $last -eq 0 ] - then - local effective_progression=$(( $increment_progression * $scale / $max_progression )) - # If last is specified, fill immediately the progression_bar - else - local effective_progression=$scale - fi - - # Build $progression_bar from progress_string(1,2) according to $effective_progression - local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}" - - ynh_print_info "[$progression_bar] > ${message}" -} diff --git a/scripts/backup b/scripts/backup index 3f407e7..11bb4d9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ ynh_abort_if_errors # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,7 +29,7 @@ db_name=$(ynh_app_setting_get "$app" db_name) # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --time --weight=1 +ynh_script_progression --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -38,7 +38,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 +ynh_script_progression --message="Backing up the main app directory..." ynh_backup "$final_path" @@ -46,7 +46,7 @@ ynh_backup "$final_path" # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -54,7 +54,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Backing up the PostgreSQL database..." ynh_psql_dump_db "$db_name" > db.sql ynh_backup "db.sql" @@ -64,7 +64,7 @@ ynh_backup "db.sql" #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Backing up logrotate configuration..." ynh_backup --src_path="/etc/logrotate.d/$app" @@ -72,7 +72,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1 +ynh_script_progression --message="Backing up systemd configuration..." ynh_backup "/etc/cron.d/$app" @@ -80,7 +80,7 @@ ynh_backup "/etc/cron.d/$app" # BACKUP THE uwsgi files #================================================= -ynh_script_progression --message="Backing up uwsgi configuration..." --time --weight=1 +ynh_script_progression --message="Backing up uwsgi configuration..." ynh_backup "/etc/uwsgi/apps-available/$app.ini" ynh_backup "/etc/systemd/system/$app.service" @@ -96,7 +96,7 @@ ynh_backup "/etc/systemd/system/$app-celery.service" # BACKUP THE hub binary file #================================================= -ynh_script_progression --message="Backing up uwsgi configuration..." --time --weight=1 +ynh_script_progression --message="Backing up uwsgi configuration..." ynh_backup /usr/bin/hub @@ -104,7 +104,7 @@ ynh_backup /usr/bin/hub # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --time --weight=1 +ynh_script_progression --message="Starting systemd services..." ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -113,4 +113,4 @@ ynh_systemd_action --service_name="$app-celery" --action="start" # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url index e93dee2..0edad8c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get "$app" final_path) is_public=$(ynh_app_setting_get "$app" is_public) @@ -51,7 +51,7 @@ fi # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --time --weight=1 +ynh_script_progression --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -62,7 +62,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf" finalnginxconf=$nginx_conf_path @@ -109,7 +109,7 @@ ynh_store_file_checksum "$finalnginxconf" #================================================= # MODIFY settings.py #================================================= -ynh_script_progression --message="Modify weblate's config file..." --time --weight=1 +ynh_script_progression --message="Modify weblate's config file..." # Change the path in the nginx config file if [ $change_path -eq 1 ] @@ -142,7 +142,7 @@ ynh_store_file_checksum "$settings" #================================================= # ChangeSite inside weblate #================================================= -ynh_script_progression --message="Run weblate's command changesite..." --time --weight=1 +ynh_script_progression --message="Run weblate's command changesite..." ( set +eu source "${final_path}/venv/bin/activate" @@ -155,7 +155,7 @@ ynh_script_progression --message="Run weblate's command changesite..." --time -- #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --time --weight=1 +ynh_script_progression --message="Starting systemd services..." ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -163,7 +163,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -171,4 +171,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 0aad39b..1993684 100755 --- a/scripts/install +++ b/scripts/install @@ -42,7 +42,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." # Register (book) web path ynh_webpath_register "$app" "$domain" "$path_url" @@ -56,7 +56,7 @@ mkdir -p "$final_path" # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path_url" @@ -74,14 +74,14 @@ ynh_app_setting_set "$app" github_token "$github_token" # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." db_name=$(ynh_sanitize_dbid "$app") ynh_app_setting_set "$app" db_name "$db_name" @@ -97,7 +97,7 @@ ynh_systemd_action --service_name=postgresql --action=reload # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -117,7 +117,7 @@ fi # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." # Hub needs a home directory with a config file ynh_system_user_create "$app" "$final_path" @@ -128,7 +128,7 @@ chsh --shell /bin/bash "$app" # Download and install hub #================================================= -ynh_script_progression --message="Download and install hub..." --time --weight=1 +ynh_script_progression --message="Download and install hub..." arch=$(dpkg --print-architecture) # Rasberry Pi: Debian armhf (ARM hard float) refers to the ARMv7 @@ -177,7 +177,7 @@ EOF # PIP INSTALLATION #================================================= -ynh_script_progression --message="Install weblate using PIP..." --time --weight=10 +ynh_script_progression --message="Install weblate using PIP..." --weight=10 virtualenv --python=python3 "${final_path}/venv" #run source in a 'sub shell' @@ -200,7 +200,7 @@ virtualenv --python=python3 "${final_path}/venv" # TODO: use --extra-search-dir=/path/to/dists #================================================= -ynh_script_progression --message="Create weblate configuration file..." --time --weight=1 +ynh_script_progression --message="Create weblate configuration file..." db_pwd=$(ynh_app_setting_get "$app" psqlpwd) admin_mail=$(ynh_user_get_info "$admin" mail) @@ -217,7 +217,7 @@ ynh_app_setting_set "$app" redis_db "$redis_db" # SPECIFIC SETUP Filling up the database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database #========================================== -ynh_script_progression --message="Filling up the database..." --time --weight=1 +ynh_script_progression --message="Filling up the database..." ( set +o nounset source "${final_path}/venv/bin/activate" @@ -238,7 +238,7 @@ ynh_script_progression --message="Filling up the database..." --time --weight=1 # SETUP CRON #================================================= -ynh_script_progression --message="Configure cron file..." --time --weight=1 +ynh_script_progression --message="Configure cron file..." cp ../conf/cron "/etc/cron.d/$app" ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app" @@ -254,7 +254,7 @@ ynh_store_file_checksum "$settings" #================================================= # SPECIFIC SETUP uwsgi #================================================= -ynh_script_progression --message="Configure uwsgi..." --time --weight=1 +ynh_script_progression --message="Configure uwsgi..." finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" cp ../conf/uwsgi.ini "$finaluwsgiini" @@ -280,7 +280,7 @@ ynh_store_file_checksum "$finaluwsgiini" # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." --time --weight=1 +ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" @@ -305,7 +305,7 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --time --weight=1 +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -314,7 +314,7 @@ ynh_use_logrotate # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring SSOwat..." if [ "$is_public" -eq 0 ] then # Remove the public access @@ -342,7 +342,7 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" #================================================= # Start weblate #================================================= -ynh_script_progression --message="Starting weblate's services..." --time --weight=1 +ynh_script_progression --message="Starting weblate's services..." ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -351,7 +351,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name="nginx" --action="reload" @@ -366,4 +366,4 @@ If you facing an issue or want to improve this app, please open a new issue in t ynh_send_readme_to_admin "$message" "$admin" -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 87adac0..269941f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) @@ -28,21 +28,21 @@ final_path=$(ynh_app_setting_get "$app" final_path) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app service..." --time --weight=1 + ynh_script_progression --message="Removing $app service..." yunohost service remove "$app" fi # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app-celery" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app-celery service..." --time --weight=1 + ynh_script_progression --message="Removing $app-celery service..." yunohost service remove "$app-celery" fi #================================================= # STOP WEBLATE'S SERVICES #================================================= -ynh_script_progression --message="Stopping and removing systemd services..." --time --weight=1 +ynh_script_progression --message="Stopping and removing systemd services..." ynh_remove_systemd_config "$app" ynh_remove_systemd_config "$app-celery" @@ -50,7 +50,7 @@ ynh_remove_systemd_config "$app-celery" #================================================= # REMOVE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db "$db_name" "$app" @@ -58,7 +58,7 @@ ynh_psql_remove_db "$db_name" "$app" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -66,7 +66,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove "$final_path" @@ -74,7 +74,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -82,7 +82,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -107,7 +107,7 @@ ynh_secure_remove "/var/run/$app-celery" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete "$app" @@ -115,4 +115,4 @@ ynh_system_user_delete "$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index a347460..d624d1a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,7 +31,7 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." # Check web path availability ynh_webpath_available "$domain" "$path_url" || ynh_die "Path not available: ${domain}${path_url}" @@ -49,14 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create "$app" "$final_path" @@ -75,14 +75,14 @@ chown -R "$app": "$final_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_psql_test_if_first_run ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd" @@ -91,7 +91,7 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= # RESTORE Weblate service #================================================= -ynh_script_progression --message="Restoring systemd configurations..." --time --weight=1 +ynh_script_progression --message="Restoring systemd configurations..." usermod --append --groups www-data "$app" @@ -120,7 +120,7 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # RESTORE THE HUB BINARY FILE #================================================= -ynh_script_progression --message="Restore hub's binary file..." --time --weight=1 +ynh_script_progression --message="Restore hub's binary file..." ynh_restore_file "/usr/bin/hub" #================================================= @@ -135,7 +135,7 @@ mkdir -p "/var/log/$app" #================================================= # Start weblate #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -143,11 +143,11 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server and php-fpm..." ynh_systemd_action --service_name="nginx" --action="reload" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index b0e0e65..17f36a3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,7 @@ redis_db=$(ynh_app_setting_get "$app" redis_db) #================================================= # Get previous version number #================================================= -ynh_script_progression --message="Get previous version number..." --time --weight=1 +ynh_script_progression --message="Get previous version number..." ( set +o nounset @@ -51,7 +51,7 @@ test -e "$previous_version_template" || ynh_die "Previous version unknown: $prev #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -65,7 +65,7 @@ ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." if [ "$is_public" = "Yes" ]; then ynh_app_setting_set "$app" is_public 1 # Fix is_public as a boolean value @@ -102,7 +102,7 @@ path_url=$(ynh_normalize_url_path "$path_url") # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --time --weight=1 +ynh_script_progression --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -110,7 +110,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -137,7 +137,7 @@ ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a system user ynh_system_user_create "$app" "$final_path" @@ -146,7 +146,7 @@ chsh --shell /bin/bash "$app" #================================================= # SPECIFIC SETUP uwsgi #================================================= -ynh_script_progression --message="Configure uwsgi..." --time --weight=1 +ynh_script_progression --message="Configure uwsgi..." finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" cp ../conf/uwsgi.ini "$finaluwsgiini" @@ -172,7 +172,7 @@ ynh_store_file_checksum "$finaluwsgiini" # PIP INSTALLATION #================================================= -ynh_script_progression --message="Install weblate using PIP..." --time --weight=10 +ynh_script_progression --message="Install weblate using PIP..." --weight=10 ( set +o nounset @@ -190,7 +190,7 @@ ynh_script_progression --message="Install weblate using PIP..." --time --weight= #================================================= # CONFIG FILE UPGRADE #================================================= -ynh_script_progression --message="Create weblate configuration file..." --time --weight=1 +ynh_script_progression --message="Create weblate configuration file..." # save old settings file settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" @@ -246,7 +246,7 @@ ynh_secure_remove "$old_settings" #================================================= # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." --time --weight=1 +ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" @@ -259,7 +259,7 @@ ynh_add_systemd_config "$app-celery" "celery-weblate.service" #================================================= # Run migration scripts #================================================= -ynh_script_progression --message="Run migration scripts..." --time --weight=1 +ynh_script_progression --message="Run migration scripts..." ( set +o nounset source "${final_path}/venv/bin/activate" @@ -279,7 +279,7 @@ ynh_store_file_checksum "$final_path/venv/lib/$weblate_pypath/site-packages/webl #================================================= # SETUP CRON #================================================= -ynh_script_progression --message="Configure cron file..." --time --weight=1 +ynh_script_progression --message="Configure cron file..." cp ../conf/cron "/etc/cron.d/$app" ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app" @@ -288,7 +288,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate @@ -309,7 +309,7 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring SSOwat..." if [ $is_public -eq 0 ] then # Remove the public access @@ -330,7 +330,7 @@ fi #================================================= # Restart weblate #================================================= -ynh_script_progression --message="Starting weblate's services..." --time --weight=1 +ynh_script_progression --message="Starting weblate's services..." ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -339,7 +339,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name="nginx" --action="reload" @@ -347,4 +347,4 @@ ynh_systemd_action --service_name="nginx" --action="reload" # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last