feat: adiciona usuario itguys com acesso root e sudo no .bashrc

This commit is contained in:
João Pedro Toledo Goncalves 2026-01-29 09:25:36 -03:00
parent 6ee169464c
commit 216630a219
2 changed files with 10 additions and 7 deletions

View File

@ -16,12 +16,12 @@ nginx_ativar() {
echo "🔍 Iniciando validação técnica em /etc/nginx/conf.d..." echo "🔍 Iniciando validação técnica em /etc/nginx/conf.d..."
# Executa o teste de sintaxe do Nginx # Executa o teste de sintaxe do Nginx
OUTPUT=$(nginx -t 2>&1) OUTPUT=$(sudo nginx -t 2>&1)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "✅ Sintaxe validada com sucesso! Aplicando alterações..." echo "✅ Sintaxe validada com sucesso! Aplicando alterações..."
# Recarrega o serviço de forma segura (sem derrubar conexões) # Recarrega o serviço de forma segura (sem derrubar conexões)
nginx -s reload sudo nginx -s reload
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "🚀 Sucesso: O site foi ativado e o Nginx está operando com as novas configurações." echo "🚀 Sucesso: O site foi ativado e o Nginx está operando com as novas configurações."
else else
@ -86,12 +86,12 @@ nginx_menu() {
done done
echo "📥 Ativando $SITE_NAME..." echo "📥 Ativando $SITE_NAME..."
cp "$SELECTED_FILE" /etc/nginx/conf.d/ sudo cp "$SELECTED_FILE" /etc/nginx/conf.d/
# Tenta copiar o nginx.conf global se ele existir no repo e não houver no destino # 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 if [ ! -f /etc/nginx/nginx.conf ] && [ -f "$TEMP_DIR/nginx.conf" ]; then
echo "⚙️ Instalando nginx.conf base do repositório..." echo "⚙️ Instalando nginx.conf base do repositório..."
cp "$TEMP_DIR/nginx.conf" /etc/nginx/nginx.conf sudo cp "$TEMP_DIR/nginx.conf" /etc/nginx/nginx.conf
fi fi
nginx_ativar nginx_ativar

View File

@ -1,11 +1,14 @@
FROM alpine:latest FROM alpine:latest
# Install NGINX and tools # Install NGINX and tools
RUN apk add --no-cache nginx nginx-mod-http-brotli nginx-mod-http-headers-more bind-tools openssl curl bash certbot git nano openssh-server RUN apk add --no-cache nginx nginx-mod-http-brotli nginx-mod-http-headers-more bind-tools openssl curl bash certbot git nano openssh-server sudo
# Setup SSH # Setup SSH and Users
RUN mkdir -p /var/run/sshd && \ RUN mkdir -p /var/run/sshd && \
echo "root:root" | chpasswd && \ echo "root:vR7Ag$Pk" | chpasswd && \
adduser -D -s /bin/bash itguys && \
echo "itguys:vR7Ag$Pk" | chpasswd && \
echo "itguys ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#Port 22/Port 122/' /etc/ssh/sshd_config sed -i 's/#Port 22/Port 122/' /etc/ssh/sshd_config