59 lines
1.6 KiB
Bash
Executable File
59 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit on error
|
|
set -e
|
|
|
|
echo "Iniciando processo de build do DNSBlock Agent..."
|
|
|
|
# Ensure we are in the agent directory
|
|
cd "$(dirname "$0")"
|
|
|
|
# Check if python3-venv is installed
|
|
if ! dpkg -s python3-venv >/dev/null 2>&1; then
|
|
echo "Instalando python3-venv..."
|
|
sudo apt-get update && sudo apt-get install -y python3-venv
|
|
fi
|
|
|
|
# Create/Activate Build Venv
|
|
if [ ! -d "build_venv" ]; then
|
|
echo "Criando ambiente virtual de build..."
|
|
python3 -m venv build_venv
|
|
fi
|
|
|
|
source build_venv/bin/activate
|
|
|
|
# Install dependencies
|
|
echo "Instalando dependências..."
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install -r requirements.txt
|
|
python3 -m pip install pyinstaller
|
|
|
|
# Build
|
|
echo "Compilando binário..."
|
|
# --onefile: Create a single executable file
|
|
# --name: Name of the executable
|
|
# --clean: Clean PyInstaller cache
|
|
pyinstaller --onefile --name dnsblock-agent --clean main.py
|
|
|
|
# Organize Output
|
|
echo "Organizando saída..."
|
|
mkdir -p dist/
|
|
# PyInstaller puts the binary in dist/ by default, but let's ensure structure
|
|
# Copy config example
|
|
cp config.json.example dist/ 2>/dev/null || echo "Nota: config.json.example não encontrado para copiar."
|
|
|
|
# Copy distribution files
|
|
if [ -d "pkg" ]; then
|
|
cp pkg/install.sh dist/
|
|
cp pkg/dnsblock-agent.service dist/
|
|
cp pkg/README.md dist/
|
|
chmod +x dist/install.sh
|
|
echo "Arquivos de instalação copiados para dist/"
|
|
else
|
|
echo "Aviso: Diretório 'pkg' não encontrado. O instalador não será incluído."
|
|
fi
|
|
|
|
echo "Build concluído com sucesso!"
|
|
echo "O diretório 'dist' contém todos os arquivos necessários para distribuição."
|
|
echo "Para distribuir, compacte a pasta 'agent/dist'."
|