mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Apply new packaging advices
This commit is contained in:
parent
f4d64c6fdd
commit
45ff697d9f
9 changed files with 325 additions and 96 deletions
|
@ -3,7 +3,7 @@
|
||||||
"id": "weblate",
|
"id": "weblate",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.4.0"
|
"yunohost": ">= 3.5.0"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A translation platform using Git and Python"
|
"en": "A translation platform using Git and Python"
|
||||||
|
@ -44,6 +44,9 @@
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Should Weblate be public accessible?"
|
"en": "Should Weblate be public accessible?"
|
||||||
},
|
},
|
||||||
|
"help": {
|
||||||
|
"en": "Any YunoHost user and anonymous people from the web will be able to access the application"
|
||||||
|
},
|
||||||
"default": "0"
|
"default": "0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev \
|
||||||
|
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
|
||||||
|
postgresql libpq-dev uwsgi uwsgi-plugin-python3 \
|
||||||
|
mailutils python-celery-common virtualenv redis-server"
|
||||||
|
|
||||||
|
# Weblate's version for PIP and settings file
|
||||||
current_version="3.6.1"
|
current_version="3.6.1"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
weblate_fill_settings() {
|
weblate_fill_settings() {
|
||||||
local settings="$1"
|
local settings="$1"
|
||||||
|
@ -144,3 +158,74 @@ ynh_redis_remove_db() {
|
||||||
local db=$1
|
local db=$1
|
||||||
redis-cli -n "$db" flushall
|
redis-cli -n "$db" flushall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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}"
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ ynh_abort_if_errors
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
@ -23,22 +25,37 @@ db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Stopping systemd services..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PostgreSQL DATABASE
|
# BACKUP THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
ynh_psql_dump_db "$db_name" > db.sql
|
ynh_psql_dump_db "$db_name" > db.sql
|
||||||
ynh_backup "db.sql"
|
ynh_backup "db.sql"
|
||||||
|
|
||||||
|
@ -48,18 +65,45 @@ ynh_backup "db.sql"
|
||||||
# BACKUP THE CRON FILE
|
# BACKUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "/etc/cron.d/$app"
|
ynh_backup "/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE uwsgi files
|
# BACKUP THE uwsgi files
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up uwsgi configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_backup "/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
ynh_backup "/etc/systemd/system/$app-celery.service"
|
ynh_backup "/etc/systemd/system/$app-celery.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE celery files
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# nothing to do because it is inside $finalpath
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE hub binary file
|
# BACKUP THE hub binary file
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up uwsgi configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup /usr/bin/hub
|
ynh_backup /usr/bin/hub
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Starting systemd services..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
|
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
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
set -eu
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -20,19 +20,15 @@ new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path=$YNH_APP_NEW_PATH
|
new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=/var/www/$app
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
test -n "$old_path" || old_path="/"
|
|
||||||
test -n "$new_path" || new_path="/"
|
|
||||||
new_path=$(ynh_normalize_url_path $new_path)
|
|
||||||
old_path=$(ynh_normalize_url_path $old_path)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -50,17 +46,15 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Backup the current version of the app
|
ynh_script_progression --message="Stopping systemd services..." --time --weight=1
|
||||||
# ynh_backup_before_upgrade
|
|
||||||
# ynh_clean_setup () {
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
# # restore it if the upgrade fails
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
# ynh_restore_upgradebackup
|
|
||||||
# }
|
|
||||||
# # Exit if an error occurs during the execution of the script
|
|
||||||
# ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -68,6 +62,8 @@ fi
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||||
finalnginxconf=$nginx_conf_path
|
finalnginxconf=$nginx_conf_path
|
||||||
|
|
||||||
|
@ -81,6 +77,7 @@ fi
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/${new_domain}.d/${app}.conf"
|
finalnginxconf="/etc/nginx/conf.d/${new_domain}.d/${app}.conf"
|
||||||
mv "$nginx_conf_path" "$finalnginxconf"
|
mv "$nginx_conf_path" "$finalnginxconf"
|
||||||
fi
|
fi
|
||||||
|
@ -88,8 +85,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# Edit specific content from nginx configuration
|
# Edit specific content from nginx configuration
|
||||||
#=================================================
|
#=================================================
|
||||||
|
settings="$final_path/venv/lib/python3.5/site-packages/weblate/settings.py"
|
||||||
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
|
||||||
|
|
||||||
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
||||||
then
|
then
|
||||||
|
@ -99,10 +95,6 @@ then
|
||||||
# ynh panel is useless for public websites
|
# ynh panel is useless for public websites
|
||||||
ynh_replace_string " #include conf.d/" " include conf.d/" "$finalnginxconf"
|
ynh_replace_string " #include conf.d/" " include conf.d/" "$finalnginxconf"
|
||||||
fi
|
fi
|
||||||
# root install as an empty PATHURL to prevent '//static'
|
|
||||||
ynh_replace_string "URL_PREFIX = ''" "URL_PREFIX = '$new_path'" "$settings"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
||||||
|
@ -110,37 +102,47 @@ then
|
||||||
|
|
||||||
# ynh panel is only comptable with non-root installation
|
# ynh panel is only comptable with non-root installation
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||||
|
|
||||||
# root install as an empty PATHURL to prevent '//static'
|
|
||||||
ynh_replace_string "URL_PREFIX = '$old_path'" "URL_PREFIX = ''" "$settings"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_store_file_checksum "$finalnginxconf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY settings.py
|
# MODIFY settings.py
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Modify weblate's config file..." --time --weight=1
|
||||||
settingspy_conf_path="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
# Change the path in the nginx config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "URL_PREFIX = '$old_path" "URL_PREFIX = '$new_path" "$settingspy_conf_path"
|
ynh_replace_string "URL_PREFIX = '$old_path" "URL_PREFIX = '$new_path" "$settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# replace SERVER_EMAIL
|
# replace SERVER_EMAIL
|
||||||
ynh_replace_string "noreply@$old_domain" "noreply@$new_domain" "$settingspy_conf_path"
|
ynh_replace_string "noreply@$old_domain" "noreply@$new_domain" "$settings"
|
||||||
# replace ALLOWED_HOSTS
|
# replace ALLOWED_HOSTS
|
||||||
ynh_replace_string "['$old_domain']" "['$new_domain']" "$settingspy_conf_path"
|
ynh_replace_string "['$old_domain']" "['$new_domain']" "$settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
||||||
|
then
|
||||||
|
ynh_replace_string "URL_PREFIX = ''" "URL_PREFIX = '$new_path'" "$settings"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
||||||
|
then
|
||||||
|
# root install as an empty PATHURL to prevent '//static'
|
||||||
|
ynh_replace_string "URL_PREFIX = '$old_path'" "URL_PREFIX = ''" "$settings"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_store_file_checksum "$settings"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ChangeSite inside weblate
|
# ChangeSite inside weblate
|
||||||
#==========================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Run weblate's command changesite..." --time --weight=1
|
||||||
(
|
(
|
||||||
set +eu
|
set +eu
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -151,9 +153,22 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX and Weblate
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting systemd services..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||||
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
set -eu
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -42,12 +42,8 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||||
|
|
||||||
# Normalize the url path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path "$path_url")
|
|
||||||
|
|
||||||
# Check web path availability
|
|
||||||
ynh_webpath_available "$domain" "$path_url"
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
|
||||||
|
@ -60,6 +56,8 @@ mkdir -p "$final_path"
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
ynh_app_setting_set "$app" path "$path_url"
|
ynh_app_setting_set "$app" path "$path_url"
|
||||||
ynh_app_setting_set "$app" admin "$admin"
|
ynh_app_setting_set "$app" admin "$admin"
|
||||||
|
@ -76,14 +74,14 @@ ynh_app_setting_set "$app" github_token "$github_token"
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
|
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||||
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
|
|
||||||
postgresql libpq-dev uwsgi uwsgi-plugin-python3 \
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
mailutils python-celery-common virtualenv redis-server
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A PostgreSQL DATABASE
|
# CREATE A PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid "$app")
|
db_name=$(ynh_sanitize_dbid "$app")
|
||||||
ynh_app_setting_set "$app" db_name "$db_name"
|
ynh_app_setting_set "$app" db_name "$db_name"
|
||||||
|
@ -93,12 +91,14 @@ ynh_psql_test_if_first_run
|
||||||
# Initialize database and store postgres password for upgrade
|
# Initialize database and store postgres password for upgrade
|
||||||
ynh_psql_setup_db "$db_name" "$app"
|
ynh_psql_setup_db "$db_name" "$app"
|
||||||
|
|
||||||
systemctl reload postgresql
|
ynh_systemd_action --service_name=postgresql --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
@ -117,6 +117,8 @@ fi
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||||
|
|
||||||
# Hub needs a home directory with a config file
|
# Hub needs a home directory with a config file
|
||||||
ynh_system_user_create "$app" "$final_path"
|
ynh_system_user_create "$app" "$final_path"
|
||||||
# Allow bash for our user, so he can use Hub
|
# Allow bash for our user, so he can use Hub
|
||||||
|
@ -126,6 +128,8 @@ chsh --shell /bin/bash "$app"
|
||||||
# Download and install hub
|
# Download and install hub
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Download and install hub..." --time --weight=1
|
||||||
|
|
||||||
arch=$(dpkg --print-architecture)
|
arch=$(dpkg --print-architecture)
|
||||||
# Rasberry Pi: Debian armhf (ARM hard float) refers to the ARMv7
|
# Rasberry Pi: Debian armhf (ARM hard float) refers to the ARMv7
|
||||||
[[ $arch = "armhf" ]] && arch="arm"
|
[[ $arch = "armhf" ]] && arch="arm"
|
||||||
|
@ -172,6 +176,9 @@ EOF
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Install weblate using PIP..." --time --weight=10
|
||||||
|
|
||||||
virtualenv --python=python3 "${final_path}/venv"
|
virtualenv --python=python3 "${final_path}/venv"
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
|
@ -192,6 +199,9 @@ virtualenv --python=python3 "${final_path}/venv"
|
||||||
# https://docs.weblate.org/en/latest/admin/install.html#installation
|
# https://docs.weblate.org/en/latest/admin/install.html#installation
|
||||||
# TODO: use --extra-search-dir=/path/to/dists
|
# TODO: use --extra-search-dir=/path/to/dists
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Create weblate configuration file..." --time --weight=1
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||||
key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2)
|
key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2)
|
||||||
|
@ -207,6 +217,7 @@ ynh_app_setting_set "$app" redis_db "$redis_db"
|
||||||
# SPECIFIC SETUP Filling up the database
|
# SPECIFIC SETUP Filling up the database
|
||||||
# https://docs.weblate.org/en/latest/admin/install.html#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
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -226,6 +237,9 @@ ynh_app_setting_set "$app" redis_db "$redis_db"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP CRON
|
# SETUP CRON
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configure cron file..." --time --weight=1
|
||||||
|
|
||||||
cp ../conf/cron "/etc/cron.d/$app"
|
cp ../conf/cron "/etc/cron.d/$app"
|
||||||
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
||||||
|
@ -235,11 +249,12 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate 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 "$settings"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP uwsgi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure uwsgi..." --time --weight=1
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
@ -263,6 +278,8 @@ ynh_store_file_checksum "$finaluwsgiini"
|
||||||
# ACTIVATE CELERY
|
# ACTIVATE CELERY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configure celery..." --time --weight=1
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
celeryconf="$final_path/celery-weblate"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
cp ../conf/celery-weblate "$celeryconf"
|
||||||
|
|
||||||
|
@ -287,6 +304,8 @@ chown -R "$app": "$final_path/avatar-cache"
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||||
|
|
||||||
if [ "$is_public" -eq 0 ]
|
if [ "$is_public" -eq 0 ]
|
||||||
then # Remove the public access
|
then # Remove the public access
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
ynh_app_setting_delete "$app" skipped_uris
|
||||||
|
@ -313,15 +332,18 @@ yunohost service add "$app-celery" --log "/var/log/$app-celery"
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start weblate
|
# Start weblate
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting weblate's services..." --time --weight=1
|
||||||
|
|
||||||
systemctl start "$app"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
systemctl start "$app-celery"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
|
@ -333,3 +355,5 @@ 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_send_readme_to_admin "$message" "$admin"
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --time --last
|
||||||
|
|
|
@ -12,10 +12,12 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -24,22 +26,23 @@ db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status | grep -q "$app"
|
if yunohost service status "$app" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo "Remove $app service"
|
ynh_script_progression --message="Removing $app service..." --time --weight=1
|
||||||
yunohost service remove "$app"
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status | grep -q "$app-celery"
|
if yunohost service status "$app-celery" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo "Remove $app service"
|
ynh_script_progression --message="Removing $app-celery service..." --time --weight=1
|
||||||
yunohost service remove "$app-celery"
|
yunohost service remove "$app-celery"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP WEBLATE'S SERVICES
|
# STOP WEBLATE'S SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping and removing systemd services..." --time --weight=1
|
||||||
|
|
||||||
ynh_remove_systemd_config "$app"
|
ynh_remove_systemd_config "$app"
|
||||||
ynh_remove_systemd_config "$app-celery"
|
ynh_remove_systemd_config "$app-celery"
|
||||||
|
@ -47,6 +50,7 @@ ynh_remove_systemd_config "$app-celery"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE PostgreSQL DATABASE
|
# REMOVE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db "$db_name" "$app"
|
ynh_psql_remove_db "$db_name" "$app"
|
||||||
|
@ -54,6 +58,7 @@ ynh_psql_remove_db "$db_name" "$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
@ -61,13 +66,15 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "/var/www/$app"
|
ynh_secure_remove "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -92,6 +99,12 @@ ynh_secure_remove "/var/run/$app-celery"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete "$app"
|
ynh_system_user_delete "$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||||
|
|
|
@ -9,11 +9,16 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -26,11 +31,12 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||||
|
|
||||||
# Check web path availability
|
# Check web path availability
|
||||||
ynh_webpath_available "$domain" "$path_url"
|
ynh_webpath_available "$domain" "$path_url" || ynh_die "Path not available: ${domain}${path_url}"
|
||||||
|
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die "There is already a directory: $final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -43,12 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create "$app" "/home/$app"
|
ynh_system_user_create "$app" "/home/$app"
|
||||||
|
@ -67,23 +75,23 @@ chown -R "$app": "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
|
|
||||||
postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached \
|
|
||||||
mailutils python-celery-common virtualenv redis-server
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PostgreSQL DATABASE
|
# RESTORE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
|
ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd"
|
||||||
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE Weblate service
|
# RESTORE Weblate service
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring systemd configurations..." --time --weight=1
|
||||||
|
|
||||||
usermod --append --groups www-data "$app"
|
usermod --append --groups www-data "$app"
|
||||||
|
|
||||||
|
@ -112,7 +120,7 @@ ynh_restore_file "/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE HUB BINARY FILE
|
# RESTORE THE HUB BINARY FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore hub's binary file..." --time --weight=1
|
||||||
ynh_restore_file "/usr/bin/hub"
|
ynh_restore_file "/usr/bin/hub"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -120,12 +128,19 @@ ynh_restore_file "/usr/bin/hub"
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start weblate
|
# Start weblate
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
systemctl start "$app"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
systemctl start "$app-celery"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX & uwsgi
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||||
|
|
|
@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ redis_db=$(ynh_app_setting_get "$app" redis_db)
|
||||||
#=================================================
|
#=================================================
|
||||||
# Get previous version number
|
# Get previous version number
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Get previous version number..." --time --weight=1
|
||||||
|
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
|
@ -49,6 +51,7 @@ test -e "$previous_version_template" || ynh_die "Previous version unknown: $prev
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -62,6 +65,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set "$app" is_public 1 # Fix is_public as a boolean value
|
ynh_app_setting_set "$app" is_public 1 # Fix is_public as a boolean value
|
||||||
|
@ -171,6 +175,18 @@ path_url=$(ynh_normalize_url_path "$path_url")
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Stopping systemd services..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -186,28 +202,27 @@ then
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
ynh_store_file_checksum "$finalnginxconf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# Update dependencies
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create "$app" "/home/$app"
|
ynh_system_user_create "$app" "/home/$app"
|
||||||
chsh --shell /bin/bash "$app"
|
chsh --shell /bin/bash "$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
# Update dependencies
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
|
|
||||||
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
|
|
||||||
postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached \
|
|
||||||
mailutils python-celery-common virtualenv redis-server
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP uwsgi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure uwsgi..." --time --weight=1
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
@ -233,11 +248,13 @@ ynh_store_file_checksum "$finaluwsgiini"
|
||||||
|
|
||||||
if [ "$migrate_to_python3" -eq 1 ]
|
if [ "$migrate_to_python3" -eq 1 ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Rebuild the virtualenv with Python3..." --time --weight=1
|
||||||
ynh_secure_remove "${final_path}/venv"
|
ynh_secure_remove "${final_path}/venv"
|
||||||
virtualenv --python=python3 "${final_path}/venv"
|
virtualenv --python=python3 "${final_path}/venv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
|
ynh_script_progression --message="Install weblate using PIP..." --time --weight=10
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
@ -259,7 +276,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIG FILE UPGRADE
|
# CONFIG FILE UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create weblate configuration file..." --time --weight=1
|
||||||
# save old settings file
|
# save old settings file
|
||||||
|
|
||||||
old_settings="$final_path/settings.$previous_version.old.py"
|
old_settings="$final_path/settings.$previous_version.old.py"
|
||||||
|
@ -314,6 +331,7 @@ ynh_secure_remove "$old_settings"
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE CELERY
|
# ACTIVATE CELERY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure celery..." --time --weight=1
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
celeryconf="$final_path/celery-weblate"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
cp ../conf/celery-weblate "$celeryconf"
|
||||||
|
@ -326,7 +344,7 @@ ynh_add_systemd_config "$app-celery" "celery-weblate.service"
|
||||||
#=================================================
|
#=================================================
|
||||||
# Run migration scripts
|
# Run migration scripts
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Run migration scripts..." --time --weight=1
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -373,6 +391,8 @@ ynh_store_file_checksum "$final_path/venv/lib/python3.5/site-packages/weblate/se
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP CRON
|
# SETUP CRON
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure cron file..." --time --weight=1
|
||||||
|
|
||||||
cp ../conf/cron "/etc/cron.d/$app"
|
cp ../conf/cron "/etc/cron.d/$app"
|
||||||
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
||||||
|
@ -393,6 +413,7 @@ chown -R "$app": "$final_path/avatar-cache"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then # Remove the public access
|
then # Remove the public access
|
||||||
|
@ -413,12 +434,21 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# Restart weblate
|
# Restart weblate
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting weblate's services..." --time --weight=1
|
||||||
|
|
||||||
systemctl start "$app"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
systemctl start "$app-celery"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||||
|
|
Loading…
Reference in a new issue