terminal-switch-second
options=({% for project in projects %} "{{ project.name }} ({{ project.projectType.type }})" {% endfor %} "Autre" )
# check if a parameter with requested project have been asked
skippAsking=0
if [ ! -z "$PROJECT" ]
then
echo
echo "Vous avez demandé à installer le projet $PROJECT"
echo
# Verify if request project in list
if [[ " ${options[*]} " =~ " $PROJECT " ]]; then
opt="$PROJECT"
skippAsking=1
else
echo -e "\033[1;31mErreur\033[0m, le projet demandé '$PROJECT' est introuvable."
sleep 2
fi
fi
if [ $skippAsking = 0 ]
then
echo "Voici la liste des projets récents sur https://gitlab.cosavostra.com/"
echo
echo -e "\e[4mSélectionnez un projet que vous souhaitez installer.\e[0m"
PS3='Sélectionnez le numéro d''un site à installer: '
set -o posix
select opt in "${options[@]}"
do
case $opt in
{% for project in projects %}
"{{ project.name }} ({{ project.projectType.type }})")
break
;;
{% endfor %}
"Autre")
echo
echo "Les projets présents ici sont les projets ayant eut une activité récente sur gitlab."
echo "Contactez un administrateur si vous pensez qu'il manque un projet"
echo
exit 1
;;
*) echo "Réponse invalide $REPLY";;
esac
done
set +o posix
fi
# 0 if git root, 1 if git WP theme
projectGitLevel="0";
case $opt in
{% for project in projects %}
{% set projectDevPath = project.config(constant('App\\Service\\ProjectManager::CONFIG_PATH_DEV')) %}
"{{ project.name }} ({{ project.projectType.type }})")
projectName="{{ project.name }}"
projectShortName="{{ project.name|slug|lower }}"
projectType="{{ project.projectType.type }}"
{# Si le projet n'est pa défini, son chemin est vide ou invalide (<10 char) #}
{% if projectDevPath|length > 10 %}
projectDevPath="{{ project.config(constant('App\\Service\\ProjectManager::CONFIG_PATH_DEV')) }}/"
{% endif %}
{% if project.projectType.type == 'wordpress' %}
projectTheme="{{ project.config(constant('App\\Service\\ProjectManager::CONFIG_WP_PATH_THEME')) }}"
projectGitLevel="{{ project.config(constant('App\\Service\\ProjectManager::CONFIG_WP_GIT_ONLY_THEME')) }}"
{% endif %}
projectGit="{{ project.gitlabUrl }}"
{% set forcePhpVersion = project.config(constant('App\\Service\\ProjectManager::CONFIG_PHP_VERSION')) %}
{% if forcePhpVersion is not empty %}
projectPhpForceVersion="{{ forcePhpVersion }}"
{% endif %}
{% set forceNodeVersion = project.config(constant('App\\Service\\ProjectManager::CONFIG_NODE_VERSION')) %}
{% if forceNodeVersion is not empty %}
projectNodeForceVersion="{{ forceNodeVersion }}"
{% endif %}
;;
{% endfor %}
*) echo "Réponse invalide $REPLY";;
esac
if [ "$projectDevPath" == "" ]; then
echo
echo -e "\033[1;31m ERREUR : Le chemin du serveur de dev n'est pas (encore) configuré pour ce site. Contactez un administrateur \033[0m"
echo
exit 1
fi
terminal-switch-first
echo
echo "Installation de $opt en local"
echo