check_witness_files to ynh_lxc_pc_witness_files_check

This commit is contained in:
yalh76 2022-10-24 00:05:41 +02:00
parent cdcd0b6765
commit 7c8e2c7c29
2 changed files with 50 additions and 50 deletions

View file

@ -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 () {

View file

@ -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
}