From e96a3cb52802b57fde3b63b1d0f3c6e332974004 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 16 May 2023 18:11:52 +0200 Subject: [PATCH] fix prepare script --- prepare.sh | 3 ++- run.sh | 2 +- utils.sh | 5 +++++ variables.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/prepare.sh b/prepare.sh index 1cb5017..cd2a5cd 100755 --- a/prepare.sh +++ b/prepare.sh @@ -30,7 +30,8 @@ start_container () { chmod 777 $current_dir/cache lxc config device add "$CONTAINER_IMAGE" cache-folder disk path=/cache source="$current_dir/cache" - lxc restart $CONTAINER_IMAGE + lxc stop $CONTAINER_IMAGE || true + lxc start $CONTAINER_IMAGE wait_container $CONTAINER_IMAGE } diff --git a/run.sh b/run.sh index d1769ff..2cace7b 100755 --- a/run.sh +++ b/run.sh @@ -36,7 +36,7 @@ case ${2} in esac -lxc exec "$CONTAINER_ID" /bin/bash < "${1}" +lxc exec "$CONTAINER_IMAGE" /bin/bash < "${1}" if [ $? -ne 0 ]; then # Exit using the variable, to make the build as failure in GitLab # CI. diff --git a/utils.sh b/utils.sh index 490d250..956dab2 100755 --- a/utils.sh +++ b/utils.sh @@ -46,6 +46,11 @@ wait_container() if [ "$j" == "10" ]; then error 'Failed to access the internet' failstart=1 + lxc exec "$1" -- /bin/bash -c "echo 'resolv-file=/etc/resolv.dnsmasq.conf' > /etc/dnsmasq.d/resolvconf" + lxc exec "$1" -- /bin/bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.dnsmasq.conf" + lxc exec "$1" -- /bin/bash -c "sed -i 's/#IGNORE/IGNORE/g' /etc/default/dnsmasq" + lxc exec "$1" -- /bin/bash -c "systemctl restart dnsmasq" + lxc exec "$1" -- /bin/bash -c "journalctl -u dnsmasq -n 100 --no-pager" restart_container "$1" fi diff --git a/variables.sh b/variables.sh index c2a07c7..872c7e3 100755 --- a/variables.sh +++ b/variables.sh @@ -30,4 +30,4 @@ PROJECT_NAME="$CUSTOM_ENV_CI_PROJECT_NAME" # For example yunohost-buster-unstable BASE_IMAGE="yunohost-$DEBIAN_VERSION-$CURRENT_VERSION" -CONTAINER_IMAGE="$BASE_IMAGE-runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID" \ No newline at end of file +CONTAINER_IMAGE="$BASE_IMAGE-r-$CUSTOM_ENV_CI_RUNNER_ID-p-$CUSTOM_ENV_CI_PROJECT_ID-c-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID" \ No newline at end of file