#!/bin/bash [ $(CreoleGet hapy_init_master) == non ] && exit 0 DISKSIZE=$(CreoleGet hapy_init_master_disk_size) DISKNAME="DSK-${DISKSIZE}-Go" DISKDESC="Disque vide de ${DISKSIZE} Go" VERSIONISO=$(CreoleGet hapy_init_master_iso_version) MAJORVERSION=${VERSIONISO:0:3} ISONAME="ISO-Eole-${VERSIONISO}-amd64" ISODESC="Image ISO EOLE Stable ${VERSIONISO} 64 bits" TMPLNAME="InstallEole-${VERSIONISO}-amd64" TMPLDESC="Modèle de VM permettant d'installer un module EOLE ${VERSIONISO} 64 bits (non persistente)" #echo "########### suppr ${DISKNAME} ###############" #oneimage delete ${DISKNAME} #echo #echo "########### suppr ${ISONAME} ###################" #oneimage delete ${ISONAME} #echo #echo "########### suppr ${TMPLNAME} ###################" #onetemplate delete ${TMPLNAME} #echo #***************************************************** # DISQUE VIDE #***************************************************** if ! oneimage show "${DISKNAME}" &>/dev/null then echo "***** Création de ${DISKNAME} *****" oneimage create -d $(CreoleGet one_ds_image_name) --name "${DISKNAME}" --type DATABLOCK --description "${DISKDESC}" --size $((${DISKSIZE}*1024)) --prefix vd --driver qcow2 --fstype qcow2 oneimage chtype "${DISKNAME}" OS else echo "***** ${DISKNAME} existe déjà *****" fi echo #***************************************************** # Image ISO EOLE Latest Stable #***************************************************** if ! oneimage show "${ISONAME}" &>/dev/null then echo "***** Téléchargement de ${ISONAME} *****" wget --output-document "/tmp/eole-${VERSIONISO}-alternate-amd64.iso" "http://eole.ac-dijon.fr/pub/iso/EOLE-${MAJORVERSION}/${VERSIONISO}/eole-${VERSIONISO}-alternate-amd64.iso" echo "***** Création de ${ISONAME} *****" if [ $? -ne 0 ]; then echo "Erreur lors du téléchargement, Abandon" exit 1 fi FILE=$(mktemp) cat > ${FILE} </dev/null && break oneimage show ${ISONAME} | grep STATE | grep lock &>/dev/null || break echo -n "Attente : " oneimage show ${ISONAME} | grep STATE done rm -f "/tmp/eole-${VERSIONISO}-alternate-amd64.iso" else echo "***** ${ISONAME} existe déjà *****" fi echo #***************************************************** # Template EOLEBASE #***************************************************** if ! onetemplate show "${TMPLNAME}" &>/dev/null then echo "***** Création de ${TMPLNAME} *****" FILE=$(mktemp) cat > ${FILE} <