Last active
May 15, 2023 21:18
-
-
Save richardsondev/6d69277efd4021edfaec9acf206e3ec1 to your computer and use it in GitHub Desktop.
Azure ArchiveTeam Warrior Container Setup - creates multiple ArchiveTeam Warrior Docker containers hosted in Azure pointed at the project you specify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Azure ArchiveTeam Warrior Container Setup | |
# Creates multiple ArchiveTeam Warrior Docker containers | |
# hosted in Azure pointed at the project you specify. | |
# How to use: | |
# 1. Change the settings below to match your environment. | |
# 2. In Azure Portal, open the "Cloud Shell" in Powershell mode (or use Powershell locally). | |
# 3. Upload this file to Cloud Shell and execute it. | |
# 4. Access the Web UI with http://<prefix>-<machine_id>.<azure_region>.azurecontainer.io:8001/ | |
# Mass delete: | |
# Get-AzSubscription -SubscriptionName "" | Set-AzContext; Get-AzResourceGroup -Name archiveteam-* | Remove-AzResourceGroup -Force | |
#------------------ | |
# Start user config | |
#------------------ | |
# Archive Warrior config | |
$coreProject = "auto" # The Archive Team project to invoke (consider 'auto') | |
$downloader = "" # Archive team leaderboard name (default is 'AzureUser') | |
$httpuser = "" # The HTTP auth username for the warrior (default is random) | |
$httppass = "" # The HTTP auth password for the warrior (default is random) | |
$concurrent = 6 # concurrent threads (6 is the max in the container) | |
# Azure settings | |
$subscription = "YourSubscriptionName" # Your Azure subscription name | |
$instances = @( | |
@{ | |
ShortName = "$coreProject-wcus" | |
Location = "WestCentralUS" | |
MachineCount = 5 | |
Project = $coreProject | |
}, | |
@{ | |
ShortName = "$coreProject-fr" | |
Location = "FranceCentral" | |
MachineCount = 5 | |
Project = $coreProject | |
} | |
) | |
#------------------ | |
# End user config | |
#------------------ | |
function randomString() {return -join ((65..90) + (97..122) | Get-Random -Count (Get-Random -Minimum 18 -Maximum 25) | % {[char]$_}) } | |
# Set defaults | |
if ([string]::IsNullOrWhitespace($downloader)) { | |
$downloader = "AzureUser" | |
} | |
if ([string]::IsNullOrWhitespace($httpuser)) { | |
$httpuser = (randomString) | |
} | |
if ([string]::IsNullOrWhitespace($httppass)) { | |
$httppass = (randomString) | |
} | |
# Select the right subscription | |
az account set --subscription $subscription | |
# Start processing | |
foreach ($instance in $instances) | |
{ | |
# Azure settings | |
$resourceGroup = "archiveteam-" + $instance.ShortName # The resource group to deploy containers in | |
$azureLocation = $instance.Location # The Azure location to deploy containers in | |
# Machine info | |
$machineIdNumberStart = 1 # The base id number for this execution (default: 1) | |
$machineCount = $instance.MachineCount # The amount of containers to deploy in thie resource group | |
# Archive Warrior config | |
$prefix = "archiveteam-" + $instance.ShortName # A unique prefix name for your container (use your username) | |
$project = $instance.Project # Archive team project to operate on (default: auto) | |
# Create RG if needed | |
az group create --location $azureLocation --name $resourceGroup | |
$upperMachineId = $machineIdNumberStart+$machineCount | |
for (($i = $machineIdNumberStart); $i -lt $upperMachineId; $i++) | |
{ | |
$port = 8001 | |
$id = $i.ToString().PadLeft($upperMachineId.ToString().Length,"0") | |
$rand = -join ((97..122) | Get-Random -Count 5 | % {[char]$_}) # random value to prevent overlap with other subscriptions | |
$containerName = "$prefix-$id-$rand" | |
az container create --resource-group $resourceGroup --name $containerName --image atdr.meo.ws/archiveteam/warrior-dockerfile --dns-name-label $containerName --ports $port --env DOWNLOADER=$downloader SELECTED_PROJECT=$project CONCURRENT_ITEMS=$concurrent SHARED_RSYNC_THREADS=10 HTTP_USERNAME=$httpuser HTTP_PASSWORD=$httppass --restart-policy Always --memory 0.5 --cpu 1 | |
} | |
} |
Hey, also thanks....script worked perfectly fine!
I have a question. Do you have a script for the same outcome, just for B1ls VMs? It's way cheaper and would suite the case perfectly I guess.
Hey folks, glad to hear it worked well for you!
That is correct that this approach is not the most cost effective. I use it to deplete my free credits every month (it can be automatically run with a runbook and another would tear down the containers).
It appears that another user on Reddit has created a script that uses the cheaper B1ls VMs :) https://old.reddit.com/r/DataHoarder/comments/13hex6p/archiveteam_has_saved_760_million_imgur_files_but/jk91ef1/?context=4 (direct link] I hope this will work for you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing this script! Works perfectly. I didnt even knew about "container instances". Previously I manually created debian VMs, installed Docker and opened the 8001 port 😆