From 97847623c34d9ff04a16e224723ac1b18a938115 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 12 Aug 2016 18:07:01 +0200 Subject: [PATCH] Time to switch --- demo_lxc_build.sh | 13 +++++++++++++ demo_start.sh | 3 +-- demo_upgrade.sh | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/demo_lxc_build.sh b/demo_lxc_build.sh index 2b77133..0d9767f 100755 --- a/demo_lxc_build.sh +++ b/demo_lxc_build.sh @@ -11,6 +11,7 @@ DOMAIN=demotest1.nohost.me YUNO_PWD=admin LXC_NAME1=yunohost_demo1 LXC_NAME2=yunohost_demo2 +TIME_TO_SWITCH=30 # En minutes USER_DEMO=demo PASSWORD_DEMO=demo @@ -173,3 +174,15 @@ server { EOF sudo service nginx reload + +# Mise en place du cron de switch +echo | sudo tee /etc/cron.d/demo_switch < /dev/null 2>&1 +EOF + +# Mise en place de HAProxy +# [...] + +# Démarrage de la démo +"./$script_dir/demo_start.sh" diff --git a/demo_start.sh b/demo_start.sh index f4f2b2e..5163a4a 100755 --- a/demo_start.sh +++ b/demo_start.sh @@ -30,6 +30,5 @@ echo "> Démarrage de la machine" sudo lxc-start -n $LXC_NAME -d sleep 3 -# Vérifie que la machine a démarré: +# Vérifie que la machine a démarré sudo lxc-ls -f - diff --git a/demo_upgrade.sh b/demo_upgrade.sh index 167dd3c..6d5b3dc 100755 --- a/demo_upgrade.sh +++ b/demo_upgrade.sh @@ -6,11 +6,13 @@ if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$P PLAGE_IP=$(cat "$script_dir/demo_lxc_build.sh" | grep PLAGE_IP= | cut -d '"' -f2) LXC_NAME1=$(cat "$script_dir/demo_lxc_build.sh" | grep LXC_NAME1= | cut -d '"' -f2) LXC_NAME2=$(cat "$script_dir/demo_lxc_build.sh" | grep LXC_NAME2= | cut -d '"' -f2) +TIME_TO_SWITCH=$(cat "$script_dir/demo_lxc_build.sh" | grep TIME_TO_SWITCH= | cut -d '"' -f2) UPGRADE_DEMO_CONTAINER () { # Démarrage, upgrade et snapshot MACHINE=$1 # Attend que la machine soit éteinte. - sudo lxc-wait -n $MACHINE -s STOPPED #-t 2000 (Timeout à 33 minutes, puisque le swith est à 30 minutes) + TIME_OUT=$(($TIME_TO_SWITCH * 60 + 300)) # Timeout à $TIME_TO_SWITCH +5 minutes, en seconde + sudo lxc-wait -n $MACHINE -s 'STOPPED' -t $TIME_OUT # Restaure le snapshot sudo lxc-snapshot -r snap0 $MACHINE