mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Unfold AND OR
This commit is contained in:
parent
464149eb76
commit
e64eb3478e
4 changed files with 44 additions and 24 deletions
|
@ -77,7 +77,8 @@ ynh_backup() {
|
||||||
# Format correctly source and destination paths
|
# Format correctly source and destination paths
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Be sure the source path is not empty
|
# Be sure the source path is not empty
|
||||||
[[ -e "${src_path}" ]] || {
|
if [ ! -e "$src_path" ]
|
||||||
|
then
|
||||||
ynh_print_warn --message="Source path '${src_path}' does not exist"
|
ynh_print_warn --message="Source path '${src_path}' does not exist"
|
||||||
if [ "$not_mandatory" == "0" ]
|
if [ "$not_mandatory" == "0" ]
|
||||||
then
|
then
|
||||||
|
@ -92,7 +93,7 @@ ynh_backup() {
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
fi
|
||||||
|
|
||||||
# Transform the source path as an absolute path
|
# Transform the source path as an absolute path
|
||||||
# If it's a dir remove the ending /
|
# If it's a dir remove the ending /
|
||||||
|
@ -119,20 +120,23 @@ ynh_backup() {
|
||||||
dest_path="${dest_path#$YNH_CWD/}"
|
dest_path="${dest_path#$YNH_CWD/}"
|
||||||
|
|
||||||
# Case where $2 is an absolute dir but doesn't begin with $YNH_CWD
|
# Case where $2 is an absolute dir but doesn't begin with $YNH_CWD
|
||||||
[[ "${dest_path:0:1}" == "/" ]] \
|
if [[ "${dest_path:0:1}" == "/" ]]; then
|
||||||
&& dest_path="${dest_path#/}"
|
dest_path="${dest_path#/}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Complete dest_path if ended by a /
|
# Complete dest_path if ended by a /
|
||||||
[[ "${dest_path: -1}" == "/" ]] \
|
if [[ "${dest_path: -1}" == "/" ]]; then
|
||||||
&& dest_path="${dest_path}/$(basename $src_path)"
|
dest_path="${dest_path}/$(basename $src_path)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if dest_path already exists in tmp archive
|
# Check if dest_path already exists in tmp archive
|
||||||
[[ ! -e "${dest_path}" ]] || {
|
if [[ -e "${dest_path}" ]]
|
||||||
|
then
|
||||||
ynh_print_err --message="Destination path '${dest_path}' already exist"
|
ynh_print_err --message="Destination path '${dest_path}' already exist"
|
||||||
return 1
|
return 1
|
||||||
}
|
fi
|
||||||
|
|
||||||
# Add the relative current working directory to the destination path
|
# Add the relative current working directory to the destination path
|
||||||
local rel_dir="${YNH_CWD#$YNH_BACKUP_DIR}"
|
local rel_dir="${YNH_CWD#$YNH_BACKUP_DIR}"
|
||||||
|
|
|
@ -88,7 +88,9 @@ ynh_mysql_create_db() {
|
||||||
if [[ $# -gt 1 ]]
|
if [[ $# -gt 1 ]]
|
||||||
then
|
then
|
||||||
sql+=" GRANT ALL PRIVILEGES ON ${db}.* TO '${2}'@'localhost'"
|
sql+=" GRANT ALL PRIVILEGES ON ${db}.* TO '${2}'@'localhost'"
|
||||||
[[ -n ${3:-} ]] && sql+=" IDENTIFIED BY '${3}'"
|
if [[ -n ${3:-} ]]; then
|
||||||
|
sql+=" IDENTIFIED BY '${3}'"
|
||||||
|
fi
|
||||||
sql+=" WITH GRANT OPTION;"
|
sql+=" WITH GRANT OPTION;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@ ynh_add_systemd_config () {
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
# Substitute in a nginx config file only if the variable is not empty
|
||||||
if test -n "${final_path:-}"; then
|
if [ -n "${final_path:-}" ]; then
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalsystemdconf"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalsystemdconf"
|
||||||
fi
|
fi
|
||||||
if test -n "${app:-}"; then
|
if [ -n "${app:-}" ]; then
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finalsystemdconf"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finalsystemdconf"
|
||||||
fi
|
fi
|
||||||
ynh_store_file_checksum --file="$finalsystemdconf"
|
ynh_store_file_checksum --file="$finalsystemdconf"
|
||||||
|
@ -123,10 +123,20 @@ ynh_systemd_action() {
|
||||||
action="reload-or-restart"
|
action="reload-or-restart"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl $action $service_name \
|
# If the service fails to perform the action
|
||||||
|| ( journalctl --no-pager --lines=$length -u $service_name >&2 \
|
if ! systemctl $action $service_name
|
||||||
; test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 \
|
then
|
||||||
; false )
|
# Show syslog for this service
|
||||||
|
ynh_exec_err journalctl --no-pager --lines=$length --unit=$service_name
|
||||||
|
# If a log is specified for this service, show also the content of this log
|
||||||
|
if [ -e "$log_path" ]
|
||||||
|
then
|
||||||
|
ynh_print_err --message="--"
|
||||||
|
ynh_exec_err tail --lines=$length "$log_path"
|
||||||
|
fi
|
||||||
|
# Fail the app script, since the service failed.
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
|
||||||
# Start the timeout and try to find line_match
|
# Start the timeout and try to find line_match
|
||||||
if [[ -n "${line_match:-}" ]]
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
@ -155,8 +165,12 @@ ynh_systemd_action() {
|
||||||
then
|
then
|
||||||
ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout."
|
ynh_print_warn --message="The service $service_name didn't fully executed the action ${action} before the timeout."
|
||||||
ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:"
|
ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:"
|
||||||
journalctl --no-pager --lines=$length -u $service_name >&2
|
ynh_exec_warn journalctl --no-pager --lines=$length --unit=$service_name
|
||||||
test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2
|
if [ -e "$log_path" ]
|
||||||
|
then
|
||||||
|
ynh_print_warn --message="--"
|
||||||
|
ynh_exec_warn tail --lines=$length "$log_path"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -188,13 +188,13 @@ ynh_setup_source () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply patches
|
# Apply patches
|
||||||
if (( $(find $YNH_CWD/../sources/patches/ -type f -name "${source_id}-*.patch" 2> /dev/null | wc -l) > "0" )); then
|
if (( $(find $YNH_CWD/../sources/patches/ -type f -name "${source_id}-*.patch" 2> /dev/null | wc --lines) > "0" ))
|
||||||
local old_dir=$(pwd)
|
then
|
||||||
(cd "$dest_dir" \
|
(cd "$dest_dir"
|
||||||
&& for p in $YNH_CWD/../sources/patches/${source_id}-*.patch; do \
|
for p in $YNH_CWD/../sources/patches/${source_id}-*.patch
|
||||||
patch -p1 < $p; done) \
|
do
|
||||||
|| ynh_die --message="Unable to apply patches"
|
patch --strip=1 < $p
|
||||||
cd $old_dir
|
done) || ynh_die --message="Unable to apply patches"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add supplementary files
|
# Add supplementary files
|
||||||
|
|
Loading…
Add table
Reference in a new issue