mirror of
https://github.com/YunoHost-Apps/wordpress_ynh.git
synced 2024-09-03 20:36:10 +02:00
Update to last standart
This commit is contained in:
parent
7e507a4395
commit
bb64ee0d9b
7 changed files with 409 additions and 189 deletions
|
@ -39,8 +39,9 @@ Supported, with LDAP and SSO.
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
* Tested on x86_64
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/wordpress/)
|
||||||
* Tested on RaspberryPi
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/wordpress/)
|
||||||
|
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/wordpress/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DISPLAYING
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
WARNING () { # Écrit sur le canal d'erreur pour passer en warning.
|
|
||||||
$@ >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
|
|
||||||
$@ > /dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP
|
# BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -28,29 +16,16 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
|
|
||||||
if [ $free_space -le $backup_size ]
|
if [ $free_space -le $backup_size ]
|
||||||
then
|
then
|
||||||
WARNING echo "Espace insuffisant pour sauvegarder $file_to_analyse."
|
ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse."
|
||||||
WARNING echo "Espace disponible: $(HUMAN_SIZE $free_space)"
|
ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)"
|
||||||
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
|
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
#============= FUTURE YUNOHOST HELPER ============
|
# FUTUR OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,16 +33,21 @@ ynh_delete_file_checksum () {
|
||||||
# Create a dedicated fail2ban config (jail and filter conf files)
|
# Create a dedicated fail2ban config (jail and filter conf files)
|
||||||
#
|
#
|
||||||
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
||||||
# | arg: log_file - Log file to be checked by fail2ban
|
# | arg: -l, --logpath= - Log file to be checked by fail2ban
|
||||||
# | arg: failregex - Failregex to be looked for by fail2ban
|
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
|
||||||
# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3
|
# | arg: -m, --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: -p, --ports= - Ports blocked for a banned IP address - default: http,https
|
||||||
ynh_add_fail2ban_config () {
|
ynh_add_fail2ban_config () {
|
||||||
# Process parameters
|
# Declare an array to define the options of this helper.
|
||||||
logpath=$1
|
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
|
||||||
failregex=$2
|
local logpath
|
||||||
max_retry=${3:-3}
|
local failregex
|
||||||
ports=${4:-http,https}
|
local max_retry
|
||||||
|
local ports
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
max_retry=${max_retry:-3}
|
||||||
|
ports=${ports:-http,https}
|
||||||
|
|
||||||
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
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."
|
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
||||||
|
@ -77,7 +57,7 @@ ynh_add_fail2ban_config () {
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
||||||
|
|
||||||
sudo tee $finalfail2banjailconf <<EOF
|
tee $finalfail2banjailconf <<EOF
|
||||||
[$app]
|
[$app]
|
||||||
enabled = true
|
enabled = true
|
||||||
port = $ports
|
port = $ports
|
||||||
|
@ -86,7 +66,7 @@ logpath = $logpath
|
||||||
maxretry = $max_retry
|
maxretry = $max_retry
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo tee $finalfail2banfilterconf <<EOF
|
tee $finalfail2banfilterconf <<EOF
|
||||||
[INCLUDES]
|
[INCLUDES]
|
||||||
before = common.conf
|
before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
|
@ -97,7 +77,11 @@ EOF
|
||||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||||
|
|
||||||
|
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||||
|
systemctl reload fail2ban
|
||||||
|
else
|
||||||
systemctl restart fail2ban
|
systemctl restart fail2ban
|
||||||
|
fi
|
||||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||||
if [ -n "$fail2ban_error" ]
|
if [ -n "$fail2ban_error" ]
|
||||||
then
|
then
|
||||||
|
@ -112,7 +96,11 @@ EOF
|
||||||
ynh_remove_fail2ban_config () {
|
ynh_remove_fail2ban_config () {
|
||||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||||
sudo systemctl restart fail2ban
|
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||||
|
systemctl reload fail2ban
|
||||||
|
else
|
||||||
|
systemctl restart fail2ban
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -120,32 +108,91 @@ ynh_remove_fail2ban_config () {
|
||||||
# Read the value of a key in a ynh manifest file
|
# Read the value of a key in a ynh manifest file
|
||||||
#
|
#
|
||||||
# usage: ynh_read_manifest manifest key
|
# usage: ynh_read_manifest manifest key
|
||||||
# | arg: manifest - Path of the manifest to read
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
# | arg: key - Name of the key to find
|
# | arg: -k, --key= - Name of the key to find
|
||||||
ynh_read_manifest () {
|
ynh_read_manifest () {
|
||||||
manifest="$1"
|
# Declare an array to define the options of this helper.
|
||||||
key="$2"
|
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||||
python3 -c "import sys, json;print(json.load(open('$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'])"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Exit without error if the package is up to date
|
# Read the upstream version from the manifest
|
||||||
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
|
# For example : 4.3-2~ynh3
|
||||||
|
# This include the number before ~ynh
|
||||||
|
# In the last example it return 4.3-2
|
||||||
#
|
#
|
||||||
# This helper should be used to avoid an upgrade of a package
|
# usage: ynh_app_upstream_version [-m manifest]
|
||||||
# when it's not needed.
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
|
ynh_app_upstream_version () {
|
||||||
|
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
|
||||||
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
|
# For example : 4.3-2~ynh3
|
||||||
|
# This include the number after ~ynh
|
||||||
|
# In the last example it return 3
|
||||||
|
#
|
||||||
|
# usage: ynh_app_package_version [-m manifest]
|
||||||
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
|
ynh_app_package_version () {
|
||||||
|
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/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
## 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,
|
# To force an upgrade, even if the package is up to date,
|
||||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||||
#
|
#
|
||||||
# usage: ynh_abort_if_up_to_date
|
# usage: ynh_check_app_version_changed
|
||||||
ynh_abort_if_up_to_date () {
|
ynh_check_app_version_changed () {
|
||||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||||
local package_check=${PACKAGE_CHECK_EXEC:-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)
|
# By default, upstream app version has changed
|
||||||
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
local return_value="UPGRADE_APP"
|
||||||
if [ "$version" = "$last_version" ]
|
|
||||||
then
|
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" ]
|
if [ "$force_upgrade" != "0" ]
|
||||||
then
|
then
|
||||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||||
|
@ -156,7 +203,122 @@ ynh_abort_if_up_to_date () {
|
||||||
else
|
else
|
||||||
ynh_die "Up-to-date, nothing to do" 0
|
ynh_die "Up-to-date, nothing to do" 0
|
||||||
fi
|
fi
|
||||||
|
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||||
|
# Upstream versions are the same, only YunoHost package versions differ
|
||||||
|
return_value="UPGRADE_PACKAGE"
|
||||||
fi
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -164,14 +326,20 @@ ynh_abort_if_up_to_date () {
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
# | arg: app_message - The message to send to the administrator.
|
# | arg: -m --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: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
# example: "root admin@domain"
|
# 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
|
# 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"
|
# example: "root admin@domain user1 user2"
|
||||||
ynh_send_readme_to_admin() {
|
ynh_send_readme_to_admin() {
|
||||||
local app_message="${1:-...No specific information...}"
|
# Declare an array to define the options of this helper.
|
||||||
local recipients="${2:-root}"
|
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
|
# Retrieve the email of users
|
||||||
find_mails () {
|
find_mails () {
|
||||||
|
@ -221,3 +389,82 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||||
# Send the email to the recipients
|
# Send the email to the recipients
|
||||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
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 "<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="3">
|
||||||
|
<title>Your app $app is currently under maintenance!</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
width: 70em;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Your app $app is currently under maintenance!</h1>
|
||||||
|
<p>This app has been put under maintenance by your administrator at $(date)</p>
|
||||||
|
<p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>" > "/var/www/html/maintenance.$app.html"
|
||||||
|
|
||||||
|
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
|
||||||
|
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
|
||||||
|
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
|
||||||
|
# Use another location, to not be in conflict with the original config file
|
||||||
|
location ${path_url}_maintenance/ {
|
||||||
|
alias /var/www/html/ ;
|
||||||
|
|
||||||
|
try_files maintenance.$app.html =503;
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
|
}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||||
|
|
||||||
|
# The current config file will redirect all requests to the root of the app.
|
||||||
|
# To keep the full path, we can use the following rewrite rule:
|
||||||
|
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
|
||||||
|
# The difference will be in the $1 at the end, which keep the following queries.
|
||||||
|
# But, if it works perfectly for a html request, there's an issue with any php files.
|
||||||
|
# This files are treated as simple files, and will be downloaded by the browser.
|
||||||
|
# Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was.
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
|
||||||
|
sleep 4
|
||||||
|
|
||||||
|
# Then remove the temporary files used for the maintenance.
|
||||||
|
rm "/var/www/html/maintenance.$app.html"
|
||||||
|
rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
}
|
||||||
|
|
51
scripts/_sed
51
scripts/_sed
|
@ -1,51 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# https://github.com/YunoHost/yunohost/pull/394
|
|
||||||
|
|
||||||
# Substitute/replace a string (or expression) by another in a file
|
|
||||||
#
|
|
||||||
# usage: ynh_replace_string match_string replace_string target_file
|
|
||||||
# | arg: match_string - String to be searched and replaced in the file
|
|
||||||
# | arg: replace_string - String that will replace matches
|
|
||||||
# | arg: target_file - File in which the string will be replaced.
|
|
||||||
#
|
|
||||||
# As this helper is based on sed command, regular expressions and
|
|
||||||
# references to sub-expressions can be used
|
|
||||||
# (see sed manual page for more information)
|
|
||||||
ynh_replace_string () {
|
|
||||||
local delimit=@
|
|
||||||
local match_string=$1
|
|
||||||
local replace_string=$2
|
|
||||||
local workfile=$3
|
|
||||||
|
|
||||||
# Escape the delimiter if it's in the string.
|
|
||||||
match_string=${match_string//${delimit}/"\\${delimit}"}
|
|
||||||
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
|
||||||
|
|
||||||
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Substitute/replace a password by another in a file
|
|
||||||
#
|
|
||||||
# usage: ynh_replace_password_string match_string replace_string target_file
|
|
||||||
# | arg: match_string - String to be searched and replaced in the file
|
|
||||||
# | arg: replace_string - String that will replace matches
|
|
||||||
# | arg: target_file - File in which the string will be replaced.
|
|
||||||
#
|
|
||||||
# This helper will use ynh_replace_string, but as you can use special
|
|
||||||
# characters, you can't use some regular expressions and sub-expressions.
|
|
||||||
ynh_replace_password_string () {
|
|
||||||
local match_string=$1
|
|
||||||
local replace_string=$2
|
|
||||||
local workfile=$3
|
|
||||||
|
|
||||||
# Escape any backslash to preserve them as simple backslash.
|
|
||||||
match_string=${match_string//\\/"\\\\"}
|
|
||||||
replace_string=${replace_string//\\/"\\\\"}
|
|
||||||
|
|
||||||
# Escape the & character, who has a special function in sed.
|
|
||||||
match_string=${match_string//&/"\&"}
|
|
||||||
replace_string=${replace_string//&/"\&"}
|
|
||||||
|
|
||||||
ynh_replace_string "$match_string" "$replace_string" "$workfile"
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source _sed
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
|
@ -26,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
multisite=$(ynh_app_setting_get $app multisite)
|
multisite=$(ynh_app_setting_get $app multisite)
|
||||||
|
|
||||||
if [ $multisite -eq 1 ]
|
if [ $multisite -eq 1 ]
|
||||||
|
@ -43,6 +43,14 @@ test -n "$new_path" || new_path="/"
|
||||||
new_path=$(ynh_normalize_url_path $new_path)
|
new_path=$(ynh_normalize_url_path $new_path)
|
||||||
old_path=$(ynh_normalize_url_path $old_path)
|
old_path=$(ynh_normalize_url_path $old_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
path_url=$old_path
|
||||||
|
domain=$old_domain
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -80,29 +88,15 @@ then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||||
|
|
||||||
# Move from sub path to root
|
# Set global variables for nginx helper
|
||||||
if [ "$new_path" == "/" ]
|
domain="$old_domain"
|
||||||
then
|
path_url="$new_path"
|
||||||
ynh_replace_string "\(^.*rewrite.*\^$old_path.* permanent;\)" "#sub_path_only\1" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Move to a sub path
|
# Store path_url setting
|
||||||
else
|
ynh_app_setting_set $app path "$path_url"
|
||||||
ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_replace_string "location ${old_path%/}/" "location ${new_path%/}/" "$nginx_conf_path"
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
# Change the rewrite instructions for multisite
|
|
||||||
ynh_replace_string "rewrite \^$old_path\(.*last;\)" "rewrite ^$new_path\1" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "$old_path\$2 last;" "$new_path\$2 last;" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Change the rewrite instruction with $request_filename
|
|
||||||
ynh_replace_string "${old_path%/}/index.php?q=" "${new_path%/}/index.php?q=" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Calculate and store the nginx config file checksum
|
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
|
@ -112,9 +106,8 @@ then
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum "$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
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
|
# Store file checksum for the new config file location
|
||||||
# Calculate and store the nginx config file checksum
|
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -132,4 +125,12 @@ ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_p
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
path_url=$old_path
|
||||||
|
domain=$old_domain
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
|
@ -39,8 +39,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
# Normalize the url path syntax
|
# Normalize the url path syntax
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
# Check web path availability
|
|
||||||
ynh_webpath_available $domain $path_url
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
|
@ -88,10 +86,6 @@ ynh_setup_source "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
if [ "$path_url" != "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
|
||||||
fi
|
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -143,21 +137,19 @@ ynh_app_setting_set $app unprotected_uris "/"
|
||||||
yunohost app ssowatconf # Régénère la configuration de SSOwat
|
yunohost app ssowatconf # Régénère la configuration de SSOwat
|
||||||
|
|
||||||
# Reload Nginx
|
# Reload Nginx
|
||||||
systemctl reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
# Wordpress installation
|
# Wordpress installation
|
||||||
ynh_local_curl "/wp-admin/install.php?step=2" "&weblog_title=YunoBlog" "user_name=$admin_wordpress" "admin_password=$db_pwd" "admin_password2=$db_pwd" "admin_email=$admin_wordpress@$domain" "Submit=Install+WordPress"
|
ynh_local_curl "/wp-admin/install.php?step=2" "&weblog_title=YunoBlog" "user_name=$admin_wordpress" "admin_password=$db_pwd" "admin_password2=$db_pwd" "admin_email=$admin_wordpress@$domain" "Submit=Install+WordPress"
|
||||||
|
|
||||||
WARNING echo -n "Please wait during Wordpress installation"
|
ynh_print_info "Please wait during Wordpress installation" >&2
|
||||||
for i in `seq 1 300`
|
for i in `seq 1 300`
|
||||||
do # La boucle attend la fin de l'installation de wordpress Ou 5 minutes.
|
do # La boucle attend la fin de l'installation de wordpress Ou 5 minutes.
|
||||||
if ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "show tables" | grep -q "wp_options"; then
|
if ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "show tables" | grep -q "wp_options"; then
|
||||||
break # Si la table wp_options est trouvée, l'installation de wordpress est terminée. Quitte la boucle.
|
break # Si la table wp_options est trouvée, l'installation de wordpress est terminée. Quitte la boucle.
|
||||||
fi
|
fi
|
||||||
WARNING echo -n "."
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
WARNING echo ""
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL WORDPRESS' PLUGINS
|
# INSTALL WORDPRESS' PLUGINS
|
||||||
|
@ -189,7 +181,7 @@ then
|
||||||
ynh_replace_string "//--MULTISITE1--define" "define " $final_path/wp-config.php
|
ynh_replace_string "//--MULTISITE1--define" "define " $final_path/wp-config.php
|
||||||
|
|
||||||
# Active le multisite via wp-cli.
|
# Active le multisite via wp-cli.
|
||||||
ALL_QUIET $wpcli_alias core multisite-convert --base=$path_url/
|
ynh_exec_fully_quiet $wpcli_alias core multisite-convert --base=$path_url/
|
||||||
|
|
||||||
# Active le multisite wordpress
|
# Active le multisite wordpress
|
||||||
ynh_replace_string "//--MULTISITE2--define" "define" $final_path/wp-config.php
|
ynh_replace_string "//--MULTISITE2--define" "define" $final_path/wp-config.php
|
||||||
|
@ -232,7 +224,7 @@ chown root: $final_path/wp-config.php
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/auth.log" "Authentication (attempt for unknown user|failure for) .* from <HOST>" 5
|
ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -248,7 +240,7 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE WP-CLI.PHAR
|
# REMOVE WP-CLI.PHAR
|
||||||
|
@ -260,6 +252,6 @@ ynh_secure_remove $final_path/wp-cli.phar
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/wordpress_ynh"
|
message="If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/wordpress_ynh"
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message" "$admin_wordpress"
|
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin_wordpress"
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# 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 /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -32,6 +27,7 @@ path_url=$(ynh_app_setting_get $app path)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
admin_wordpress=$(ynh_app_setting_get $app admin)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -42,6 +38,12 @@ ynh_webpath_available $domain $path_url \
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORE STEPS
|
# STANDARD RESTORE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -91,7 +93,7 @@ ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||||
systemctl restart fail2ban
|
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
@ -99,5 +101,19 @@ systemctl restart fail2ban
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload php5-fpm
|
ynh_systemd_action --action=reload --service_name=php5-fpm
|
||||||
systemctl reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SEND A README FOR THE ADMIN
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
message="If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/wordpress_ynh"
|
||||||
|
|
||||||
|
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin_wordpress"
|
||||||
|
|
|
@ -28,7 +28,7 @@ db_name=$(ynh_app_setting_get $app db_name)
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_up_to_date
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -98,15 +98,23 @@ ynh_abort_if_errors
|
||||||
# Normalize the URL path syntax
|
# Normalize the URL path syntax
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies php5-cli
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
if [ "$path_url" != "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
|
||||||
fi
|
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -193,7 +201,7 @@ chown root: $final_path/wp-config.php
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/auth.log" "Authentication (attempt for unknown user|failure for) .* from <HOST>" 5
|
ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from <HOST>" --max_retry=5
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -210,10 +218,16 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE WP-CLI.PHAR
|
# REMOVE WP-CLI.PHAR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_secure_remove $final_path/wp-cli.phar
|
ynh_secure_remove $final_path/wp-cli.phar
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
Loading…
Add table
Reference in a new issue