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() {
|
||||
REPO_URL="https://git.itguys.com.br/joao.goncalves/NgixProxy_Pathfinder.git"
|
||||
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"
|
||||
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
|
||||
echo "❌ Erro ao conectar ao repositório Git."
|
||||
echo "❌ Erro ao conectar ao repositório Git ou branch não encontrada."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Lista arquivos .conf na pasta conf.d do repo
|
||||
SITES=($(ls "$TEMP_DIR/conf.d"/*.conf 2>/dev/null | xargs -n 1 basename))
|
||||
# Busca arquivos .conf no repositório (recursivamente para garantir)
|
||||
echo "📂 Analisando arquivos disponíveis..."
|
||||
FILES=($(find "$TEMP_DIR" -maxdepth 2 -name "*.conf" ! -name "nginx.conf"))
|
||||
|
||||
if [ ${#SITES[@]} -eq 0 ]; then
|
||||
echo "⚠️ Nenhum arquivo de site (.conf) encontrado no repositório."
|
||||
if [ ${#FILES[@]} -eq 0 ]; then
|
||||
echo "⚠️ Nenhum arquivo de site (.conf) encontrado na branch $BRANCH."
|
||||
rm -rf "$TEMP_DIR"
|
||||
return 1
|
||||
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): '
|
||||
select SITE in "${SITES[@]}"; do
|
||||
select SITE_NAME in "${SITES[@]}"; do
|
||||
if [[ "$REPLY" == "q" ]]; then
|
||||
echo "Saindo..."
|
||||
echo "👋 Saindo..."
|
||||
break
|
||||
elif [[ -n "$SITE" ]]; then
|
||||
echo "📥 Baixando e ativando $SITE..."
|
||||
cp "$TEMP_DIR/conf.d/$SITE" /etc/nginx/conf.d/
|
||||
elif [[ -n "$SITE_NAME" ]]; then
|
||||
# Acha o caminho original do arquivo selecionado
|
||||
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
|
||||
break
|
||||
else
|
||||
echo "Opção inválida."
|
||||
echo "❌ Opção inválida."
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ services:
|
|||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
# Personalização do Shell
|
||||
# Personalização do Shell e Scripts
|
||||
- ./.bashrc:/root/.bashrc:ro
|
||||
- ./.bashrc:/etc/bash.bashrc:ro
|
||||
|
||||
# Mapeamento para persistência e edição direta
|
||||
- ../sites-ativos/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ../sites-ativos/conf.d:/etc/nginx/conf.d
|
||||
- ../sites-ativos/snippets:/etc/nginx/snippets
|
||||
# Volumes para Configurações (Persistência Interna)
|
||||
- nginx_config:/etc/nginx/nginx.conf
|
||||
- nginx_conf_d:/etc/nginx/conf.d
|
||||
- nginx_snippets:/etc/nginx/snippets
|
||||
|
||||
# Persistent Data
|
||||
- ./ssl:/etc/nginx/ssl
|
||||
|
|
@ -20,5 +21,8 @@ services:
|
|||
- ./certbot:/etc/letsencrypt
|
||||
|
||||
volumes:
|
||||
nginx_config:
|
||||
nginx_conf_d:
|
||||
nginx_snippets:
|
||||
nginx_logs:
|
||||
nginx_cache:
|
||||
|
|
|
|||
Loading…
Reference in New Issue