From c663ec74c1d97cccbc1291a9d3e74cdf3b7586e9 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 13 Jan 2019 19:09:21 +0100 Subject: [PATCH 01/12] Update to last standart --- README.md | 5 +- README_fr.md | 5 +- scripts/_common.sh | 453 ++++++++++++++++++++++++--------------------- scripts/backup | 7 +- scripts/change_url | 43 ++--- scripts/install | 21 +-- scripts/restore | 13 +- scripts/upgrade | 87 ++++----- 8 files changed, 319 insertions(+), 315 deletions(-) diff --git a/README.md b/README.md index f733235..3da16bb 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ Supported, with LDAP. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/) +* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/) +* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/) +* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/) ## Limitations diff --git a/README_fr.md b/README_fr.md index b6b605c..d43108e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -40,8 +40,9 @@ Supportée, avec LDAP. #### Architectures supportées. -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/) +* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/) +* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/) +* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/etherpad_mypads%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/) ## Limitations diff --git a/scripts/_common.sh b/scripts/_common.sh index 44a54cc..48f5b48 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -23,146 +23,37 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant } #================================================= -# EXPERIMENTAL HELPERS -#================================================= - -# Start or restart a service and follow its booting -# -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch; specify "systemd" to read systemd journal for specified service -# /var/log/$app/$app.log will be used if no other log is defined. -# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -# | arg: Service name - -ynh_check_starting () { - local line_to_match="$1" - local app_log="${2:-/var/log/$service_name/$service_name.log}" - local timeout=${3:-300} - local service_name="${4:-$app}" - - echo "Starting of $service_name" >&2 - systemctl stop $service_name - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$app_log" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$app_log" > "$templog" & - fi - # Get the PID of the last command - local pid_tail=$! - systemctl start $service_name - - local i=0 - for i in `seq 1 $timeout` - do - # Read the log until the sentence is found, which means the app finished starting. Or run until the timeout. - if grep --quiet "$line_to_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully start before the timeout." >&2 - fi - - echo "" - ynh_clean_check_starting -} -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting - -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} - -#================================================= - -ynh_print_log () { - echo "${1}" -} - -# Print an info on stdout -# -# usage: ynh_print_info "Text to print" -# | arg: text - The text to print -ynh_print_info () { - ynh_print_log "[INFO] ${1}" -} - -# Print a error on stderr -# -# usage: ynh_print_err "Text to print" -# | arg: text - The text to print -ynh_print_err () { - ynh_print_log "[ERR] ${1}" >&2 -} - -# Execute a command and force the result to be printed on stdout -# -# usage: ynh_exec_warn_less command to execute -# usage: ynh_exec_warn_less "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_warn_less () { - eval $@ 2>&1 -} - -# Remove any logs for all the following commands. -# -# usage: ynh_print_OFF -# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging. -ynh_print_OFF () { - set +x -} - -# Restore the logging after ynh_print_OFF -# -# usage: ynh_print_ON -ynh_print_ON () { - set -x - # Print an echo only for the log, to be able to know that ynh_print_ON has been called. - echo ynh_print_ON > /dev/null -} - +# FUTUR OFFICIAL HELPERS #================================================= # Create a dedicated fail2ban config (jail and filter conf files) # # usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]] -# | arg: log_file - Log file to be checked by fail2ban -# | arg: failregex - Failregex to be looked for by fail2ban -# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3 -# | arg: ports - Ports blocked for a banned IP address - default: http,https +# | arg: -l, --logpath= - Log file to be checked by fail2ban +# | arg: -r, --failregex= - Failregex to be looked for by fail2ban +# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3 +# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https ynh_add_fail2ban_config () { - # Process parameters - logpath=$1 - failregex=$2 - max_retry=${3:-3} - ports=${4:-http,https} - - test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." - test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing." - - finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf" - finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1 - ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1 - - sudo tee $finalfail2banjailconf <&2 - echo "WARNING${fail2ban_error#*WARNING}" >&2 - fi + ynh_store_file_checksum "$finalfail2banjailconf" + ynh_store_file_checksum "$finalfail2banfilterconf" + + if [ "$(lsb_release --codename --short)" != "jessie" ]; then + systemctl reload fail2ban + else + systemctl restart fail2ban + fi + local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")" + if [ -n "$fail2ban_error" ] + then + echo "[ERR] Fail2ban failed to load the jail for $app" >&2 + echo "WARNING${fail2ban_error#*WARNING}" >&2 + fi } # Remove the dedicated fail2ban config (jail and filter conf files) # # usage: ynh_remove_fail2ban_config ynh_remove_fail2ban_config () { - ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" - ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" - systemctl restart fail2ban + ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" + ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" + if [ "$(lsb_release --codename --short)" != "jessie" ]; then + systemctl reload fail2ban + else + systemctl restart fail2ban + fi } #================================================= @@ -205,28 +104,39 @@ ynh_remove_fail2ban_config () { # Read the value of a key in a ynh manifest file # # usage: ynh_read_manifest manifest key -# | arg: manifest - Path of the manifest to read -# | arg: key - Name of the key to find +# | arg: -m, --manifest= - Path of the manifest to read +# | arg: -k, --key= - Name of the key to find ynh_read_manifest () { - manifest="$1" - key="$2" - python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])" + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=manifest= [k]=manifest_key= ) + local manifest + local manifest_key + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])" } -# Read the upstream version from the manifest +# Read the upstream version from the manifest # The version number in the manifest is defined by ~ynh # For example : 4.3-2~ynh3 # This include the number before ~ynh # In the last example it return 4.3-2 # -# usage: ynh_app_upstream_version +# usage: ynh_app_upstream_version [-m manifest] +# | arg: -m, --manifest= - Path of the manifest to read ynh_app_upstream_version () { - manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest "$manifest_path" "version") - echo "${version_key/~ynh*/}" + declare -Ar args_array=( [m]=manifest= ) + local manifest + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + manifest="${manifest:-../manifest.json}" + if [ ! -e "$manifest" ]; then + manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") + echo "${version_key/~ynh*/}" } # Read package version from the manifest @@ -235,34 +145,50 @@ ynh_app_upstream_version () { # This include the number after ~ynh # In the last example it return 3 # -# usage: ynh_app_package_version +# usage: ynh_app_package_version [-m manifest] +# | arg: -m, --manifest= - Path of the manifest to read ynh_app_package_version () { - manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest "$manifest_path" "version") - echo "${version_key/*~ynh/}" + declare -Ar args_array=( [m]=manifest= ) + local manifest + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + manifest="${manifest:-../manifest.json}" + if [ ! -e "$manifest" ]; then + manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") + echo "${version_key/*~ynh/}" } -# Exit without error if the package is up to date +# Checks the app version to upgrade with the existing app version and returns: +# - UPGRADE_APP if the upstream app version has changed +# - UPGRADE_PACKAGE if only the YunoHost package has changed # -# This helper should be used to avoid an upgrade of a package -# when it's not needed. +## It stops the current script without error if the package is up-to-date +# +# This helper should be used to avoid an upgrade of an app, or the upstream part +# of it, when it's not needed # # To force an upgrade, even if the package is up to date, # you have to set the variable YNH_FORCE_UPGRADE before. # example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp # -# usage: ynh_abort_if_up_to_date -ynh_abort_if_up_to_date () { +# usage: ynh_check_app_version_changed +ynh_check_app_version_changed () { local force_upgrade=${YNH_FORCE_UPGRADE:-0} local package_check=${PACKAGE_CHECK_EXEC:-0} - local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) - local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0) - if [ "$version" = "$last_version" ] - then + # By default, upstream app version has changed + local return_value="UPGRADE_APP" + + local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0) + local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" + local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0) + local update_upstream_version="$(ynh_app_upstream_version)" + + if [ "$current_version" == "$update_version" ] ; then + # Complete versions are the same if [ "$force_upgrade" != "0" ] then echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 @@ -273,7 +199,122 @@ ynh_abort_if_up_to_date () { else ynh_die "Up-to-date, nothing to do" 0 fi + elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then + # Upstream versions are the same, only YunoHost package versions differ + return_value="UPGRADE_PACKAGE" fi + echo $return_value +} + +#================================================= + +# Delete a file checksum from the app settings +# +# $app should be defined when calling this helper +# +# usage: ynh_remove_file_checksum file +# | arg: -f, --file= - The file for which the checksum will be deleted +ynh_delete_file_checksum () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [f]=file= ) + local file + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_' + ynh_app_setting_delete $app $checksum_setting_name +} + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started +# +# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] +# | arg: -n, --service_name= - Name of the service to reload. Default : $app +# | arg: -a, --action= - Action to perform with systemctl. Default: start +# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. +# If not defined it don't wait until the service is completely started. +# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log +# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. +# | arg: -e, --length= - Length of the error log : Default : 20 +ynh_systemd_action() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) + local service_name + local action + local line_match + local length + local log_path + local timeout + + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + local service_name="${service_name:-$app}" + local action=${action:-start} + local log_path="${log_path:-/var/log/$service_name/$service_name.log}" + local length=${length:-20} + local timeout=${timeout:-300} + + # Start to read the log + if [[ -n "${line_match:-}" ]] + then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ] ; then + # Read the systemd journal + journalctl -u $service_name -f --since=-45 > "$templog" & + else + # Read the specified log file + tail -F -n0 "$log_path" > "$templog" & + fi + # Get the PID of the tail command + local pid_tail=$! + fi + + echo "${action^} the service $service_name" >&2 + systemctl $action $service_name \ + || ( journalctl --lines=$length -u $service_name >&2 \ + ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ + ; false ) + + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]] + then + local i=0 + for i in $(seq 1 $timeout) + do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --quiet "$line_match" "$templog" + then + echo "The service $service_name has correctly started." >&2 + break + fi + echo -n "." >&2 + sleep 1 + done + if [ $i -eq $timeout ] + then + echo "The service $service_name didn't fully started before the timeout." >&2 + journalctl --lines=$length -u $service_name >&2 + test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 + fi + + echo "" + ynh_clean_check_starting + fi +} + +# Clean temporary process and file used by ynh_check_starting +# (usually used in ynh_clean_setup scripts) +# +# usage: ynh_clean_check_starting +ynh_clean_check_starting () { + # Stop the execution of tail. + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 } #================================================= @@ -281,14 +322,20 @@ ynh_abort_if_up_to_date () { # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# | arg: -m --app_message= - The message to send to the administrator. +# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root # example: "root admin@domain" # If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you # example: "root admin@domain user1 user2" ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=app_message= [r]=recipients= ) + local app_message + local recipients + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + local app_message="${app_message:-...No specific information...}" + local recipients="${recipients:-root}" # Retrieve the email of users find_mails () { @@ -341,35 +388,15 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" #================================================= -# Reload (or other actions) a service and print a log in case of failure. -# -# usage: ynh_system_reload service_name [action] -# | arg: service_name - Name of the service to reload -# | arg: action - Action to perform with systemctl. Default: reload -ynh_system_reload () { - local service_name=$1 - local action=${2:-reload} - - # Reload, restart or start and print the log if the service fail to start or reload - systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false) -} - -#================================================= - -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} - -#================================================= - ynh_maintenance_mode_ON () { + # Load value of $path_url and $domain from the config if their not set + if [ -z $path_url ]; then + path_url=$(ynh_app_setting_get $app path) + fi + if [ -z $domain ]; then + domain=$(ynh_app_setting_get $app domain) + fi + # Create an html to serve as maintenance notice echo " @@ -416,6 +443,14 @@ include conf.d/yunohost_panel.conf.inc; } ynh_maintenance_mode_OFF () { + # Load value of $path_url and $domain from the config if their not set + if [ -z $path_url ]; then + path_url=$(ynh_app_setting_get $app path) + fi + if [ -z $domain ]; then + domain=$(ynh_app_setting_get $app domain) + fi + # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx diff --git a/scripts/backup b/scripts/backup index 311dfb4..9bd8e1e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/change_url b/scripts/change_url index 3b4ec90..fc028f1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -21,6 +21,11 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME +#================================================= +# LOAD SETTINGS +#================================================= + +final_path=$(ynh_app_setting_get $app final_path) mypads=$(ynh_app_setting_get $app mypads) #================================================= @@ -81,30 +86,15 @@ then # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" - # Move from sub path to root - if [ "$new_path" == "/" ] - then - ynh_replace_string "^location $old_path/" "location $new_path" "$nginx_conf_path" - ynh_replace_string "^.*rewrite.*\^/" "#sub_path_only&" "$nginx_conf_path" - ynh_replace_string "^location ~\* $old_path/" "location ~* $new_path" "$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" - # Change the path in the two rewrite instructions - ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path" - ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1${new_path}admin\$ $new_path" "$nginx_conf_path" + # Store path_url setting + ynh_app_setting_set $app path "$path_url" - # Move to a sub path - else - ynh_replace_string "^location $old_path.*" "location $new_path/ {" "$nginx_conf_path" - ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path" - ynh_replace_string "^location ~\* $old_path/*" "location ~* $new_path/" "$nginx_conf_path" - - # Change the path in the two rewrite instructions - ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path" - ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1$new_path/admin\$ $new_path/" "$nginx_conf_path" - fi - - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" + # Create a dedicated nginx config + ynh_add_nginx_config fi # Change the domain for nginx @@ -114,23 +104,22 @@ then ynh_delete_file_checksum "$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" + # Store file checksum for the new config file location + ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # RELOAD NGINX #================================================= -ynh_system_reload nginx +ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= # Wait for etherpad fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" #================================================= # DEACTIVE MAINTENANCE MODE diff --git a/scripts/install b/scripts/install index 929c3af..9c6c1dd 100644 --- a/scripts/install +++ b/scripts/install @@ -54,8 +54,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # 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 ynh_webpath_register $app $domain $path_url @@ -73,12 +71,6 @@ ynh_app_setting_set $app export $export ynh_app_setting_set $app mypads $mypads ynh_app_setting_set $app useldap $useldap -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_ON - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -123,11 +115,6 @@ ynh_setup_source "$final_path" # Download, check integrity and uncompress the so # NGINX CONFIGURATION #================================================= -if [ "$path_url" != "/" ] -then - ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf" -fi -ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" ynh_add_nginx_config #================================================= @@ -260,7 +247,7 @@ fi # SETUP FAIL2BAN #================================================= -ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" " .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5 +ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5 #================================================= # SETUP SSOWAT @@ -276,14 +263,14 @@ fi # RELOAD NGINX #================================================= -ynh_system_reload nginx +ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= # Wait for etherpad to be fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" if [ $mypads -eq 1 ] then @@ -291,7 +278,7 @@ then mysql -u $db_name -p$db_pwd $db_name < "../conf/lang_mypads.sql" # Wait for etherpad to be fully started - ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" + ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" fi #================================================= diff --git a/scripts/restore b/scripts/restore index 56e3f83..577f2cf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers # Load common variables for all scripts. source ../settings/scripts/_variables @@ -152,20 +147,20 @@ systemctl enable $app.service ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" -ynh_system_reload fail2ban restart +ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # RELOAD NGINX #================================================= -ynh_system_reload nginx +ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= # Wait for etherpad to be fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" #================================================= # DEACTIVE MAINTENANCE MODE diff --git a/scripts/upgrade b/scripts/upgrade index 7941647..3eb193d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,9 +34,9 @@ useldap=$(ynh_app_setting_get $app useldap) #================================================= # Wait for etherpad to be fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" -ynh_abort_if_up_to_date +upgrade_type=$(ynh_check_app_version_changed) #================================================= # FIX OLD THINGS @@ -114,7 +114,7 @@ ynh_maintenance_mode_ON # STOP ETHERPAD #================================================= -ynh_system_reload $app stop +ynh_systemd_action --action=stop #================================================= # STANDARD UPGRADE STEPS @@ -122,17 +122,15 @@ ynh_system_reload $app stop # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src +fi #================================================= # NGINX CONFIGURATION #================================================= -if [ "$path_url" != "/" ] -then - ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf" -fi -ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" ynh_add_nginx_config #================================================= @@ -172,40 +170,43 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")") # CONFIGURE ETHERPAD #================================================= -ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different -cp ../conf/settings.json "$final_path/settings.json" -cp ../conf/credentials.json "$final_path/credentials.json" -ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" -ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json" -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON -ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" -ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" -ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON -if [ "$export" = "abiword" ] +if [ "$upgrade_type" == "UPGRADE_APP" ] then - abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad -elif [ "$export" = "libreoffice" ] -then - soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad -fi -if test -z $language; then - language=en # If upgrading from a version which doesn't support translations, set language to English by default - ynh_app_setting_set $app language $language -fi -ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" + ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different + ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different + cp ../conf/settings.json "$final_path/settings.json" + cp ../conf/credentials.json "$final_path/credentials.json" + ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" + ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json" + db_pwd=$(ynh_app_setting_get $app mysqlpwd) + ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON + ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" + ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" + ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON + if [ "$export" = "abiword" ] + then + abiword_path=`which abiword` # Get abiword binary path + ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + elif [ "$export" = "libreoffice" ] + then + soffice_path=`which soffice` # Get soffice binary path + ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + fi + if test -z $language; then + language=en # If upgrading from a version which doesn't support translations, set language to English by default + ynh_app_setting_set $app language $language + fi + ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" -# Use ldap for mypads -if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] -then - ynh_replace_string "//noldap" "" "$final_path/settings.json" -fi + # Use ldap for mypads + if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] + then + ynh_replace_string "//noldap" "" "$final_path/settings.json" + fi -ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings + ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings + ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings +fi #================================================= # CREATE DEDICATED USER @@ -226,7 +227,7 @@ chown $app -R /var/log/$app/etherpad.log # UPGRADE FAIL2BAN #================================================= -ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" " .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5 +ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5 #================================================= # SETUP LOGROTATE @@ -266,14 +267,14 @@ fi # RELOAD NGINX #================================================= -ynh_system_reload nginx +ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= # Wait for etherpad to be fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" #================================================= # DEACTIVE MAINTENANCE MODE From b154cf912d445bf73a9de5cfb44d9aa6e099213a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 19 Jan 2019 11:35:33 +0100 Subject: [PATCH 02/12] Various fixes --- README.md | 4 ++-- README_fr.md | 4 ++-- manifest.json | 4 ++-- scripts/change_url | 1 + scripts/install | 8 +------- scripts/upgrade | 12 +++++++++++- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3da16bb..f4a7689 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Please do your pull request to the [testing branch](https://github.com/YunoHost- To try the testing branch, please proceed like that. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose +sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug or -sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose +sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug ``` diff --git a/README_fr.md b/README_fr.md index d43108e..93244f4 100644 --- a/README_fr.md +++ b/README_fr.md @@ -82,7 +82,7 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno Pour tester la branche testing, merci de procéder ainsi. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose +sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug ou -sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose +sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug ``` diff --git a/manifest.json b/manifest.json index 40a4a03..3996937 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Framapad clone, a online editor providing collaborative editing in real-time.", "fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel." }, - "version": "1.7.0~ynh1", + "version": "1.7.0~ynh2", "url": "https://framapad.org", "license": "Apache-2.0", "maintainer": { @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 2.7.12" + "yunohost": ">= 3.3.3" }, "multi_instance": true, "services": [ diff --git a/scripts/change_url b/scripts/change_url index fc028f1..25b00ef 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -27,6 +27,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) mypads=$(ynh_app_setting_get $app mypads) +port=$(ynh_app_setting_get $app port) #================================================= # CHECK THE SYNTAX OF THE PATHS diff --git a/scripts/install b/scripts/install index 9c6c1dd..a1bfbe2 100644 --- a/scripts/install +++ b/scripts/install @@ -247,7 +247,7 @@ fi # SETUP FAIL2BAN #================================================= -ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5 +ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 #================================================= # SETUP SSOWAT @@ -281,12 +281,6 @@ then ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" fi -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_OFF - #================================================= # SEND A README FOR THE ADMIN #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3eb193d..04ed654 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,6 +127,16 @@ then ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src fi +#================================================= +# UPGRADE DEPENDENCIES +#================================================= + +if [ "$export" = "abiword" ]; then + ynh_install_app_dependencies $abiword_app_depencencies +elif [ "$export" = "libreoffice" ]; then + ynh_install_app_dependencies $libreoffice_app_dependencies +fi + #================================================= # NGINX CONFIGURATION #================================================= @@ -227,7 +237,7 @@ chown $app -R /var/log/$app/etherpad.log # UPGRADE FAIL2BAN #================================================= -ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5 +ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 #================================================= # SETUP LOGROTATE From a588724425abfc6c71f0ffc20fed9dc6208c92f4 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 19 Jan 2019 11:57:22 +0100 Subject: [PATCH 03/12] English translation and typo --- scripts/_variables | 4 +- scripts/backup | 6 +-- scripts/change_url | 4 +- scripts/install | 101 +++++++++++++++++++++++++++++---------------- scripts/remove | 29 ++++++++----- scripts/restore | 18 ++++---- scripts/upgrade | 79 +++++++++++++++++++++++------------ 7 files changed, 154 insertions(+), 87 deletions(-) diff --git a/scripts/_variables b/scripts/_variables index 7eb4c6b..cb5e577 100644 --- a/scripts/_variables +++ b/scripts/_variables @@ -6,9 +6,9 @@ abiword_app_depencencies="abiword" # Dependencies for libre office libreoffice_app_dependencies="unoconv libreoffice-writer" -# Version of nodejs +# NodeJS version nodejs_version=6 -# Version of mypads +# Mypads version # This variable is mostly used to force an upgrade of the package in case of new versions of mypads. mypads_version=1.6.8 diff --git a/scripts/backup b/scripts/backup index 9bd8e1e..383b2f0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,20 +29,20 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # STANDARD BACKUP STEPS #================================================= -# BACKUP OF THE MAIN DIR OF THE APP +# BACKUP THE APP MAIN DIR #================================================= CHECK_SIZE "$final_path" ynh_backup "$final_path" #================================================= -# BACKUP OF THE NGINX CONFIGURATION +# BACKUP NGINX CONFIGURATION #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP OF THE SQL BDD +# BACKUP THE MYSQL DATABASE #================================================= ynh_mysql_dump_db "$db_name" > db.sql diff --git a/scripts/change_url b/scripts/change_url index 25b00ef..6922643 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,7 +67,7 @@ fi #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -119,7 +119,7 @@ ynh_systemd_action --action=reload --service_name=nginx # CHECK ETHERPAD STARTING #================================================= -# Wait for etherpad fully started +# Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" #================================================= diff --git a/scripts/install b/scripts/install index a1bfbe2..16708fa 100644 --- a/scripts/install +++ b/scripts/install @@ -16,10 +16,11 @@ source _variables #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } -ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST @@ -44,7 +45,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_print_OFF if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ] then - ynh_die "The password must have between 8 and 30 characters." + ynh_die "The password must be between 8 and 30 characters." fi ynh_print_ON @@ -77,7 +78,8 @@ ynh_app_setting_set $app useldap $useldap # FIND AND OPEN A PORT #================================================= -port=$(ynh_find_port 9001) # Look for an available port +# Find a free port +port=$(ynh_find_port 9001) ynh_app_setting_set $app port $port #================================================= @@ -97,7 +99,7 @@ fi ynh_install_nodejs $nodejs_version #================================================= -# CREATE A SQL DB +# CREATE A MYSQL DATABASE #================================================= db_name=$(ynh_sanitize_dbid $app) @@ -109,19 +111,22 @@ ynh_mysql_setup_db $db_name $db_name #================================================= ynh_app_setting_set $app final_path $final_path -ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src +# Download, check integrity and uncompress the source from app.src +ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +# Create a dedicated nginx config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_system_user_create $app $final_path # Create a dedicated system user +# Create a dedicated system user +ynh_system_user_create $app #================================================= # SPECIFIC SETUP @@ -143,7 +148,7 @@ ynh_use_logrotate # INSTALL ETHERPAD #================================================= -# Install dependencies and proceed with the installation +# Install dependencies and proceed to the installation ynh_use_nodejs "$final_path/bin/installDeps.sh" > $install_log 2>&1 npm install forever -g >> $install_log 2>&1 @@ -161,12 +166,16 @@ ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON if [ "$export" = "abiword" ] then - abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get abiword binary path + abiword_path=`which abiword` + # Set the path of abiword into etherpad config + ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" elif [ "$export" = "libreoffice" ] then - soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get soffice binary path + soffice_path=`which soffice` + # Set the path of soffice into etherpad config + ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" fi ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" @@ -176,8 +185,10 @@ then ynh_replace_string "//noldap" "" "$final_path/settings.json" fi -ynh_store_file_checksum "$final_path/settings.json" # Store config file checksum -ynh_store_file_checksum "$final_path/credentials.json" # Store config file checksum +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/settings.json" +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/credentials.json" #================================================= # SECURING FILES AND DIRECTORIES @@ -185,20 +196,21 @@ ynh_store_file_checksum "$final_path/credentials.json" # Store config file check # Set files ownership to etherpad chown -R $app: $final_path -chmod 600 $final_path/credentials.json # Restrict access to credentials.json +# Restrict access to credentials.json +chmod 600 $final_path/credentials.json #================================================= # SETUP SYSTEMD #================================================= ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" +# Create a dedicated systemd config ynh_add_systemd_config #================================================= -# ENABLE SERVICE IN ADMIN PANEL +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= -# Add service to YunoHost monitoring panel yunohost service add $app --log "/var/log/$app/etherpad.log" #================================================= @@ -206,23 +218,38 @@ yunohost service add $app --log "/var/log/$app/etherpad.log" #================================================= pushd "$final_path" -npm install ep_align # Add Left/Center/Right/Justify to lines of text in a pad -npm install ep_author_hover >> $install_log 2>&1 # Framapad - Adds author names to span titles -npm install ep_automatic_logut >> $install_log 2>&1 # Automatically disconnects user after some period of time (Prevent server overload) -npm install ep_comments_page >> $install_log 2>&1 # Framapad - Adds comments on sidebar and link it to the text. -npm install ep_countable >> $install_log 2>&1 # Framapad - Displays paragraphs, sentences, words and characters counts. -npm install ep_delete_empty_pads >> $install_log 2>&1 # Framapad - Delete pads which were never edited -npm install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts -npm install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite. -npm install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad +# Add Left/Center/Right/Justify to lines of text in a pad +npm install ep_align >> $install_log 2>&1 +# Framapad - Adds author names to span titles +npm install ep_author_hover >> $install_log 2>&1 +# Automatically disconnects user after some period of time (Prevent server overload) +npm install ep_automatic_logut >> $install_log 2>&1 +# Framapad - Adds comments on sidebar and link it to the text. +npm install ep_comments_page >> $install_log 2>&1 +# Framapad - Displays paragraphs, sentences, words and characters counts. +npm install ep_countable >> $install_log 2>&1 +# Framapad - Delete pads which were never edited +npm install ep_delete_empty_pads >> $install_log 2>&1 +# Framapad - Apply colors to fonts +npm install ep_font_color >> $install_log 2>&1 +# Framapad - Adds heading support to Etherpad Lite. +npm install ep_headings2 >> $install_log 2>&1 +# Framapad - Edit and Export as Markdown in Etherpad +npm install ep_markdown >> $install_log 2>&1 if [ $mypads -eq 1 ]; then - npm install ep_mypads@${mypads_version} >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad + # Framapad - Groups and private pads for etherpad + npm install ep_mypads@${mypads_version} >> $install_log 2>&1 fi -npm install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter -npm install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking' -npm install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript -npm install ep_table_of_contents >> $install_log 2>&1 # Framapad - View a table of contents for your pad -npm install ep_user_font_size >> $install_log 2>&1 # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views +# Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter +npm install ep_page_view >> $install_log 2>&1 +# Framapad - Add support to do 'Spell checking' +npm install ep_spellcheck >> $install_log 2>&1 +# Framapad - Add support for Subscript and Superscript +npm install ep_subscript_and_superscript >> $install_log 2>&1 +# Framapad - View a table of contents for your pad +npm install ep_table_of_contents >> $install_log 2>&1 +# Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views +npm install ep_user_font_size >> $install_log 2>&1 popd chown -R $app: $final_path/node_modules @@ -239,14 +266,17 @@ then ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | Etherpad admin" $final_path/node_modules/ep_mypads/static/l10n/en.json ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | Etherpad admin" $final_path/node_modules/ep_mypads/static/l10n/fr.json - mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. - sed -i "$mod_line s@div>@&\n\t

Mypads
@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad. + # Find the /div just after the field to open a pad + mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) + # In order to add a link to mypads plugin. + sed -i "$mod_line s@div>@&\n\t

Mypads
@" $final_path/src/templates/index.html fi #================================================= # SETUP FAIL2BAN #================================================= +# Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 #================================================= @@ -256,7 +286,8 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege if [ $is_public -eq 1 ]; then ynh_app_setting_set $app skipped_uris "/" else - ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... + # etherpad admin page doesn't support SSO... + ynh_app_setting_set $app skipped_uris "/admin" fi #================================================= diff --git a/scripts/remove b/scripts/remove index ae5d971..eef8cd0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -26,13 +26,15 @@ export=$(ynh_app_setting_get $app export) # STOP AND REMOVE SERVICE #================================================= +# Remove the dedicated systemd config ynh_remove_systemd_config #================================================= -# DISABLE SERVICE IN ADMIN PANEL +# REMOVE SERVICE FROM ADMIN PANEL #================================================= -if yunohost service status | grep -q $app # Check if service is declared in YunoHost +# Check if the service is declared in YunoHost +if yunohost service status | grep -q $app then ynh_print_info "Remove $app service" >&2 yunohost service remove $app @@ -44,6 +46,7 @@ fi if [ "$export" != "none" ] then + # Remove metapackage and its dependencies ynh_remove_app_dependencies fi @@ -54,33 +57,38 @@ fi ynh_remove_nodejs #================================================= -# REMOVE THE SQL DB +# REMOVE THE MYSQL DATABASE #================================================= -ynh_mysql_remove_db $db_name $db_name # Remove the database along with the associated user +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db $db_name $db_name #================================================= -# REMOVE THE MAIN DIR OF THE APP +# REMOVE APP MAIN DIR #================================================= -ynh_secure_remove "/var/www/$app" # Remove the app directory securely +# Remove the app directory securely +ynh_secure_remove "/var/www/$app" #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE NGINX CONFIGURATION #================================================= -ynh_remove_nginx_config # Remove the dedicated nginx config +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= -# REMOVE THE LOGROTATE CONFIG +# REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_remove_logrotate # Remove the app-specific logrotate config +# Remove the app-specific logrotate config +ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= +# Remove the dedicated fail2ban config ynh_remove_fail2ban_config #================================================= @@ -89,4 +97,5 @@ ynh_remove_fail2ban_config # REMOVE DEDICATED USER #================================================= +# Delete dedicated system user ynh_system_user_delete $app diff --git a/scripts/restore b/scripts/restore index 577f2cf..be3c222 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,7 +16,7 @@ source ../settings/scripts/_variables #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -55,19 +55,19 @@ ynh_maintenance_mode_ON #================================================= # STANDARD RESTORE STEPS #================================================= -# RESTORE OF THE NGINX CONFIGURATION +# RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RESTORE OF THE MAIN DIR OF THE APP +# RESTORE THE APP MAIN DIR #================================================= ynh_restore_file "$final_path" #================================================= -# RESTORE THE SQL DB +# RESTORE THE MYSQL DATABASE #================================================= db_pwd=$(ynh_app_setting_get $app mysqlpwd) @@ -78,7 +78,8 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql # RECREATE THE DEDICATED USER #================================================= -ynh_system_user_create $app $final_path # Recreate the dedicated user, if it doesn't exist +# Create the dedicated user (if not existing) +ynh_system_user_create $app #================================================= # SPECIFIC RESTORE @@ -121,14 +122,14 @@ npm cache clean npm install forever -g >> $install_log 2>&1 #================================================= -# SECURING FILES AND DIRECTORIES +# RESTORE USER RIGHTS #================================================= -# Set files ownership to etherpad +# Restore permissions on app files chown -R $app: $final_path #================================================= -# ENABLE SERVICE IN ADMIN PANEL +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app --log "/var/log/$app/etherpad.log" @@ -138,7 +139,6 @@ yunohost service add $app --log "/var/log/$app/etherpad.log" #================================================= ynh_restore_file "/etc/systemd/system/$app.service" -## Démarrage auto du service systemctl enable $app.service #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 04ed654..6aca4d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,28 +39,32 @@ ynh_systemd_action --action=restart --line_match="You can access your Etherpad i upgrade_type=$(ynh_check_app_version_changed) #================================================= -# FIX OLD THINGS +# ENSURE DOWNWARD COMPATIBILITY #================================================= +# Convert is_public as a boolean if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 # Convert is_public to boolean + ynh_app_setting_set $app is_public 1 is_public=1 elif [ "$is_public" = "No" ]; then ynh_app_setting_set $app is_public 0 is_public=0 fi -if [ -z $db_name ]; then # If db_name setting doesn't exist +# If db_name setting doesn't exist +if [ -z $db_name ]; then db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name fi -if [ -z $abiword ]; then # If abiword setting doesn't exist +# If abiword setting doesn't exist +if [ -z $abiword ]; then abiword=0 ynh_app_setting_set $app abiword $abiword fi -if [ -n $abiword ]; then # If abiword setting exists +# If abiword setting exists +if [ -n $abiword ]; then if [ $abiword -eq 1 ]; then export=abiword fi @@ -68,22 +72,26 @@ if [ -n $abiword ]; then # If abiword setting exists ynh_app_setting_delete $app abiword fi -if [ -z $export ]; then # If export setting doesn't exist +# If export setting doesn't exist +if [ -z $export ]; then export=none ynh_app_setting_set $app export $export fi -if [ -z $mypads ]; then # If mypads setting doesn't exist +# If mypads setting doesn't exist +if [ -z $mypads ]; then mypads=1 ynh_app_setting_set $app mypads $mypads fi -if [ -z $useldap ]; then # If useldap setting doesn't exist +# If useldap setting doesn't exist +if [ -z $useldap ]; then useldap=0 ynh_app_setting_set $app useldap $useldap fi -if [ -z $path_url ]; then # If path_url setting doesn't exist +# If path_url setting doesn't exist +if [ -z $path_url ]; then path_url="/" ynh_app_setting_set $app path $path_url fi @@ -95,10 +103,10 @@ fi # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # Cleanup installatioNettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -124,7 +132,8 @@ ynh_systemd_action --action=stop if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source "$final_path" fi #================================================= @@ -141,6 +150,7 @@ fi # NGINX CONFIGURATION #================================================= +# Create a dedicated nginx config ynh_add_nginx_config #================================================= @@ -182,8 +192,10 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")") if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different - ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different + # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. + ynh_backup_if_checksum_is_different "$final_path/settings.json" + # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. + ynh_backup_if_checksum_is_different "$final_path/credentials.json" cp ../conf/settings.json "$final_path/settings.json" cp ../conf/credentials.json "$final_path/credentials.json" ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" @@ -195,15 +207,20 @@ then ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON if [ "$export" = "abiword" ] then - abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get abiword binary path + abiword_path=`which abiword` + # Set the path of abiword into etherpad config + ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" elif [ "$export" = "libreoffice" ] then - soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get soffice binary path + soffice_path=`which soffice` + # Set the path of soffice into etherpad config + ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" fi if test -z $language; then - language=en # If upgrading from a version which doesn't support translations, set language to English by default + # If upgrading from a version which doesn't support translations, set language to English by default + language=en ynh_app_setting_set $app language $language fi ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" @@ -214,15 +231,18 @@ then ynh_replace_string "//noldap" "" "$final_path/settings.json" fi - ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings - ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings + # Recalculate and store the checksum of the file for the next upgrade. + ynh_store_file_checksum "$final_path/settings.json" + # Recalculate and store the checksum of the file for the next upgrade. + ynh_store_file_checksum "$final_path/credentials.json" fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_system_user_create $app $final_path # Create the dedicated user, if it doesn't exist +# Create a dedicated user (if not existing) +ynh_system_user_create $app #================================================= # SECURING FILES AND DIRECTORIES @@ -230,19 +250,22 @@ ynh_system_user_create $app $final_path # Create the dedicated user, if it doesn # Set files ownership to etherpad chown -R $app: $final_path -chmod 600 "$final_path/credentials.json" # Restrict access to credentials.json +chmod 600 "$final_path/credentials.json" +# Restrict access to credentials.json chown $app -R /var/log/$app/etherpad.log #================================================= # UPGRADE FAIL2BAN #================================================= +# Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 #================================================= # SETUP LOGROTATE #================================================= +# Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= @@ -250,6 +273,7 @@ ynh_use_logrotate --non-append #================================================= ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" +# Create a dedicated systemd config ynh_add_systemd_config #================================================= @@ -258,8 +282,10 @@ ynh_add_systemd_config if [ $mypads -eq 1 ] then - mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. - sed -i "$mod_line s@div>@&\n\t

Mypads
@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad. + # Find the /div just after the field to open a pad + mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) + # In order to add a link to mypads plugin. + sed -i "$mod_line s@div>@&\n\t

Mypads
@" $final_path/src/templates/index.html fi #================================================= @@ -270,7 +296,8 @@ fi if [ $is_public -eq 1 ]; then ynh_app_setting_set $app skipped_uris "/" else - ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... + # etherpad admin page doesn't support SSO... + ynh_app_setting_set $app skipped_uris "/admin" fi #================================================= From c0de9b2ee3ebc5ecb11e02655984e1fe793dd9d5 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 21 Jan 2019 13:06:07 +0100 Subject: [PATCH 04/12] Fix regression on ynh_system_user_create --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 16708fa..70ad9a1 100644 --- a/scripts/install +++ b/scripts/install @@ -126,7 +126,7 @@ ynh_add_nginx_config #================================================= # Create a dedicated system user -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP diff --git a/scripts/restore b/scripts/restore index be3c222..aa151a1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -79,7 +79,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC RESTORE diff --git a/scripts/upgrade b/scripts/upgrade index 6aca4d3..a57ce2b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -242,7 +242,7 @@ fi #================================================= # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # SECURING FILES AND DIRECTORIES From c87caaad6507a52a71572ef21529cc4f1022b53b Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 21 Jan 2019 19:30:28 +0100 Subject: [PATCH 05/12] Update to mypads 1.7.6 --- scripts/_variables | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_variables b/scripts/_variables index cb5e577..9d86eaa 100644 --- a/scripts/_variables +++ b/scripts/_variables @@ -11,4 +11,4 @@ nodejs_version=6 # Mypads version # This variable is mostly used to force an upgrade of the package in case of new versions of mypads. -mypads_version=1.6.8 +mypads_version=1.7.6 From a413aa716fe620eaae310b7c2118b574c0659e31 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Feb 2019 08:07:58 +0100 Subject: [PATCH 06/12] Require ynh 3.4 --- README.md | 2 +- README_fr.md | 2 +- manifest.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f4a7689..c2810cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Etherpad with mypads plugin for YunoHost -[![Integration level](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Official%29/lastBuild/consoleFull) +[![Integration level](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) [![Install Etherpad with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 93244f4..85595ca 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # Etherpad avec plugin mypads pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Official%29/lastBuild/consoleFull) +[![Niveau d'intégration](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) [![Installer Etherpad avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads) *[Read this readme in english.](./README.md)* diff --git a/manifest.json b/manifest.json index 3996937..16005e4 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 3.3.3" + "yunohost": ">= 3.4" }, "multi_instance": true, "services": [ From 4489e07a059477802cfeb402e1980b79e1ddce97 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Feb 2019 08:08:42 +0100 Subject: [PATCH 07/12] Progress bar --- scripts/_common.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/backup | 13 +++++++ scripts/change_url | 14 ++++++++ scripts/install | 25 ++++++++++++++ scripts/remove | 18 +++++++++- scripts/restore | 19 +++++++++++ scripts/upgrade | 24 +++++++++++++ 7 files changed, 196 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 48f5b48..bc74bc1 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -319,6 +319,90 @@ ynh_clean_check_starting () { #================================================= +# 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 +# Define base_time when the file is sourced +base_time=$(date +%s) +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 execution time since the last $base_time + local exec_time=$(( $(date +%s) - $base_time )) + base_time=$(date +%s) + + # 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 ))}" + + local print_exec_time="" + if [ $time -eq 1 ] + then + print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]" + fi + + ynh_print_info "[$progression_bar] > ${message}${print_exec_time}" +} + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= + # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/backup b/scripts/backup index 383b2f0..3f9056f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -31,6 +32,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_script_progression --message="Backup the app main dir" --weight=2 CHECK_SIZE "$final_path" ynh_backup "$final_path" @@ -38,12 +40,14 @@ ynh_backup "$final_path" #================================================= # BACKUP NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backup nginx configuration" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= +ynh_script_progression --message="Backup the mysql database" --weight=3 ynh_mysql_dump_db "$db_name" > db.sql CHECK_SIZE "db.sql" @@ -53,18 +57,27 @@ CHECK_SIZE "db.sql" #================================================= # BACKUP LOGROTATE #================================================= +ynh_script_progression --message="Backup logrotate configuration" ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= +ynh_script_progression --message="Backup systemd configuration" ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= +ynh_script_progression --message="Backup fail2ban configuration" ynh_backup "/etc/fail2ban/jail.d/$app.conf" ynh_backup "/etc/fail2ban/filter.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup completed" --last diff --git a/scripts/change_url b/scripts/change_url index 6922643..143207f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -24,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=5 final_path=$(ynh_app_setting_get $app final_path) mypads=$(ynh_app_setting_get $app mypads) @@ -32,6 +34,7 @@ port=$(ynh_app_setting_get $app port) #================================================= # CHECK THE SYNTAX OF THE PATHS #================================================= +ynh_script_progression --message="Check the syntax of the paths" test -n "$old_path" || old_path="/" test -n "$new_path" || new_path="/" @@ -41,6 +44,7 @@ old_path=$(ynh_normalize_url_path $old_path) #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 path_url=$old_path domain=$old_domain @@ -78,6 +82,7 @@ ynh_abort_if_errors #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Modify url in nginx configuration" --weight=3 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -112,12 +117,14 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= +ynh_script_progression --message="Restart Etherpad" --weight=10 # Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" @@ -125,7 +132,14 @@ ynh_systemd_action --action=restart --line_match="You can access your Etherpad i #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable maintenance mode" --weight=5 path_url=$old_path domain=$old_domain ynh_maintenance_mode_OFF + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of url completed" --last diff --git a/scripts/install b/scripts/install index 70ad9a1..61a44c6 100644 --- a/scripts/install +++ b/scripts/install @@ -25,6 +25,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_script_progression --message="Retrieve arguments from the manifest" domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -41,6 +42,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS #================================================= +ynh_script_progression --message="Check if the app can be installed" ynh_print_OFF if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ] @@ -61,6 +63,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Store settings from manifest" --weight=3 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -77,6 +80,7 @@ ynh_app_setting_set $app useldap $useldap #================================================= # FIND AND OPEN A PORT #================================================= +ynh_script_progression --message="Find a free port" --weight=2 # Find a free port port=$(ynh_find_port 9001) @@ -85,6 +89,7 @@ ynh_app_setting_set $app port $port #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Install dependencies" --weight=120 if [ "$export" = "abiword" ]; then ynh_install_app_dependencies $abiword_app_depencencies @@ -95,12 +100,14 @@ fi #================================================= # INSTALL NODEJS #================================================= +ynh_script_progression --message="Install NodeJS" --weight=12 ynh_install_nodejs $nodejs_version #================================================= # CREATE A MYSQL DATABASE #================================================= +ynh_script_progression --message="Create a mysql database" db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name @@ -109,6 +116,7 @@ ynh_mysql_setup_db $db_name $db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Download, check and unpack source" --weight=4 ynh_app_setting_set $app final_path $final_path # Download, check integrity and uncompress the source from app.src @@ -117,6 +125,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configure nginx" --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -124,6 +133,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Create a dedicated user" --weight=3 # Create a dedicated system user ynh_system_user_create $app $final_path @@ -133,6 +143,7 @@ ynh_system_user_create $app $final_path #================================================= # HANDLE LOG FILES AND LOGROTATE #================================================= +ynh_script_progression --message="Configure logrotate" # Create log directory mkdir -p /var/log/$app @@ -147,6 +158,7 @@ ynh_use_logrotate #================================================= # INSTALL ETHERPAD #================================================= +ynh_script_progression --message="Install Etherpad" --weight=90 # Install dependencies and proceed to the installation ynh_use_nodejs @@ -156,6 +168,7 @@ npm install forever -g >> $install_log 2>&1 #================================================= # CONFIGURE ETHERPAD #================================================= +ynh_script_progression --message="Configure Etherpad" --weight=6 cp ../conf/settings.json "$final_path/settings.json" cp ../conf/credentials.json "$final_path/credentials.json" @@ -202,6 +215,7 @@ chmod 600 $final_path/credentials.json #================================================= # SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configure systemd" --weight=4 ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" # Create a dedicated systemd config @@ -216,6 +230,7 @@ yunohost service add $app --log "/var/log/$app/etherpad.log" #================================================= # INSTALL FRAMAPAD'S PLUGINS #================================================= +ynh_script_progression --message="Install Etherpad plugins" --weight=90 pushd "$final_path" # Add Left/Center/Right/Justify to lines of text in a pad @@ -275,6 +290,7 @@ fi #================================================= # SETUP FAIL2BAN #================================================= +ynh_script_progression --message="Configure fail2ban" --weight=13 # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 @@ -282,6 +298,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Setup SSOwat" if [ $is_public -eq 1 ]; then ynh_app_setting_set $app skipped_uris "/" @@ -293,12 +310,14 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= +ynh_script_progression --message="Restart Etherpad" --weight=20 # Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" @@ -335,3 +354,9 @@ If you are facing an issue or want to improve this app, please open a new issue ynh_send_readme_to_admin "$message" "$admin" ynh_print_ON + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation completed" --last diff --git a/scripts/remove b/scripts/remove index eef8cd0..ac31a9c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=3 app=$YNH_APP_INSTANCE_NAME @@ -25,6 +26,7 @@ export=$(ynh_app_setting_get $app export) #================================================= # STOP AND REMOVE SERVICE #================================================= +ynh_script_progression --message="Stop and remove the service" --weight=2 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -36,7 +38,7 @@ ynh_remove_systemd_config # Check if the service is declared in YunoHost if yunohost service status | grep -q $app then - ynh_print_info "Remove $app service" >&2 + ynh_print_info "Remove $app service" yunohost service remove $app fi @@ -46,6 +48,7 @@ fi if [ "$export" != "none" ] then + ynh_script_progression --message="Remove dependencies" --weight=60 # Remove metapackage and its dependencies ynh_remove_app_dependencies fi @@ -53,12 +56,14 @@ fi #================================================= # REMOVE NODEJS #================================================= +ynh_script_progression --message="Remove NodeJS version for Etherpad" --weight=3 ynh_remove_nodejs #================================================= # REMOVE THE MYSQL DATABASE #================================================= +ynh_script_progression --message="Remove the mysql database" --weight=2 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_name $db_name @@ -66,6 +71,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Remove app main directory" # Remove the app directory securely ynh_secure_remove "/var/www/$app" @@ -73,6 +79,7 @@ ynh_secure_remove "/var/www/$app" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Remove nginx configuration" --weight=2 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -80,6 +87,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Remove logrotate configuration" # Remove the app-specific logrotate config ynh_remove_logrotate @@ -87,6 +95,7 @@ ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= +ynh_script_progression --message="Remove fail2ban configuration" --weight=7 # Remove the dedicated fail2ban config ynh_remove_fail2ban_config @@ -96,6 +105,13 @@ ynh_remove_fail2ban_config #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Remove the dedicated user" --weight=2 # Delete dedicated system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Deletion completed" --last diff --git a/scripts/restore b/scripts/restore index aa151a1..27ee06e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,6 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=4 app=$YNH_APP_INSTANCE_NAME @@ -49,6 +50,7 @@ test ! -d $final_path \ #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON @@ -63,12 +65,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restore the app main directory" ynh_restore_file "$final_path" #================================================= # RESTORE THE MYSQL DATABASE #================================================= +ynh_script_progression --message="Restore the mysql database" db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -77,6 +81,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreate the dedicated user" --weight=2 # Create the dedicated user (if not existing) ynh_system_user_create $app $final_path @@ -100,6 +105,7 @@ ynh_restore_file "/etc/logrotate.d/$app" #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstall dependencies" --weight=60 if [ "$export" = "abiword" ]; then ynh_install_app_dependencies $abiword_app_depencencies @@ -110,12 +116,14 @@ fi #================================================= # INSTALL NODEJS #================================================= +ynh_script_progression --message="Reinstall NodeJS" --weight=7 ynh_install_nodejs $nodejs_version #================================================= # INSTALL ETHERPAD DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstall Etherpad node dependencies" --weight=17 ynh_use_nodejs npm cache clean @@ -137,6 +145,7 @@ yunohost service add $app --log "/var/log/$app/etherpad.log" #================================================= # RESTORE SYSTEMD #================================================= +ynh_script_progression --message="Restore the systemd configuration" ynh_restore_file "/etc/systemd/system/$app.service" systemctl enable $app.service @@ -144,6 +153,7 @@ systemctl enable $app.service #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= +ynh_script_progression --message="Restore the fail2ban configuration" --weight=6 ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" @@ -152,12 +162,14 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= +ynh_script_progression --message="Restart Etherpad" --weight=8 # Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" @@ -165,6 +177,7 @@ ynh_systemd_action --action=restart --line_match="You can access your Etherpad i #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable maintenance mode" --weight=7 ynh_maintenance_mode_OFF @@ -191,3 +204,9 @@ If you are facing an issue or want to improve this app, please open a new issue ynh_send_readme_to_admin "$message" "$admin" ynh_print_ON + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed" --last diff --git a/scripts/upgrade b/scripts/upgrade index a57ce2b..388f38a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,7 @@ source _variables #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Load settings" --weight=20 app=$YNH_APP_INSTANCE_NAME @@ -41,6 +42,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensure downward compatibility" --weight=2 # Convert is_public as a boolean if [ "$is_public" = "Yes" ]; then @@ -99,6 +101,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backup the app before upgrading" --weight=35 # Backup the current version of the app ynh_backup_before_upgrade @@ -115,12 +118,14 @@ ynh_abort_if_errors #================================================= # ACTIVATE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_maintenance_mode_ON #================================================= # STOP ETHERPAD #================================================= +ynh_script_progression --message="Stop Etherpad service" --weight=3 ynh_systemd_action --action=stop @@ -139,6 +144,7 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= +ynh_script_progression --message="Download, check and unpack source" --weight=5 if [ "$export" = "abiword" ]; then ynh_install_app_dependencies $abiword_app_depencencies @@ -149,6 +155,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Reconfigure nginx" # Create a dedicated nginx config ynh_add_nginx_config @@ -156,6 +163,7 @@ ynh_add_nginx_config #================================================= # UPGRADE NODEJS #================================================= +ynh_script_progression --message="Upgrade NodeJS" --weight=4 # Remove the old nvm helper. if [ -d /opt/nvm ] @@ -169,6 +177,7 @@ ynh_install_nodejs $nodejs_version #================================================= # UPGRADE NPM MODULES #================================================= +ynh_script_progression --message="Upgrade Etherpad npm modules" --weight=60 # Update the main modules of etherpad (cd "$final_path/src" @@ -192,6 +201,7 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")") if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_script_progression --message="Reconfigure Etherpad" --weight=3 # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. @@ -240,6 +250,7 @@ fi #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Create a dedicated user" # Create a dedicated user (if not existing) ynh_system_user_create $app $final_path @@ -257,6 +268,7 @@ chown $app -R /var/log/$app/etherpad.log #================================================= # UPGRADE FAIL2BAN #================================================= +ynh_script_progression --message="Reconfigure fail2ban" --weight=8 # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 @@ -264,6 +276,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege #================================================= # SETUP LOGROTATE #================================================= +ynh_script_progression --message="Reconfigure logrotate" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -271,6 +284,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD #================================================= +ynh_script_progression --message="Reconfigure systemd" --weight=2 ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" # Create a dedicated systemd config @@ -291,6 +305,7 @@ fi #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Reconfigure SSOwat" # Make app public if necessary if [ $is_public -eq 1 ]; then @@ -303,12 +318,14 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reload nginx" ynh_systemd_action --action=reload --service_name=nginx #================================================= # CHECK ETHERPAD STARTING #================================================= +ynh_script_progression --message="Restart Etherpad" --weight=9 # Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" @@ -316,5 +333,12 @@ ynh_systemd_action --action=restart --line_match="You can access your Etherpad i #================================================= # DEACTIVE MAINTENANCE MODE #================================================= +ynh_script_progression --message="Disable maintenance mode" --weight=5 ynh_maintenance_mode_OFF + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade completed" --last From bab779a39f3f6f45c0fcc6bdf640baa47a5e6821 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Feb 2019 08:08:57 +0100 Subject: [PATCH 08/12] Update helpers --- scripts/_common.sh | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bc74bc1..fc2de39 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -206,29 +206,6 @@ ynh_check_app_version_changed () { echo $return_value } -#================================================= - -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: -f, --file= - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [f]=file= ) - local file - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - # Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started # # usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] @@ -298,6 +275,7 @@ ynh_systemd_action() { if [ $i -eq $timeout ] then echo "The service $service_name didn't fully started before the timeout." >&2 + echo "Please find here an extract of the end of the log of the service $service_name:" journalctl --lines=$length -u $service_name >&2 test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 fi From 2929e20aac2d2ecdcb28532cd188a07890589a4a Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Fri, 8 Mar 2019 09:32:21 +0100 Subject: [PATCH 09/12] Update scripts/change_url Co-Authored-By: maniackcrudelis --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 143207f..f466805 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,7 +71,7 @@ fi #================================================= ynh_clean_setup () { -# Clean installation remaining that are not handle by the remove script. +# Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script From 6dfb49f1d55a1851646a478320e3d7959357775c Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Fri, 8 Mar 2019 09:32:31 +0100 Subject: [PATCH 10/12] Update scripts/install Co-Authored-By: maniackcrudelis --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 61a44c6..1b0fd1d 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,7 @@ source _variables #================================================= ynh_clean_setup () { -# Clean installation remaining that are not handle by the remove script. +# Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script From ec9c3e930a5b104b9184aa915d08ee3d832dba7d Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Fri, 8 Mar 2019 09:32:39 +0100 Subject: [PATCH 11/12] Update scripts/upgrade Co-Authored-By: maniackcrudelis --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 388f38a..5344955 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -106,7 +106,7 @@ ynh_script_progression --message="Backup the app before upgrading" --weight=35 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { -# Clean installation remaining that are not handle by the remove script. +# Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting # Restore it if the upgrade fails From 324e95dad0fa195dcb9e27da61ebb06f42ed54ab Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Fri, 8 Mar 2019 09:32:47 +0100 Subject: [PATCH 12/12] Update scripts/restore Co-Authored-By: maniackcrudelis --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 27ee06e..2bf11f4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,7 +16,7 @@ source ../settings/scripts/_variables #================================================= ynh_clean_setup () { -# Clean installation remaining that are not handle by the remove script. +# Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script