Ajout de l'utilisation des options --user --password dans le script d'init
ref #17203 @1h
This commit is contained in:
parent
5fea856bec
commit
33209a8fae
|
@ -2,6 +2,38 @@
|
||||||
|
|
||||||
[ $(CreoleGet hapy_init_master) == non ] && exit 0
|
[ $(CreoleGet hapy_init_master) == non ] && exit 0
|
||||||
|
|
||||||
|
function error()
|
||||||
|
{
|
||||||
|
MSG=${1}
|
||||||
|
echo "[ERROR][${MSG}]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_home()
|
||||||
|
{
|
||||||
|
HOMEDIR=$(getent passwd ${1} | cut -d ':' -f 6)
|
||||||
|
echo ${HOMEDIR}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_one_auth()
|
||||||
|
{
|
||||||
|
CMD="cat"
|
||||||
|
HOME=$(get_user_home oneadmin)
|
||||||
|
FILE="${HOME}/.one/one_auth"
|
||||||
|
${CMD} ${FILE}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runOneCmd()
|
||||||
|
{
|
||||||
|
local cmd=${1}
|
||||||
|
local opt=${2}
|
||||||
|
local auth=$(get_one_auth)
|
||||||
|
|
||||||
|
echo "$cmd ${opt} --user ${auth%:*} --password ${auth#*:}"
|
||||||
|
$cmd ${opt} --user ${auth%:*} --password ${auth#*:}
|
||||||
|
return ${?}
|
||||||
|
}
|
||||||
|
|
||||||
DISKSIZE=$(CreoleGet hapy_init_master_disk_size)
|
DISKSIZE=$(CreoleGet hapy_init_master_disk_size)
|
||||||
DISKNAME="DSK-${DISKSIZE}-Go"
|
DISKNAME="DSK-${DISKSIZE}-Go"
|
||||||
DISKDESC="Disque vide de ${DISKSIZE} Go"
|
DISKDESC="Disque vide de ${DISKSIZE} Go"
|
||||||
|
@ -10,6 +42,7 @@ VERSIONISO=$(CreoleGet hapy_init_master_iso_version)
|
||||||
MAJORVERSION=${VERSIONISO:0:3}
|
MAJORVERSION=${VERSIONISO:0:3}
|
||||||
ISONAME="ISO-Eole-${VERSIONISO}-amd64"
|
ISONAME="ISO-Eole-${VERSIONISO}-amd64"
|
||||||
ISODESC="Image ISO EOLE Stable ${VERSIONISO} 64 bits"
|
ISODESC="Image ISO EOLE Stable ${VERSIONISO} 64 bits"
|
||||||
|
ISOURL="http://eole.ac-dijon.fr/pub/iso/EOLE-${MAJORVERSION}/${VERSIONISO}/eole-${VERSIONISO}-alternate-amd64.iso"
|
||||||
|
|
||||||
TMPLNAME="InstallEole-${VERSIONISO}-amd64"
|
TMPLNAME="InstallEole-${VERSIONISO}-amd64"
|
||||||
TMPLDESC="Modèle de VM permettant d'installer un module EOLE ${VERSIONISO} 64 bits (non persistente)"
|
TMPLDESC="Modèle de VM permettant d'installer un module EOLE ${VERSIONISO} 64 bits (non persistente)"
|
||||||
|
@ -27,11 +60,17 @@ TMPLDESC="Modèle de VM permettant d'installer un module EOLE ${VERSIONISO} 64 b
|
||||||
#*****************************************************
|
#*****************************************************
|
||||||
# DISQUE VIDE
|
# DISQUE VIDE
|
||||||
#*****************************************************
|
#*****************************************************
|
||||||
if ! oneimage show "${DISKNAME}" &>/dev/null
|
if ! runOneCmd "oneimage" "show ${DISKNAME}" &>/dev/null
|
||||||
then
|
then
|
||||||
echo "***** Création de ${DISKNAME} *****"
|
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
|
|
||||||
oneimage chtype "${DISKNAME}" OS
|
## Attention oneimage create --datastore ne fonctionne pas dans runOneCmd ...
|
||||||
|
auth=$(get_one_auth)
|
||||||
|
oneimage create --datastore $(CreoleGet one_ds_image_name) \
|
||||||
|
--name ${DISKNAME} --type DATABLOCK --description "${DISKDESC}" \
|
||||||
|
--size $((${DISKSIZE}*1024)) --prefix vd --driver qcow2 --user ${auth%:*} --password ${auth#*:}
|
||||||
|
|
||||||
|
runOneCmd "oneimage" "chtype ${DISKNAME} OS"
|
||||||
else
|
else
|
||||||
echo "***** ${DISKNAME} existe déjà *****"
|
echo "***** ${DISKNAME} existe déjà *****"
|
||||||
fi
|
fi
|
||||||
|
@ -40,10 +79,10 @@ echo
|
||||||
#*****************************************************
|
#*****************************************************
|
||||||
# Image ISO EOLE Latest Stable
|
# Image ISO EOLE Latest Stable
|
||||||
#*****************************************************
|
#*****************************************************
|
||||||
if ! oneimage show "${ISONAME}" &>/dev/null
|
if ! runOneCmd "oneimage" "show ${ISONAME}" &>/dev/null
|
||||||
then
|
then
|
||||||
echo "***** Téléchargement de ${ISONAME} *****"
|
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"
|
wget --output-document "/tmp/eole-${VERSIONISO}-alternate-amd64.iso" ${ISOURL}
|
||||||
echo "***** Création de ${ISONAME} *****"
|
echo "***** Création de ${ISONAME} *****"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Erreur lors du téléchargement, Abandon"
|
echo "Erreur lors du téléchargement, Abandon"
|
||||||
|
@ -59,15 +98,15 @@ DEV_PREFIX="hd"
|
||||||
PATH="/tmp/eole-${VERSIONISO}-alternate-amd64.iso"
|
PATH="/tmp/eole-${VERSIONISO}-alternate-amd64.iso"
|
||||||
PERSISTENT="No"
|
PERSISTENT="No"
|
||||||
EOF
|
EOF
|
||||||
oneimage create -d $(CreoleGet one_ds_iso_name) ${FILE}
|
runOneCmd "oneimage" "create -d $(CreoleGet one_ds_iso_name) ${FILE}"
|
||||||
/bin/rm -f ${FILE}
|
/bin/rm -f ${FILE}
|
||||||
for i in `seq 60`
|
for i in `seq 60`
|
||||||
do
|
do
|
||||||
sleep 1
|
sleep 1
|
||||||
#oneimage show ${ISONAME} | grep STATE | grep rdy &>/dev/null && break
|
#oneimage show ${ISONAME} | grep STATE | grep rdy &>/dev/null && break
|
||||||
oneimage show ${ISONAME} | grep STATE | grep lock &>/dev/null || break
|
runOneCmd "oneimage" "show ${ISONAME}" | grep STATE | grep lock &>/dev/null || break
|
||||||
echo -n "Attente : "
|
echo -n "Attente : "
|
||||||
oneimage show ${ISONAME} | grep STATE
|
runOneCmd "oneimage" "show ${ISONAME}" | grep STATE
|
||||||
done
|
done
|
||||||
rm -f "/tmp/eole-${VERSIONISO}-alternate-amd64.iso"
|
rm -f "/tmp/eole-${VERSIONISO}-alternate-amd64.iso"
|
||||||
else
|
else
|
||||||
|
@ -98,11 +137,8 @@ MEMORY="1024"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#NIC=[MODEL="virtio",NETWORK="CR_eole"]
|
#NIC=[MODEL="virtio",NETWORK="CR_eole"]
|
||||||
onetemplate create ${FILE}
|
runOneCmd "onetemplate" "create ${FILE}"
|
||||||
|
|
||||||
/bin/rm -f ${FILE}
|
/bin/rm -f ${FILE}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue