From ff74d283a6b68edc21b27bb1f6ebbaa538ddc93f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 11 May 2017 01:36:06 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20hostname=20&=20liste=20non=20tri=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sub_scripts/launcher.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sub_scripts/launcher.sh b/sub_scripts/launcher.sh index 766e86b..069e10c 100755 --- a/sub_scripts/launcher.sh +++ b/sub_scripts/launcher.sh @@ -19,16 +19,16 @@ create_temp_backup () { # Create a temporary snapshot # Check all the witness files, to verify if them still here - check_witness_files + check_witness_files >&2 # Stop the container, before its snapshot - sudo lxc-stop --name $lxc_name + sudo lxc-stop --name $lxc_name >&2 # Create the snapshot. sudo lxc-snapshot --name $lxc_name >> "$test_result" 2>&1 # Get the last created snapshot and return it - echo "$(sudo lxc-snapshot --name $lxc_name --list | head --lines=1 | cut --delimiter=' ' --fields=1)" + sudo lxc-snapshot --name $lxc_name --list | sort | tail --lines=1 | cut --delimiter=' ' --fields=1 # Restart the container, after the snapshot LXC_START "true" >&2 @@ -39,6 +39,9 @@ use_temp_snapshot () { # $1 = Name of the snapshot to use local snapshot_name=$1 + # Fix the missing hostname in the hosts file... + echo "127.0.0.1 $lxc_name" | sudo tee --append "$snapshot_path/$snapshot_name/rootfs/etc/hosts" > /dev/null + # Restore this snapshot. sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$snapshot_name/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result" @@ -51,7 +54,7 @@ destroy_temporary_snapshot () { while true do - local snapshot=$(sudo lxc-snapshot --name $lxc_name --list | head --lines=1 | cut --delimiter=' ' --fields=1) + local snapshot=$(sudo lxc-snapshot --name $lxc_name --list | sort | tail --lines=1 | cut --delimiter=' ' --fields=1) if [ -n "$snapshot" ] && [ "$snapshot" != "snap0" ] then echo "Destroy temporary snapshot $snapshot."