From 2968582a74984f00c3b27806f151930159ebe7df Mon Sep 17 00:00:00 2001 From: Francois Lesueur Date: Wed, 18 Jan 2023 12:13:48 +0100 Subject: [PATCH] ajout option NOKAZ --- README.md | 11 +++-------- Vagrantfile.dist | 2 +- files/snster-kaz/kaz/prod/kaz.sh | 8 +------- files/vm-install-kaz.sh | 20 ++++++++++++++++++++ files/{provision.sh => vm-provision.sh} | 23 +++++++++-------------- 5 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 files/vm-install-kaz.sh rename files/{provision.sh => vm-provision.sh} (91%) diff --git a/README.md b/README.md index 6f722d3..d1f00c6 100644 --- a/README.md +++ b/README.md @@ -44,19 +44,14 @@ Cette étape peut-être (très) longue. Notamment, la construction de kaz-prod s ## Mise au point -(Non implémenté) Il est possible d'interrompre la création à la coquille vide (juste la VM sans les services KAZ) pour des question de mise au point avec la commande : +Il est possible d'interrompre la création à la coquille vide (juste la VM sans les services KAZ) pour des question de mise au point avec la commande : ```bash NOKAZ="true" vagrant up ``` -(Non implémenté) Dans ce cas, il faudra ensuite lancer dans la VM : +Dans ce cas, il faudra ensuite lancer dans la VM : ```bash -snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x /mnt/snster/root/snster-kaz/kaz/prod/kaz.sh -SETUP_MAIL="docker exec mailServ setup" -snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact1@kaz.sns toto" -snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact2@kaz.sns toto" -snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact3@kaz.sns toto" -snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact4@kaz.sns toto" +KAZGUARD="true" /root/vm-install-kaz.sh ``` Pour détruire la VM et recommencer : diff --git a/Vagrantfile.dist b/Vagrantfile.dist index 99316fe..e513bd2 100644 --- a/Vagrantfile.dist +++ b/Vagrantfile.dist @@ -88,7 +88,7 @@ Vagrant.configure("2") do |config| config.vm.synced_folder "/tmp/", "/tmp_host" config.vm.provision "shell" do |s| - s.inline = "/vagrant/files/provision.sh" + s.inline = "/vagrant/files/vm-provision.sh" s.env = {"KAZGUARD" => "true", "HOSTLANG" => ENV['LANG'], "NOKAZ" => ENV['NOKAZ'], "KAZBRANCH" => ENV['KAZBRANCH']} end end diff --git a/files/snster-kaz/kaz/prod/kaz.sh b/files/snster-kaz/kaz/prod/kaz.sh index fd0d54f..c0d234a 100755 --- a/files/snster-kaz/kaz/prod/kaz.sh +++ b/files/snster-kaz/kaz/prod/kaz.sh @@ -61,13 +61,7 @@ export DebugLog="${OUTPUT_DIR}/log/log-kaz-$(date +%y-%m-%d-%T)-" echo -e "\n #### secretGen\n" /kaz/bin/secretGen.sh - #possibilité de lancer vagrant up NOKAZ="true" quand on construit la machine - if [ "${NOKAZ}" == "true" ]; then - echo "on ne lance pas install.sh" - else - echo "on lance install.sh" - /kaz/bin/install.sh - fi + /kaz/bin/install.sh # clear apt cache DEBIAN_FRONTEND=noninteractive apt-get autoremove -y diff --git a/files/vm-install-kaz.sh b/files/vm-install-kaz.sh new file mode 100644 index 0000000..e2d5317 --- /dev/null +++ b/files/vm-install-kaz.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Installation de Kaz + +if [ -z "${KAZGUARD}" ] ; then + exit 1 +fi + +snster -c /root/snster-kaz -t /root/templates start +sleep 10 +snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x /mnt/snster/root/snster-kaz/kaz/prod/kaz.sh + +# On crée quelques mails +SETUP_MAIL="docker exec mailServ setup" +snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact1@kaz.sns toto" +snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact2@kaz.sns toto" +snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact3@kaz.sns toto" +snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact4@kaz.sns toto" + +echo -e '#!/bin/sh\nsnster -c /root/snster-kaz start' >> /etc/rc.local +chmod +x /etc/rc.local diff --git a/files/provision.sh b/files/vm-provision.sh similarity index 91% rename from files/provision.sh rename to files/vm-provision.sh index 0832059..983467b 100755 --- a/files/provision.sh +++ b/files/vm-provision.sh @@ -192,21 +192,16 @@ EOF # Build SNSTER KAZ ! snster -c /root/snster-kaz -t /root/templates create - snster -c /root/snster-kaz -t /root/templates start - sleep 10 - snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x /mnt/snster/root/snster-kaz/kaz/prod/kaz.sh + cp "${VAGRANT_SRC_DIR}/vm-install-kaz.sh" /root/ + chmod +x /root/vm-install-kaz.sh + if [ "${NOKAZ}" == "true" ]; then + echo "on ne fait pas l'install de kaz sur kaz-prod" + else + echo "on installe kaz sur kaz-prod" + bash "/root/vm-install-kaz.sh" + fi - # On crée quelques mails - SETUP_MAIL="docker exec mailServ setup" - snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact1@kaz.sns toto" - snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact2@kaz.sns toto" - snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact3@kaz.sns toto" - snster -c /root/snster-kaz -t /root/templates attach kaz-prod -x "${SETUP_MAIL} email add contact4@kaz.sns toto" - - echo -e '#!/bin/sh\nsnster -c /root/snster-kaz start' >> /etc/rc.local - chmod +x /etc/rc.local - - # On monte le filesystem de kaz-prod dans le /kaz de la VM pour le dév + # On monte le filesystem de kaz-prod dans le /kaz de la VM pour le dév (en nofail) mkdir /kaz-prod /kaz echo "overlay /kaz-prod overlay lowerdir=/var/lib/lxc/sr-masters-bullseye/rootfs,upperdir=/var/lib/lxc/kaz-kaz-prod/overlay/delta,workdir=/var/lib/lxc/kaz-kaz-prod/overlay/work,nofail 0 0" >> /etc/fstab echo "/kaz-prod/kaz /kaz none bind,nofail 0 0" >> /etc/fstab