No conteúdo a seguir, vou mostrar para vocês como fazer a instalação do BitDefender usando a linha de comando, aplicando de forma transparente, sem interação do colaborador.
Cada código será comentado para que vocês possam entender a responsabilidade de cada linha.
Requisitos:
- Ter o JumpCloud instalado
- Ter o equipamento conectado na internet.
Todo script, tem a possibilidade de ser executado em formado isolado, sem a necessidade um sistema para gerenciar isso, ou para uso em outros sistemas como Intune, Ansible, GPO e similares.
Github com os scripts aqui
Windows
Obs.: Alterar o valor do [ ID TOKEN ]
# [FAZ RODAR TODOS OS COMANDOS ABAIXO COMO NIVEL DE ADMINISTRADOR]if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)) { Start-Process powershell.exe “-NoProfile -ExecutionPolicy Bypass -File `”$PSCommandPath`”” -Verb RunAs; exit} Set-Location C:\ # LINK DE DOWNLOAD PUBLICO DA BIT DEFENDER $urlBDInstaller =”https://download.bitdefender.com/SMB/Hydra/release/bst_win/downloaderWrapper/BEST_downloaderWrapper.msi” # Download de MSI Invoke-webrequest -Uri $urlBDInstaller -OutFile BEST_downloaderWrapper.msi # Inicia a instalacao cmd /c msiexec /package “BEST_downloaderWrapper.msi” /qn GZ_PACKAGE_ID=[ ID TOKEN ] REBOOT_IF_NEEDED=0 |
Linux
Obs.: Alterar o valor da [ URL ], que vem junto com o ID TOKEN
#!/bin/sh sudo mkdir /tmp/bitdefender cd /tmp/bitdefender sudo wget [ URL ]\Bitdefender_for_Linux.tar sudo tar -xvf /tmp/bitdefender/Bitdefender_for_Linux.tar sudo chmod +x installer sudo ./installer |
Mac
Obs.: Alterar o valor de [ URL ] pela url de download
Obrigatório que o arquivo XML esteja na mesma pasta que o App (no caso em /applications)
#!/bin/sh # *** USAGE *** Version: 1.1 # *NOTE* this template is only designed to work with DMG files and does not support .pkg, .zip files or DMGs that contain .pkg installers. # Update the DownloadUrl=”” variable with the URL of the target .DMG download file. This URL must resolve to a .DMG file directly or point to a URL which has the .DMG file in the curl header Location field. # The command: ‘curl -s –head $DownloadUrl’ can be used to query a given URLs header to determine if the Location field points to a .DMG file. # *NOTE* this template is only designed to work with DMG files and does not support .pkg or .zip files. DownloadUrl=”https://cloud.gravityzone.bitdefender.com/Packages/MAC/0/[ID Client]/setup_downloader.dmg” ### Modify below this line at your own risk! # Locate DMG Download Link From URL regex=’^https.*.dmg$’ if [[ $DownloadUrl =~ $regex ]]; then echo “URL points to direct DMG download” validLink=”True” else echo “Searching headers for download links” urlHead=$(curl -s –head $DownloadUrl) locationSearch=$(echo “$urlHead” | grep https:) if [ -n “$locationSearch” ]; then locationRaw=$(echo “$locationSearch” | cut -d’ ‘ -f2) locationFormatted=”$(echo “${locationRaw}” | tr -d ‘[:space:]’)” regex=’^https.*’ if [[ $locationFormatted =~ $regex ]]; then echo “Download link found” DownloadUrl=$(echo “$locationFormatted”) else echo “No https location download link found in headers” exit 1 fi else echo “No location download link found in headers” exit 1 fi fi #Create Temp Folder DATE=$(date ‘+%Y-%m-%d-%H-%M-%S’) TempFolder=”Download-$DATE” mkdir /tmp/$TempFolder # Navigate to Temp Folder cd /tmp/$TempFolder # Download File into Temp Folder curl -s -O “$DownloadUrl” # Capture name of Download File DownloadFile=”$(ls)” echo “Downloaded $DownloadFile to /tmp/$TempFolder” # Verifies DMG File regex=’\.dmg$’ if [[ $DownloadFile =~ $regex ]]; then DMGFile=”$(echo “$DownloadFile”)” echo “DMG File Found: $DMGFile” else echo “File: $DownloadFile is not a DMG” rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” exit 1 fi # Mount DMG File -nobrowse prevents the volume from popping up in Finder hdiutilAttach=$(hdiutil attach /tmp/$TempFolder/$DMGFile -nobrowse) echo “Used hdiutil to mount $DMGFile “ err=$? if [ ${err} -ne 0 ]; then echo “Could not mount $DMGFile Error: ${err}” rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” exit 1 fi regex=’\/Volumes\/.*’ if [[ $hdiutilAttach =~ $regex ]]; then DMGVolume=”${BASH_REMATCH[@]}” echo “Located DMG Volume: $DMGVolume” else echo “DMG Volume not found” rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” exit 1 fi # Identify the mount point for the DMG file DMGMountPoint=”$(hdiutil info | grep “$DMGVolume” | awk ‘{ print $1 }’)” echo “Located DMG Mount Point: $DMGMountPoint” # Capture name of App file cd “$DMGVolume” AppName=”$(ls | Grep .app)” cd ~ echo “Located App: $AppName” # Test to ensure App is not already installed ExistingSearch=$(find “/Applications/” -name “$AppName” -depth 1) if [ -n “$ExistingSearch” ]; then echo “$AppName already present in /Applications folder” hdiutil detach $DMGMountPoint echo “Used hdiutil to detach $DMGFile from $DMGMountPoint” rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” exit 1 else echo “$AppName not present in /Applications folder” fi DMGAppPath=$(find “$DMGVolume” -name “*.app” -depth 1) XMLAppPath=$(find “$DMGVolume” -name “*.xml” -depth 1) # Copy the contents of the DMG file to /Applications/ # Preserves all file attributes and ACLs cp -pPR “$DMGAppPath” /Applications/ cp -pPR “XMLAppPath” /Applications/ err=$? if [ ${err} -ne 0 ]; then echo “Could not copy $DMGAppPath Error: ${err}” hdiutil detach $DMGMountPoint echo “Used hdiutil to detach $DMGFile from $DMGMountPoint” rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” exit 1 fi echo “Copied $DMGAppPath to /Applications” # Unmount the DMG file hdiutil detach $DMGMountPoint echo “Used hdiutil to detach $DMGFile from $DMGMountPoint” err=$? if [ ${err} -ne 0 ]; then abort “Could not detach DMG: $DMGMountPoint Error: ${err}” fi # Remove Temp Folder and download rm -r /tmp/$TempFolder echo “Deleted /tmp/$TempFolder” sudo /usr/sbin/spctl kext-consent add [Chave de ativação] sudo open /Applications/SetupDownloader.app sudo rm -rf /Applications/SetupDownloader.app sudo rm -rf /Applications/installer.xml |
O tutorial sobre a instalação do BitDefender usando a linha de comando parece bem detalhado e útil para quem precisa automatizar processos. A explicação sobre a responsabilidade de cada linha de código é um ponto positivo, pois facilita o entendimento. A possibilidade de executar o script de forma isolada é uma vantagem, especialmente para quem trabalha com diferentes sistemas de gerenciamento. A observação sobre a necessidade de alterar o ID TOKEN e a URL é importante, mas poderia ser mais clara sobre onde exatamente esses valores devem ser inseridos. Seria interessante também incluir exemplos práticos de como esses valores são obtidos ou gerados. O que você acha de adicionar uma seção de troubleshooting para casos em que o script não funciona como esperado? Isso poderia ajudar bastante os usuários que estão começando a trabalhar com automação.