diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 4e90f56..8b391cb 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -1,8 +1,8 @@ #!/bin/bash -source lib/lxc.sh +source lib/ynh_lxd +source lib/ynh_lxd_package_check source lib/tests.sh -source lib/witness.sh readonly complete_log="./Complete-${WORKER_ID}.log" diff --git a/lib/witness.sh b/lib/witness.sh deleted file mode 100644 index ea31590..0000000 --- a/lib/witness.sh +++ /dev/null @@ -1,90 +0,0 @@ - -set_witness_files () { - # Create files to check if the remove script does not remove them accidentally - log_debug "Create witness files..." - - create_witness_file () { - [ "$2" = "file" ] && local action="touch" || local action="mkdir -p" - RUN_INSIDE_LXC $action $1 - } - - # Nginx conf - create_witness_file "/etc/nginx/conf.d/$DOMAIN.d/witnessfile.conf" file - create_witness_file "/etc/nginx/conf.d/$SUBDOMAIN.d/witnessfile.conf" file - - # /etc - create_witness_file "/etc/witnessfile" file - - # /opt directory - create_witness_file "/opt/witnessdir" directory - - # /var/www directory - create_witness_file "/var/www/witnessdir" directory - - # /home/yunohost.app/ - create_witness_file "/home/yunohost.app/witnessdir" directory - - # /var/log - create_witness_file "/var/log/witnessfile" file - - # Config fpm - create_witness_file "/etc/php/$DEFAULT_PHP_VERSION/fpm/pool.d/witnessfile.conf" file - - # Config logrotate - create_witness_file "/etc/logrotate.d/witnessfile" file - - # Config systemd - create_witness_file "/etc/systemd/system/witnessfile.service" file - - # Database - RUN_INSIDE_LXC mysqladmin --wait status > /dev/null 2>&1 - echo "CREATE DATABASE witnessdb" | RUN_INSIDE_LXC mysql --wait > /dev/null 2>&1 -} - -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 -} diff --git a/lib/ynh_lxd b/lib/ynh_lxd new file mode 100644 index 0000000..6f59efb --- /dev/null +++ b/lib/ynh_lxd @@ -0,0 +1,6 @@ +#!/bin/bash + +#================================================= +# LXD HELPERS +#================================================= + diff --git a/lib/lxc.sh b/lib/ynh_lxd_package_check similarity index 69% rename from lib/lxc.sh rename to lib/ynh_lxd_package_check index f52ab43..a1f16c4 100644 --- a/lib/lxc.sh +++ b/lib/ynh_lxd_package_check @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# RUNNING SNAPSHOT +# PACKAGE_CHECK HELPERS #================================================= LXC_CREATE () { @@ -221,3 +221,92 @@ RUN_INSIDE_LXC() { lxc exec $LXC_NAME -- "$@" } +set_witness_files () { + # Create files to check if the remove script does not remove them accidentally + log_debug "Create witness files..." + + create_witness_file () { + [ "$2" = "file" ] && local action="touch" || local action="mkdir -p" + RUN_INSIDE_LXC $action $1 + } + + # Nginx conf + create_witness_file "/etc/nginx/conf.d/$DOMAIN.d/witnessfile.conf" file + create_witness_file "/etc/nginx/conf.d/$SUBDOMAIN.d/witnessfile.conf" file + + # /etc + create_witness_file "/etc/witnessfile" file + + # /opt directory + create_witness_file "/opt/witnessdir" directory + + # /var/www directory + create_witness_file "/var/www/witnessdir" directory + + # /home/yunohost.app/ + create_witness_file "/home/yunohost.app/witnessdir" directory + + # /var/log + create_witness_file "/var/log/witnessfile" file + + # Config fpm + create_witness_file "/etc/php/$DEFAULT_PHP_VERSION/fpm/pool.d/witnessfile.conf" file + + # Config logrotate + create_witness_file "/etc/logrotate.d/witnessfile" file + + # Config systemd + create_witness_file "/etc/systemd/system/witnessfile.service" file + + # Database + RUN_INSIDE_LXC mysqladmin --wait status > /dev/null 2>&1 + echo "CREATE DATABASE witnessdb" | RUN_INSIDE_LXC mysql --wait > /dev/null 2>&1 +} + +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 +}