update setup and update scripts - create config from example, remove binary downloads
This commit is contained in:
62
setup
62
setup
@@ -42,14 +42,15 @@ log_debug() { log "[DBG]" "$GRAY" "$@"; }
|
|||||||
print_banner() {
|
print_banner() {
|
||||||
echo -e "${MAGENTA}${BOLD}"
|
echo -e "${MAGENTA}${BOLD}"
|
||||||
cat << "EOF"
|
cat << "EOF"
|
||||||
_____ _____ _
|
_____ _____ _
|
||||||
| |___ ___ _ _| __ |___| |_
|
| |___ ___ _ _| __ |___| |_
|
||||||
| | | | .'| | | | __ -| . | _|
|
| | | | .'| | | | __ -| . | _|
|
||||||
|_|_|_|__,|_|_|_ |_____|___|_|
|
|_|_|_|__,|_|_|_ |_____|___|_|
|
||||||
|___|
|
|___|
|
||||||
|
|
||||||
website: www.mlplovers.com.br/manybot
|
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
|
EOF
|
||||||
echo -e "${RESET}"
|
echo -e "${RESET}"
|
||||||
@@ -170,47 +171,20 @@ log_info "Instalando Chrome"
|
|||||||
npx puppeteer browsers install chrome
|
npx puppeteer browsers install chrome
|
||||||
|
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# Diretórios
|
# Configuração de exemplo
|
||||||
# ------------------------
|
# ------------------------
|
||||||
log_info "Preparando diretórios"
|
log_info "Verificando configuração"
|
||||||
mkdir -p bin
|
|
||||||
log_debug "Diretório bin garantido"
|
|
||||||
|
|
||||||
# ------------------------
|
if [[ ! -f "$SCRIPT_DIR/manybot.conf" ]]; then
|
||||||
# Arquivos por plataforma
|
if [[ -f "$SCRIPT_DIR/manybot.conf.example" ]]; then
|
||||||
# ------------------------
|
cp "$SCRIPT_DIR/manybot.conf.example" "$SCRIPT_DIR/manybot.conf"
|
||||||
log_info "Selecionando dependências binárias"
|
log_ok "Arquivo manybot.conf criado a partir do exemplo"
|
||||||
|
log_warn "Edite o manybot.conf para configurar seu bot antes de executar"
|
||||||
files=()
|
else
|
||||||
if [[ "$PLATFORM" == "win" ]]; then
|
log_warn "Arquivo manybot.conf.example não encontrado"
|
||||||
log_debug "Usando binários Windows"
|
fi
|
||||||
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"
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
log_debug "Usando binários Unix"
|
log_ok "manybot.conf já existe"
|
||||||
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"
|
|
||||||
)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_debug "Total de arquivos para baixar: ${#files[@]}"
|
log_ok "Setup concluído com sucesso.\nRode sempre na raíz: 'node src/main.js' para rodar o bot."
|
||||||
|
|
||||||
# ------------------------
|
|
||||||
# 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."
|
|
||||||
66
update
66
update
@@ -11,17 +11,7 @@ set -euo pipefail
|
|||||||
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
tmp_dir="$dir/tmp"
|
tmp_dir="$dir/tmp"
|
||||||
log_file="$dir/update.log"
|
log_file="$dir/update.log"
|
||||||
bin_dir="$dir/bin"
|
config_items=(".wwebjs_auth" ".wwebjs_cache")
|
||||||
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
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Logging
|
# Logging
|
||||||
@@ -52,7 +42,6 @@ trap cleanup_on_error ERR
|
|||||||
# Validações iniciais
|
# Validações iniciais
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
log "INFO" "Iniciando atualização do ManyBot..."
|
log "INFO" "Iniciando atualização do ManyBot..."
|
||||||
log "INFO" "Plataforma detectada: $PLATFORM"
|
|
||||||
|
|
||||||
# Verifica dependências obrigatórias
|
# Verifica dependências obrigatórias
|
||||||
for cmd in git npm; do
|
for cmd in git npm; do
|
||||||
@@ -125,59 +114,6 @@ fi
|
|||||||
log "INFO" "Instalando dependências Node..."
|
log "INFO" "Instalando dependências Node..."
|
||||||
npm ci --omit=dev 2>&1 | tee -a "$log_file"
|
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
|
# Restauração dos arquivos de configuração
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user