mirror of
https://github.com/manualdousuario/marreta.git
synced 2025-09-04 03:30:43 +00:00
automatização do registro de environments
This commit is contained in:
parent
5096aacb83
commit
891c6df97a
1 changed files with 27 additions and 72 deletions
|
@ -14,99 +14,52 @@
|
||||||
# - Inicia e verifica serviços (PHP-FPM e Nginx)
|
# - Inicia e verifica serviços (PHP-FPM e Nginx)
|
||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
# Output colors
|
# Cores de saída / Output colors
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color / Sem Cor
|
||||||
|
|
||||||
# Success log function
|
# Função de log de sucesso / Success log function
|
||||||
log_success() {
|
log_success() {
|
||||||
echo -e "${GREEN}[✓] $1${NC}"
|
echo -e "${GREEN}[✓] $1${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Error log function
|
# Função de log de erro / Error log function
|
||||||
log_error() {
|
log_error() {
|
||||||
echo -e "${RED}[✗] $1${NC}"
|
echo -e "${RED}[✗] $1${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Info log function
|
# Função de log de informação / Info log function
|
||||||
log_info() {
|
log_info() {
|
||||||
echo -e "${YELLOW}[i] $1${NC}"
|
echo -e "${YELLOW}[i] $1${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "\n${YELLOW}=== Starting Marreta ===${NC}\n"
|
echo -e "\n${YELLOW}=== Starting Marreta ===${NC}\n"
|
||||||
|
|
||||||
# === Environment Variables Configuration ===
|
# === Configuração das Variáveis de Ambiente / Environment Variables Configuration ===
|
||||||
log_info "Configuring environment variables..."
|
log_info "Configuring environment variables..."
|
||||||
|
|
||||||
if [ -n "${SITE_NAME}" ]; then
|
# Arquivo de ambiente (.env) / Env file (.env)
|
||||||
echo "SITE_NAME=\"${SITE_NAME}\"" >> /app/.env
|
ENV_FILE="/app/.env"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${SITE_DESCRIPTION}" ]; then
|
# Limpa o arquivo de ambiente / Clean Env file
|
||||||
echo "SITE_DESCRIPTION=\"${SITE_DESCRIPTION}\"" >> /app/.env
|
> "$ENV_FILE"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${SITE_URL}" ]; then
|
while IFS='=' read -r key value; do
|
||||||
echo "SITE_URL=${SITE_URL}" >> /app/.env
|
# If value contains spaces and is not already quoted, add quotes
|
||||||
fi
|
# Se o valor contém espaços e não está entre aspas, adiciona aspas
|
||||||
|
if [[ "$value" =~ \ ]] && ! [[ "$value" =~ ^\".*\"$ ]]; then
|
||||||
|
value="\"$value\""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${LANGUAGE}" ]; then
|
echo "$key=$value" >> "$ENV_FILE"
|
||||||
echo "LANGUAGE=${LANGUAGE}" >> /app/.env
|
done < <(env)
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${DNS_SERVERS}" ]; then
|
|
||||||
echo "DNS_SERVERS=${DNS_SERVERS}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
# S3 Settings
|
|
||||||
if [ -n "${S3_CACHE_ENABLED}" ]; then
|
|
||||||
echo "S3_CACHE_ENABLED=${S3_CACHE_ENABLED}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_ACCESS_KEY}" ]; then
|
|
||||||
echo "S3_ACCESS_KEY=${S3_ACCESS_KEY}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_SECRET_KEY}" ]; then
|
|
||||||
echo "S3_SECRET_KEY=${S3_SECRET_KEY}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_BUCKET}" ]; then
|
|
||||||
echo "S3_BUCKET=${S3_BUCKET}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_REGION}" ]; then
|
|
||||||
echo "S3_REGION=${S3_REGION}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_FOLDER}" ]; then
|
|
||||||
echo "S3_FOLDER=${S3_FOLDER}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_ACL}" ]; then
|
|
||||||
echo "S3_ACL=${S3_ACL}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3_ENDPOINT}" ]; then
|
|
||||||
echo "S3_ENDPOINT=${S3_ENDPOINT}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Selenium Settings
|
|
||||||
if [ -n "${SELENIUM_HOST}" ]; then
|
|
||||||
echo "SELENIUM_HOST=${SELENIUM_HOST}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Hawk.so Settings
|
|
||||||
if [ -n "${HAWK_TOKEN}" ]; then
|
|
||||||
echo "HAWK_TOKEN=${HAWK_TOKEN}" >> /app/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_success "Environment variables configured"
|
log_success "Environment variables configured"
|
||||||
|
|
||||||
# === Permissions Adjustment ===
|
# === Ajuste de Permissões / Permissions Adjustment ===
|
||||||
log_info "Adjusting directory permissions..."
|
log_info "Adjusting directory permissions..."
|
||||||
|
|
||||||
chown -R www-data:www-data /app/cache /app/logs
|
chown -R www-data:www-data /app/cache /app/logs
|
||||||
|
@ -114,7 +67,7 @@ chmod -R 775 /app/cache /app/logs
|
||||||
|
|
||||||
log_success "Permissions adjusted"
|
log_success "Permissions adjusted"
|
||||||
|
|
||||||
# === Service Check Functions ===
|
# === Funções de Verificação de Serviços / Service Check Functions ===
|
||||||
check_nginx() {
|
check_nginx() {
|
||||||
if ! pgrep nginx > /dev/null; then
|
if ! pgrep nginx > /dev/null; then
|
||||||
log_error "Failed to start Nginx"
|
log_error "Failed to start Nginx"
|
||||||
|
@ -131,10 +84,10 @@ check_php_fpm() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# === Services Initialization ===
|
# === Inicialização dos Serviços / Services Initialization ===
|
||||||
echo -e "\n${YELLOW}=== Starting services ===${NC}\n"
|
echo -e "\n${YELLOW}=== Starting services ===${NC}\n"
|
||||||
|
|
||||||
# PHP-FPM Directory
|
# Diretório do PHP-FPM / PHP-FPM Directory
|
||||||
if [ ! -d /var/run/php ]; then
|
if [ ! -d /var/run/php ]; then
|
||||||
log_info "Creating PHP-FPM directory..."
|
log_info "Creating PHP-FPM directory..."
|
||||||
mkdir -p /var/run/php
|
mkdir -p /var/run/php
|
||||||
|
@ -142,13 +95,13 @@ if [ ! -d /var/run/php ]; then
|
||||||
log_success "PHP-FPM directory created"
|
log_success "PHP-FPM directory created"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Starting PHP-FPM
|
# Iniciando PHP-FPM / Starting PHP-FPM
|
||||||
log_info "Starting PHP-FPM..."
|
log_info "Starting PHP-FPM..."
|
||||||
php-fpm &
|
php-fpm &
|
||||||
sleep 3
|
sleep 3
|
||||||
check_php_fpm
|
check_php_fpm
|
||||||
|
|
||||||
# Checking Nginx configuration
|
# Verificando configuração do Nginx / Checking Nginx configuration
|
||||||
log_info "Checking Nginx configuration..."
|
log_info "Checking Nginx configuration..."
|
||||||
nginx -t
|
nginx -t
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
@ -157,7 +110,7 @@ else
|
||||||
log_success "Valid Nginx configuration"
|
log_success "Valid Nginx configuration"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Starting Nginx
|
# Iniciando Nginx / Starting Nginx
|
||||||
log_info "Starting Nginx..."
|
log_info "Starting Nginx..."
|
||||||
nginx -g "daemon off;" &
|
nginx -g "daemon off;" &
|
||||||
sleep 3
|
sleep 3
|
||||||
|
@ -165,6 +118,8 @@ check_nginx
|
||||||
|
|
||||||
echo -e "\n${GREEN}=== Marreta initialized ===${NC}\n"
|
echo -e "\n${GREEN}=== Marreta initialized ===${NC}\n"
|
||||||
|
|
||||||
|
# Aguarda qualquer processo terminar / Wait for any process to exit
|
||||||
wait -n
|
wait -n
|
||||||
|
|
||||||
|
# Sai com o status do processo que terminou primeiro / Exit with status of process that exited first
|
||||||
exit $?
|
exit $?
|
||||||
|
|
Loading…
Add table
Reference in a new issue