"MaJ expl_create_vhost.sh"

This commit is contained in:
2017-07-22 09:26:03 +02:00
parent ac1f00a9df
commit b0bd60c2f3
2 changed files with 24 additions and 11 deletions

View File

@@ -109,13 +109,14 @@ function check_port
function check_templates
{
if [ ! -r ${RPROXY_VHOST_TEMPLATE} ]; then
ERROR="${RPROXY_VHOST_TEMPLATE} n'existe pas ou n'est pas lisible"
fct_message "Vérification de la présence du fichier modèle ${NC_EXPL_MOD}/${RPROXY_VHOST_TEMPLATE}" -color rose
if [ ! -r ${NC_EXPL_MOD}/${RPROXY_VHOST_TEMPLATE} ]; then
ERROR="${NC_EXPL_MOD}/${RPROXY_VHOST_TEMPLATE} n'existe pas ou n'est pas lisible"
fct_erreur 2
fi
if [ ! -r ${REMOTE_VHOST_TEMPLATE} ]; then
ERROR="${REMOTE_VHOST_TEMPLATE} n'existe pas ou n'est pas lisible"
fct_message "Vérification de la présence du fichier modèle ${NC_EXPL_MOD}/${REMOTE_VHOST_TEMPLATE}" -color rose
if [ ! -r ${NC_EXPL_MOD}/${REMOTE_VHOST_TEMPLATE} ]; then
ERROR="${NC_EXPL_MOD}/${REMOTE_VHOST_TEMPLATE} n'existe pas ou n'est pas lisible"
fct_erreur 2
fi
}
@@ -126,8 +127,8 @@ function create_rproxy_conf
fct_message "Création de la configuration du rproxy:" -color rose
fct_message " * Domaine: ${domain}"
fct_message " * Hôte : ${backend_host}"
fct_message ' * Port: ${backend_port}'
sed -s ${REPLACE_DOMAIN} ${RPROXY_VHOST_TEMPLATE} > ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp
fct_message " * Port: ${backend_port}"
sed -s ${REPLACE_DOMAIN} ${NC_EXPL_MOD}/${RPROXY_VHOST_TEMPLATE} > ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp
RET_VAL=$?
if [ ! ${RET_VAL} -eq 0 ]; then
ERROR="Erreur lors de la création de la configuration du rproxy (1)"
@@ -171,7 +172,7 @@ function create_rproxy_conf
function create_backend_conf
{
fct_message "Création de la configuration du backend:" -color rose
sed -s ${REPLACE_DOMAIN} ${REMOTE_TEMPLATE_FILE} > ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp
sed -s ${REPLACE_DOMAIN} ${NC_EXPL_MOD}/${REMOTE_VHOST_TEMPLATE} > ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp
RET_VAL=$?
if [ ! ${RET_VAL} -eq 0 ]; then
ERROR="Erreur lors de la création de la configuration du backend (1)"
@@ -190,7 +191,7 @@ function create_backend_conf
fct_erreur 2
fi
fct_message "Installation de la configuration du backend sur ${backend_host}" -color rose
scp ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp ${HOST}:/tmp/${domain}.conf
scp ${NC_EXPL_TMP}/${domain}.conf_${SH_SESSION_ID}.tmp ${backend_host}:/tmp/${domain}.conf
RET_VAL=$?
if [ ! ${RET_VAL} -eq 0 ]; then
ERROR="Erreur lors de l'installation de la configuration du backend (1)"
@@ -203,14 +204,14 @@ function create_backend_conf
fct_erreur 2
fi
fct_message "Application des droits sur le fichier de configuration du backend"
ssh ${HOST} "sudo chown root: ${HTTPD_PATH}/${domain}.conf"
ssh ${backend_host} "sudo chown root: ${HTTPD_PATH}/${domain}.conf"
RET_VAL=$?
if [ ! ${RET_VAL} -eq 0 ]; then
ERROR="Erreur lors de l'application des droits sur la configuration du backend"
fct_erreur 2
fi
fct_message "Application des permissions sur le fichier de configuration du backend"
ssh ${HOST} "sudo chmod 644 ${HTTPD_PATH}/${domain}.conf"
ssh ${backend_host} "sudo chmod 644 ${HTTPD_PATH}/${domain}.conf"
RET_VAL=$?
if [ ! ${RET_VAL} -eq 0 ]; then
ERROR="Erreur lors de l'application des permissions sur la configuration du backend"