From f829afd2dfa4f532fe83ac15349653af2155c380 Mon Sep 17 00:00:00 2001 From: guillaume Date: Fri, 26 Apr 2024 00:09:06 +0200 Subject: [PATCH] Actualiser template/template.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correction d'une erreur sur le chemin de l'image cloud-init ainsi qu'ajout d'informations lors du déroulement du script --- template/template.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/template/template.sh b/template/template.sh index 8820b91..ab4554e 100644 --- a/template/template.sh +++ b/template/template.sh @@ -1,5 +1,11 @@ #!/bin/bash +GREEN="32" +LIGHTCYAN="96" +BOLDGREEN="\e[1;${GREEN}m" +BOLDLIGHTCYAN="\e[1;${LIGHTCYAN}m" +ENDCOLOR="\e[0m" + template_id=$1 template_name=$2 cloudinit_img=$3 @@ -12,27 +18,38 @@ ci_password="changeme" ci_network="dhcp" # Création de la VM +echo -e "\n${BOLDGREEN}Création de la MV${ENDCOLOR}" && sleep 2 qm create $template_id --memory 2048 --core 2 --name $template_name --net0 virtio,bridge=vmbr0 --agent 1 # Import disque cloud-init -qm importdisk $template_id $cloudinit_img/jammy-server-cloudimg-amd64.img Datastore +echo -e "\n${BOLDGREEN}Import image Cloud-INIT${ENDCOLOR}" && sleep 2 +qm importdisk $template_id $cloudinit_img Datastore # Création disque de stockage +echo -e "\n${BOLDGREEN}Création du disque de stockage${ENDCOLOR}" && sleep 2 qm set $template_id --scsihw virtio-scsi-pci --scsi0 Datastore:$template_id/vm-$template_id-disk-0.raw # Activation cloud-init +echo -e "\n${BOLDGREEN}Activation de Cloud-INIT${ENDCOLOR}" && sleep 2 qm set $template_id --ide2 $storage:cloudinit # Mise en place du boot sur cloud-init +echo -e "\n${BOLDGREEN}Choix du boot${ENDCOLOR}" && sleep 2 qm set $template_id --boot c --bootdisk scsi0 # Mise en place serial vga obligatoire pour cloud-init +echo -e "\n${BOLDGREEN}Mise en place du serial vga obligatoire${ENDCOLOR}" && sleep 2 qm set $template_id --serial0 socket --vga serial0 # Paramètres cloud-init +echo -e "\n${BOLDGREEN}Initialisation paramètres Cloud-INIT${ENDCOLOR}" && sleep 2 qm set $template_id -ciuser $ci_username qm set $template_id -cipassword $ci_password qm set $template_id --ipconfig0 ip=$ci_network # Création template +echo -e "\n${BOLDGREEN}Transformation de la VM en template${ENDCOLOR}" && sleep 2 qm template $template_id + +# Fin du script +echo -e "\n${BOLDLIGHTCYAN}Template ${2} terminé${ENDCOLOR}\n" \ No newline at end of file