update setup and update scripts - create config from example, remove binary downloads

This commit is contained in:
synt-xerror
2026-04-21 11:18:19 -03:00
parent c12374f86c
commit 89b477888a
2 changed files with 19 additions and 109 deletions

62
setup
View File

@@ -42,14 +42,15 @@ log_debug() { log "[DBG]" "$GRAY" "$@"; }
print_banner() {
echo -e "${MAGENTA}${BOLD}"
cat << "EOF"
_____ _____ _
| |___ ___ _ _| __ |___| |_
_____ _____ _
| |___ ___ _ _| __ |___| |_
| | | | .'| | | | __ -| . | _|
|_|_|_|__,|_|_|_ |_____|___|_|
|___|
|_|_|_|__,|_|_|_ |_____|___|_|
|___|
website: www.mlplovers.com.br/manybot
repo: github.com/synt-xerror/manybot
repos: git.maneos.net/synt-xerror/manybot
codeberg.org/synt-xerror/manybot
EOF
echo -e "${RESET}"
@@ -170,47 +171,20 @@ log_info "Instalando Chrome"
npx puppeteer browsers install chrome
# ------------------------
# Diretórios
# Configuração de exemplo
# ------------------------
log_info "Preparando diretórios"
mkdir -p bin
log_debug "Diretório bin garantido"
log_info "Verificando configuração"
# ------------------------
# Arquivos por plataforma
# ------------------------
log_info "Selecionando dependências binárias"
files=()
if [[ "$PLATFORM" == "win" ]]; then
log_debug "Usando binários Windows"
files=(
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp.exe $SCRIPT_DIR/bin/yt-dlp.exe"
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg.exe $SCRIPT_DIR/bin/ffmpeg.exe"
)
if [[ ! -f "$SCRIPT_DIR/manybot.conf" ]]; then
if [[ -f "$SCRIPT_DIR/manybot.conf.example" ]]; then
cp "$SCRIPT_DIR/manybot.conf.example" "$SCRIPT_DIR/manybot.conf"
log_ok "Arquivo manybot.conf criado a partir do exemplo"
log_warn "Edite o manybot.conf para configurar seu bot antes de executar"
else
log_warn "Arquivo manybot.conf.example não encontrado"
fi
else
log_debug "Usando binários Unix"
files=(
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp $SCRIPT_DIR/bin/yt-dlp"
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg $SCRIPT_DIR/bin/ffmpeg"
)
log_ok "manybot.conf já existe"
fi
log_debug "Total de arquivos para baixar: ${#files[@]}"
# ------------------------
# Download
# ------------------------
for file in "${files[@]}"; do
url="${file%% *}"
dest="${file##* }"
log_info "Processando dependência"
download_file "$url" "$dest"
done
# permissões
log_info "Aplicando permissões de execução"
chmod -R +x $SCRIPT_DIR/bin/
log_ok "Setup concluído com sucesso.\nRode sempre na raíz: 'node src/main.js' (ou equivalente) para rodar o bot."
log_ok "Setup concluído com sucesso.\nRode sempre na raíz: 'node src/main.js' para rodar o bot."

66
update
View File

@@ -11,17 +11,7 @@ set -euo pipefail
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
tmp_dir="$dir/tmp"
log_file="$dir/update.log"
bin_dir="$dir/bin"
config_items=(".wwebjs_auth" ".wwebjs_cache" "node_modules")
# Detecta plataforma automaticamente se PLATFORM não estiver definido
: "${PLATFORM:=}"
if [[ -z "$PLATFORM" ]]; then
case "$(uname -s)" in
MINGW*|CYGWIN*|MSYS*) PLATFORM="win" ;;
*) PLATFORM="unix" ;;
esac
fi
config_items=(".wwebjs_auth" ".wwebjs_cache")
# ------------------------------------------------------------------------------
# Logging
@@ -52,7 +42,6 @@ trap cleanup_on_error ERR
# Validações iniciais
# ------------------------------------------------------------------------------
log "INFO" "Iniciando atualização do ManyBot..."
log "INFO" "Plataforma detectada: $PLATFORM"
# Verifica dependências obrigatórias
for cmd in git npm; do
@@ -125,59 +114,6 @@ fi
log "INFO" "Instalando dependências Node..."
npm ci --omit=dev 2>&1 | tee -a "$log_file"
# ------------------------------------------------------------------------------
# Download de binários por plataforma
# ------------------------------------------------------------------------------
# Cria o diretório de binários se não existir
mkdir -p "$bin_dir"
# Função de download com fallback curl → wget
download_file() {
local url="$1"
local dest="$2"
log "INFO" "Baixando: $url → $dest"
if command -v curl &>/dev/null; then
log "INFO" "Downloader: curl"
curl -fsSL "$url" -o "$dest"
elif command -v wget &>/dev/null; then
log "INFO" "Downloader: wget"
wget -q "$url" -O "$dest"
else
log "ERROR" "Nenhum downloader encontrado (curl ou wget são necessários)."
exit 1
fi
chmod +x "$dest" 2>/dev/null || true
log "INFO" "Arquivo pronto: $dest"
}
log "INFO" "Selecionando binários para plataforma: $PLATFORM"
if [[ "$PLATFORM" == "win" ]]; then
log "INFO" "Usando binários Windows"
files=(
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp.exe $bin_dir/yt-dlp.exe"
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg.exe $bin_dir/ffmpeg.exe"
)
else
log "INFO" "Usando binários Unix"
files=(
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp $bin_dir/yt-dlp"
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg $bin_dir/ffmpeg"
)
fi # <-- fi que estava faltando no original
log "INFO" "Total de arquivos para baixar: ${#files[@]}"
for file in "${files[@]}"; do
url="${file%% *}"
dest="${file##* }"
download_file "$url" "$dest"
done
# ------------------------------------------------------------------------------
# Restauração dos arquivos de configuração
# ------------------------------------------------------------------------------