#!/bin/bash
#
#
# COSAVOSTRA
#
# Installation/Mise à jour automatique de sites.
#
# Veuillez executer la commande :
# bash <(curl -s '{{ absolute_url(path('install')) }}')
#
{# todo : set vhost first ! #}
{# todo : install mailhog #}
{# todo : set custom PHP version #}
{# todo : verify git status on composer.json check #}
{# todo : install phpmyadmin with mysql #}
{# todo : verify WP & SF path access rights (wp-content / var) #}
{# todo : ask database & username #}
{# todo : set custom node version #}
{# todo : rename script host like https://install.cosavostra.com #}
{# todo : verify display in different terminal 'resolutions' #}
{# todo : rsync with --omit-dir-times to prevent errors message ? #}
{# todo : php7.4 repository need to be added for ubuntu 21.10 #}
{# todo : notice if alias not present in . bashrc for current command . named install ? #}
{# todo : set facl access rights #}
clear
{{ include('install/config.sh.twig') }}
{{ include('install/functions.sh.twig') }}
{{ include('install/logo.sh.twig') -}}
{{ include('install/process.params.sh.twig') }}
echo
echo -e "\033[1mInstallation/Mise à jour automatique d'un projet depuis le serveur de DEV :\033[0m"
echo
# make some initials checks.
{{ include('install/process.checks.sh.twig') }}
# test wsl version
{{ include('install/requirement.virtual.sh.twig') }}
# test root access
{{ include('install/requirement.root.sh.twig') }}
# select project.
{{ include('install/projects.list.sh.twig') }}
# install requirements
{{ include('install/requirement.common.sh.twig') }}
{{ include('install/requirement.apache2.sh.twig') }}
{{ include('install/requirement.tools.sh.twig') }}
{{ include('install/requirement.php.sh.twig') }}
{{ include('install/requirement.node.sh.twig') }}
# verify mysql
{{ include('install/requirement.mysql.sh.twig') }}
# verify SSH access
{{ include('install/requirement.ssh.sh.twig') }}
# verify gitlab access
{{ include('install/requirement.gitlab.sh.twig') }}
# ask for final host
{{ include('install/projects.host.sh.twig') }}
# check project requirements.
case $projectType in
"wordpress")
{{ include('install/requirement.wordpress.sh.twig') }}
;;
"symfony")
{{ include('install/requirement.symfony.sh.twig') }}
;;
*)
# nothing special
;;
esac
# check source path
{{ include('install/requirement.sourcepath.sh.twig') }}
# verify destination path
{{ include('install/process.destpath.sh.twig') }}
# verify git access.
{{ include('install/process.git.access.sh.twig') }}
# create vhost
{{ include('install/process.vhost.sh.twig') }}
# import project
case $projectType in
"wordpress")
{{ include('install/process.import.wordpress.sh.twig') }}
;;
"symfony")
{{ include('install/process.import.symfony.sh.twig') }}
;;
"react")
{{ include('install/process.import.react.sh.twig') }}
;;
*)
echo
echo "##Erreur le type de projet ($projectType) n'est pas (encore) pris en compte. "
echo "Contactez un administrateur pour plus d'infos. "
exit 1
;;
esac
# GIT reinitialisation
{{ include('install/process.import.git.sh.twig') }}
# get projects content
case $projectType in
"wordpress")
{{ include('install/process.import.BDD.sh.twig') }}
{{ include('install/process.config.wordpress.sh.twig') }}
;;
"symfony")
{{ include('install/process.import.BDD.sh.twig') }}
{{ include('install/process.config.symfony.sh.twig') }}
;;
"react")
{# nothing to import. #}
;;
*)
echo "Erreur le type de projet ($projectType) n'est pas (encore) pris en compte. "
echo "Contactez un administrateur pour plus d'infos. "
exit 1
;;
esac
{{ include('install/process.finalise.sh.twig') }}
echo
echo
echo "Site disponible vers : http://${siteDomain}"
{{ include('install/logo.sh.twig') }}
echo
# detect if we are in a virtual machine with 'systemd-detect-virt'
# display aditionnal informations
{#{{ include('install/info.virtualmachine.sh.twig') }}#}
# open localwebsite page
xdg-open http://${siteDomain} >/dev/null 2>&1