fix: troca bind mounts por volumes e ajuste busca git sites-ativos
This commit is contained in:
parent
54f8a4283b
commit
368855f2b0
55
.bashrc
55
.bashrc
|
|
@ -40,37 +40,64 @@ nginx_ativar() {
|
||||||
nginx_menu() {
|
nginx_menu() {
|
||||||
REPO_URL="https://git.itguys.com.br/joao.goncalves/NgixProxy_Pathfinder.git"
|
REPO_URL="https://git.itguys.com.br/joao.goncalves/NgixProxy_Pathfinder.git"
|
||||||
TEMP_DIR="/tmp/site_repo"
|
TEMP_DIR="/tmp/site_repo"
|
||||||
|
BRANCH="sites-ativos"
|
||||||
|
|
||||||
echo "🌐 Buscando lista de sites no repositório..."
|
echo "🌐 Conectando à branch [$BRANCH] do repositório..."
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf "$TEMP_DIR"
|
||||||
git clone --depth 1 -b sites-ativos "$REPO_URL" "$TEMP_DIR" &>/dev/null
|
git clone --depth 1 -b "$BRANCH" "$REPO_URL" "$TEMP_DIR" &>/dev/null
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "❌ Erro ao conectar ao repositório Git."
|
echo "❌ Erro ao conectar ao repositório Git ou branch não encontrada."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Lista arquivos .conf na pasta conf.d do repo
|
# Busca arquivos .conf no repositório (recursivamente para garantir)
|
||||||
SITES=($(ls "$TEMP_DIR/conf.d"/*.conf 2>/dev/null | xargs -n 1 basename))
|
echo "📂 Analisando arquivos disponíveis..."
|
||||||
|
FILES=($(find "$TEMP_DIR" -maxdepth 2 -name "*.conf" ! -name "nginx.conf"))
|
||||||
|
|
||||||
if [ ${#SITES[@]} -eq 0 ]; then
|
if [ ${#FILES[@]} -eq 0 ]; then
|
||||||
echo "⚠️ Nenhum arquivo de site (.conf) encontrado no repositório."
|
echo "⚠️ Nenhum arquivo de site (.conf) encontrado na branch $BRANCH."
|
||||||
|
rm -rf "$TEMP_DIR"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "--- Selecione o site para ativar ---"
|
echo ""
|
||||||
|
echo "--- Selecione o site para ATIVAR ---"
|
||||||
|
|
||||||
|
# Criar array com caminhos relativos para exibição
|
||||||
|
SITES=()
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
SITES+=($(basename "$f"))
|
||||||
|
done
|
||||||
|
|
||||||
PS3='Escolha o número (ou q para sair): '
|
PS3='Escolha o número (ou q para sair): '
|
||||||
select SITE in "${SITES[@]}"; do
|
select SITE_NAME in "${SITES[@]}"; do
|
||||||
if [[ "$REPLY" == "q" ]]; then
|
if [[ "$REPLY" == "q" ]]; then
|
||||||
echo "Saindo..."
|
echo "👋 Saindo..."
|
||||||
break
|
break
|
||||||
elif [[ -n "$SITE" ]]; then
|
elif [[ -n "$SITE_NAME" ]]; then
|
||||||
echo "📥 Baixando e ativando $SITE..."
|
# Acha o caminho original do arquivo selecionado
|
||||||
cp "$TEMP_DIR/conf.d/$SITE" /etc/nginx/conf.d/
|
SELECTED_FILE=""
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
if [[ "$(basename "$f")" == "$SITE_NAME" ]]; then
|
||||||
|
SELECTED_FILE="$f"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "📥 Ativando $SITE_NAME..."
|
||||||
|
cp "$SELECTED_FILE" /etc/nginx/conf.d/
|
||||||
|
|
||||||
|
# Tenta copiar o nginx.conf global se ele existir no repo e não houver no destino
|
||||||
|
if [ ! -f /etc/nginx/nginx.conf ] && [ -f "$TEMP_DIR/nginx.conf" ]; then
|
||||||
|
echo "⚙️ Instalando nginx.conf base do repositório..."
|
||||||
|
cp "$TEMP_DIR/nginx.conf" /etc/nginx/nginx.conf
|
||||||
|
fi
|
||||||
|
|
||||||
nginx_ativar
|
nginx_ativar
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "Opção inválida."
|
echo "❌ Opção inválida."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
# Personalização do Shell
|
# Personalização do Shell e Scripts
|
||||||
- ./.bashrc:/root/.bashrc:ro
|
- ./.bashrc:/root/.bashrc:ro
|
||||||
|
- ./.bashrc:/etc/bash.bashrc:ro
|
||||||
|
|
||||||
# Mapeamento para persistência e edição direta
|
# Volumes para Configurações (Persistência Interna)
|
||||||
- ../sites-ativos/nginx.conf:/etc/nginx/nginx.conf
|
- nginx_config:/etc/nginx/nginx.conf
|
||||||
- ../sites-ativos/conf.d:/etc/nginx/conf.d
|
- nginx_conf_d:/etc/nginx/conf.d
|
||||||
- ../sites-ativos/snippets:/etc/nginx/snippets
|
- nginx_snippets:/etc/nginx/snippets
|
||||||
|
|
||||||
# Persistent Data
|
# Persistent Data
|
||||||
- ./ssl:/etc/nginx/ssl
|
- ./ssl:/etc/nginx/ssl
|
||||||
|
|
@ -20,5 +21,8 @@ services:
|
||||||
- ./certbot:/etc/letsencrypt
|
- ./certbot:/etc/letsencrypt
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
nginx_config:
|
||||||
|
nginx_conf_d:
|
||||||
|
nginx_snippets:
|
||||||
nginx_logs:
|
nginx_logs:
|
||||||
nginx_cache:
|
nginx_cache:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue