From 7c8e2c7c29883138f88b367e857d13530aa9ca0a Mon Sep 17 00:00:00 2001 From: yalh76 <yalh@yahoo.com> Date: Mon, 24 Oct 2022 00:05:41 +0200 Subject: [PATCH] check_witness_files to ynh_lxc_pc_witness_files_check --- lib/tests.sh | 2 +- lib/ynh_lxd_package_check | 98 +++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/tests.sh b/lib/tests.sh index cfca38e..68c58fc 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -18,7 +18,7 @@ _RUN_YUNOHOST_CMD() { | grep --line-buffered -v 'processing action' returncode=${PIPESTATUS[0]} - check_witness_files && return $returncode || return 2 + ynh_lxc_pc_witness_files_check && return $returncode || return 2 } _PREINSTALL () { diff --git a/lib/ynh_lxd_package_check b/lib/ynh_lxd_package_check index 23ab41f..263a2b4 100644 --- a/lib/ynh_lxd_package_check +++ b/lib/ynh_lxd_package_check @@ -67,6 +67,54 @@ ynh_lxc_pc_witness_files_set () { echo "CREATE DATABASE witnessdb" | RUN_INSIDE_LXC mysql --wait > /dev/null 2>&1 } +ynh_lxc_pc_witness_files_check () { + # Check all the witness files, to verify if them still here + + check_file_exist () { + if RUN_INSIDE_LXC test ! -e "$1" + then + log_error "The file $1 is missing ! Something gone wrong !" + SET_RESULT "failure" witness + fi + } + + # Nginx conf + check_file_exist "/etc/nginx/conf.d/$DOMAIN.d/witnessfile.conf" + check_file_exist "/etc/nginx/conf.d/$SUBDOMAIN.d/witnessfile.conf" + + # /etc + check_file_exist "/etc/witnessfile" + + # /opt directory + check_file_exist "/opt/witnessdir" + + # /var/www directory + check_file_exist "/var/www/witnessdir" + + # /home/yunohost.app/ + check_file_exist "/home/yunohost.app/witnessdir" + + # /var/log + check_file_exist "/var/log/witnessfile" + + # Config fpm + check_file_exist "/etc/php/$DEFAULT_PHP_VERSION/fpm/pool.d/witnessfile.conf" + + # Config logrotate + check_file_exist "/etc/logrotate.d/witnessfile" + + # Config systemd + check_file_exist "/etc/systemd/system/witnessfile.service" + + # Database + if ! RUN_INSIDE_LXC mysqlshow witnessdb > /dev/null 2>&1 + then + log_error "The database witnessdb is missing ! Something gone wrong !" + SET_RESULT "failure" witness + return 1 + fi +} + LXC_CREATE () { log_info "Launching new LXC $LXC_NAME ..." # Check if we can launch container from YunoHost remote image @@ -116,7 +164,7 @@ CREATE_LXC_SNAPSHOT () { start_timer # Check all the witness files, to verify if them still here - check_witness_files >&2 + ynh_lxc_pc_witness_files_check >&2 # Remove swap files to avoid killing the CI with huge snapshots. CLEAN_SWAPFILES @@ -260,51 +308,3 @@ CLEAN_SWAPFILES() { RUN_INSIDE_LXC() { lxc exec $LXC_NAME -- "$@" } - -check_witness_files () { - # Check all the witness files, to verify if them still here - - check_file_exist () { - if RUN_INSIDE_LXC test ! -e "$1" - then - log_error "The file $1 is missing ! Something gone wrong !" - SET_RESULT "failure" witness - fi - } - - # Nginx conf - check_file_exist "/etc/nginx/conf.d/$DOMAIN.d/witnessfile.conf" - check_file_exist "/etc/nginx/conf.d/$SUBDOMAIN.d/witnessfile.conf" - - # /etc - check_file_exist "/etc/witnessfile" - - # /opt directory - check_file_exist "/opt/witnessdir" - - # /var/www directory - check_file_exist "/var/www/witnessdir" - - # /home/yunohost.app/ - check_file_exist "/home/yunohost.app/witnessdir" - - # /var/log - check_file_exist "/var/log/witnessfile" - - # Config fpm - check_file_exist "/etc/php/$DEFAULT_PHP_VERSION/fpm/pool.d/witnessfile.conf" - - # Config logrotate - check_file_exist "/etc/logrotate.d/witnessfile" - - # Config systemd - check_file_exist "/etc/systemd/system/witnessfile.service" - - # Database - if ! RUN_INSIDE_LXC mysqlshow witnessdb > /dev/null 2>&1 - then - log_error "The database witnessdb is missing ! Something gone wrong !" - SET_RESULT "failure" witness - return 1 - fi -}