1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Merge branch 'testing' into buster

This commit is contained in:
Maniack Crudelis 2020-05-03 00:47:08 +02:00 committed by GitHub
commit 3f383f568f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 115 additions and 180 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
disable-write-exception = true

View file

@ -8,7 +8,7 @@
"description": {
"en": "A translation platform using Git and Python"
},
"version": "3.8.0~ynh1",
"version": "3.8.0~ynh3",
"url": "https://weblate.org",
"license": "AGPL-3.0",
"maintainer": {

View file

@ -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" == "/" ]
@ -165,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}"
}

View file

@ -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

View file

@ -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
@ -85,8 +85,7 @@ fi
#=================================================
# Edit specific content from nginx configuration
#=================================================
python_version=$(ls -1 $final_path/venv/lib | grep python)
settings="$final_path/venv/lib/$python_version/site-packages/weblate/settings.py"
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
then
@ -110,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 ]
@ -143,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"
@ -156,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"
@ -164,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
@ -172,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

View file

@ -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,15 +200,14 @@ 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)
key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2)
redis_db=$(ynh_redis_get_free_db)
python_version=$(ls -1 $final_path/venv/lib | grep python)
settings="$final_path/venv/lib/$python_version/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"
@ -218,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"
@ -239,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"
@ -255,14 +254,16 @@ 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"
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
@ -279,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"
@ -304,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
@ -313,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
@ -341,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"
@ -350,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"
@ -365,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

View file

@ -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

View file

@ -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,17 +49,17 @@ 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" "/home/$app"
ynh_system_user_create "$app" "$final_path"
# Allow bash for our user, so he can use hub
chsh --shell /bin/bash "$app"
@ -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

View file

@ -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,23 +137,25 @@ 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" "/home/$app"
ynh_system_user_create "$app" "$final_path"
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"
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
@ -170,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
@ -188,10 +190,9 @@ 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
python_version=$(ls -1 $final_path/venv/lib | grep python)
settings="$final_path/venv/lib/$python_version/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"
@ -245,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"
@ -258,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"
@ -273,12 +274,12 @@ 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
#=================================================
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"
@ -287,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
@ -308,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
@ -329,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"
@ -338,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"
@ -346,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