72 lines
1.6 KiB
Bash
Executable File
72 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Função para rodar comando mostrando saída
|
|
run_cmd() {
|
|
echo "+ $*"
|
|
"$@"
|
|
}
|
|
|
|
# Função para baixar arquivos se não existirem
|
|
download_file() {
|
|
local url="$1"
|
|
local dest="$2"
|
|
|
|
if [[ -f "$dest" ]]; then
|
|
echo "$dest já existe, pulando download."
|
|
return
|
|
fi
|
|
|
|
echo "Baixando $url → $dest"
|
|
|
|
if command -v curl >/dev/null 2>&1; then
|
|
curl -L "$url" -o "$dest"
|
|
elif command -v wget >/dev/null 2>&1; then
|
|
wget "$url" -O "$dest"
|
|
else
|
|
echo "Erro: curl ou wget são necessários para baixar arquivos."
|
|
exit 1
|
|
fi
|
|
|
|
chmod +x "$dest" 2>/dev/null || true
|
|
}
|
|
|
|
# Detecta plataforma
|
|
PLATFORM=""
|
|
case "$(uname -s)" in
|
|
Linux*) PLATFORM="linux";;
|
|
Darwin*) PLATFORM="mac";;
|
|
MINGW*|MSYS*|CYGWIN*) PLATFORM="win";;
|
|
*) PLATFORM="unknown";;
|
|
esac
|
|
|
|
echo "Plataforma detectada: $PLATFORM"
|
|
|
|
# Setup npm
|
|
run_cmd npm ci
|
|
|
|
# Cria pasta bin
|
|
mkdir -p bin
|
|
|
|
# Arquivos por plataforma
|
|
files=()
|
|
if [[ "$PLATFORM" == "win" ]]; then
|
|
files=(
|
|
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp.exe bin/yt-dlp.exe"
|
|
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg.exe bin/ffmpeg.exe"
|
|
)
|
|
else
|
|
files=(
|
|
"https://github.com/synt-xerror/manybot/releases/download/dependencies/yt-dlp bin/yt-dlp"
|
|
"https://github.com/synt-xerror/manybot/releases/download/dependencies/ffmpeg bin/ffmpeg"
|
|
)
|
|
fi
|
|
|
|
# Baixa todos os arquivos
|
|
for file in "${files[@]}"; do
|
|
url="${file%% *}"
|
|
dest="${file##* }"
|
|
download_file "$url" "$dest"
|
|
done
|
|
|
|
echo "Setup concluído."42 |