Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 1ef090e

Browse files
Razikusdenysbutenkovtinkererrdemachkovych
committedMar 6, 2022
Improve docs with latest changes (#134)
* Add varios scripts to improve ansible workflow * Fix text * Fix var * Update settings * Changed references of 0.0.x to master * Start docker containers on reboot (#128) * Changed script to down and timeout only for one second, added restart always * Added tool terraform-do-uashield (#122) * added tool terraform-do-uashield * added readme * Changed script to restart always and don't wait too much on docker compose down Co-authored-by: adam <adam@razniewski.eu> * Create README.MD Co-authored-by: Denys Butenko <ua13dark@gmail.com> Co-authored-by: vtinkerer <72277127+vtinkerer@users.noreply.github.com> Co-authored-by: rdemachkovych <demachkovych@gmail.com>
1 parent 4b0184b commit 1ef090e

23 files changed

+256
-24
lines changed
 

‎Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ COPY tsconfig.headless.json ./tsconfig.json
1414

1515
RUN yarn build:headless
1616

17+
18+
# Optimizes the build, so no NODE_MODULES included in image. Don't remove this
1719
FROM node:16.9.0-alpine
1820

1921
WORKDIR /code

‎README-en.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Targets being attacked are changed automatically and are downloaded from the con
4545
Or use [pre-built image](https://github.com/opengs/uashield/pkgs/container/uashield):
4646

4747
```bash
48-
docker run -d ghcr.io/opengs/uashield:0.0.x 512 true
48+
docker run -d ghcr.io/opengs/uashield:master 512 true
4949
```
5050

5151
## Docker-compose version
@@ -67,7 +67,7 @@ docker run -d ghcr.io/opengs/uashield:0.0.x 512 true
6767

6868
## Deploy with Play With Docker - free instance for 4 hours
6969

70-
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/opengs/uashield/0.0.x/pwd-docker-compose.yml)
70+
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/opengs/uashield/master/pwd-docker-compose.yml)
7171

7272
## Donations
7373
Donations will be used to fund our operations:

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
Або за допомогою вже [зібраного імежду](https://github.com/opengs/uashield/pkgs/container/uashield):
4646

4747
```bash
48-
docker run -d ghcr.io/opengs/uashield:0.0.x 512 true
48+
docker run -d ghcr.io/opengs/uashield:master 512 true
4949
```
5050

5151
## Docker-compose версія
@@ -67,7 +67,7 @@ docker run -d ghcr.io/opengs/uashield:0.0.x 512 true
6767

6868
## Деплой на Play With Docker - безкоштовний інстанс на 4 години
6969

70-
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/opengs/uashield/0.0.x/pwd-docker-compose.yml)
70+
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/opengs/uashield/master/pwd-docker-compose.yml)
7171

7272
## Пожертвування
7373
Пожертвування будуть використовуватися виключно для цілей програми:

‎pwd-docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
version: '3'
22
services:
33
uashield:
4-
image: ghcr.io/opengs/uashield:0.0.x
4+
image: ghcr.io/opengs/uashield:master
55
restart: always
66
environment:
7-
WORKERS: '512'
7+
WORKERS: '256'
88
USEPROXY: 'false'
99
deploy:
10-
replicas: 6
10+
replicas: 3
1111

‎tools/README.MD

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# COMMUNITY CREATED
2+
3+
Fortunately or unfortunately these tools are created by community.
4+
5+
They can be not up to date, but we are trying our best.
6+
7+
If you see any issue - make an issue or contact us via Discord.

‎tools/ansible/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Optional step, can be skipped
5252

5353
ansible-playbook -u root stats.yaml -i hosts
5454

55+
### 8. Update to the latest version and restart containers
56+
57+
ansible-playbook -u root update.yaml -i hosts
58+
5559
## UA
5660
### 1. Інсталюйте ansible на свою машину
5761
#### Mac OS
@@ -97,3 +101,7 @@ ssh-agent bash -c "ssh-add /path/to/keys/*.pem"
97101
### 7. Перевірка статистики успішних запитів
98102

99103
ansible-playbook -u root stats.yaml -i hosts
104+
105+
### 8. Оновити до останньої версії та перезавантажити
106+
107+
ansible-playbook -u root update.yaml -i hosts

‎tools/ansible/ansible.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[defaults]
2+
deprecation_warnings=False
3+
host_key_checking=False
4+
strategy=linear ; default
5+
; strategy=free ; do not wait for complete all hosts

‎tools/ansible/create-vm.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Usage example
3+
# ./create-vm.sh eastus2
4+
5+
# Variables
6+
INPUT=$1
7+
LOCATION="${INPUT:-'norwayeast'}"
8+
RESOURCE_GROUP='STOPWAR'
9+
USER='azureuser'
10+
IMAGE='UbuntuLTS'
11+
for i in {1..4}
12+
do
13+
NAME=uashield-$LOCATION-unit-$i
14+
echo "$NAME : Initializing vm..."
15+
az vm create --admin-user=$USER --location=$LOCATION --name $NAME --resource-group $RESOURCE_GROUP --image $IMAGE --generate-ssh-keys
16+
done
17+
18+
bash ./update-hosts.sh
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- name: Get stats
2-
shell: echo $(docker logs uashield | grep '| 200' -c)
2+
shell: echo $(docker ps -q | xargs -L 1 docker logs | grep '| 200' -c)
33
register: echo_content
44

55
- debug:
6-
msg: "Hits {{ echo_content.stdout }} requests."
6+
msg: "Hit {{ echo_content.stdout }} requests."
+33-11
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
---
2-
- name: Clone uashield repo
2+
- name: Check if repo is exist
3+
stat:
4+
path: "{{uashield_work_dir}}"
5+
failed_when: false
6+
changed_when: false
7+
register: check_uashield_repo
8+
9+
- name: Clone repo
310
git:
411
repo: "{{uashield_git_url}}"
512
dest: "{{uashield_work_dir}}"
613
accept_hostkey: true
714
force: true
815
version: "master"
16+
when: not check_uashield_repo.stat.exists
917

10-
- name: Stop all containers
11-
shell: "docker-compose down"
18+
- name: Pull Latest Changes
19+
shell: "git pull"
1220
args:
1321
chdir: "{{uashield_work_dir}}"
22+
when: check_uashield_repo.stat.exists
23+
24+
- name: Get Running Docker Containers
25+
shell: "docker ps -aq"
26+
register: docker_info
27+
28+
- name: Stop Running Docker Containers
29+
shell: "docker stop $(docker ps -aq)"
30+
when: docker_info.stdout
31+
32+
- name: Remove Docker Containers
33+
shell: "docker rm $(docker ps -aq)"
34+
when: docker_info.stdout
1435

15-
- name: Remove old uashield images
36+
- name: Remove Old Docker Image
1637
shell: "docker rmi -f uashield"
1738

18-
- name: Run uashield
19-
shell: "docker-compose up -d"
39+
- name: Build Docker Image
40+
shell: "docker build . -t uashield"
2041
args:
2142
chdir: "{{uashield_work_dir}}"
2243

23-
- name: Check docker started
24-
shell: "docker ps"
25-
args:
26-
chdir: "{{uashield_work_dir}}"
44+
- name: Run Instance
45+
shell: "docker run -d uashield {{ uashield_threads }} {{ uashield_proxy }}"
46+
47+
- name: Check Docker is started
48+
command: "docker ps"
2749
register: output
2850

2951
- ansible.builtin.debug:
30-
var: output
52+
var: output.stdout_lines

‎tools/ansible/stats.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
- hosts: servers
3+
strategy: linear
4+
gather_facts: no
35
become: yes
46
become_user: root
57
vars_files:

‎tools/ansible/update-hosts.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
PUBLIC_IP_ADDRESSES="$(az vm list-ip-addresses --query '[*].virtualMachine.network.publicIpAddresses[0].ipAddress' | sed '1d;$d' | cut -d'"' -f2)"
4+
for IP in $PUBLIC_IP_ADDRESSES
5+
do
6+
EXIST="$(cat hosts | awk '{print $1}' | grep $IP)"
7+
if [ "$EXIST" == "$IP" ]
8+
then
9+
echo "[Skipping] $IP already exist"
10+
else
11+
echo $IP >> hosts
12+
echo "[Changed] $IP is added to hosts"
13+
fi
14+
done

‎tools/ansible/update.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- hosts: servers
3+
become: yes
4+
become_user: root
5+
vars_files:
6+
- vars/vars.yaml
7+
roles:
8+
- uashield
9+
handlers:
10+
- include: handlers/main.yml

‎tools/ansible/vars/vars.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ docker_pip_executable: pip3
1212

1313
uashield_git_url: "https://github.com/opengs/uashield"
1414
uashield_work_dir: /root/uashield/
15+
uashield_threads: 2500
16+
uashield_proxy: true

‎tools/azure/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PLEASE SHARE WITH YOUR FRIENDS AND ANYONE WHO WANTS TO HELP BUT DOESN&#39;T KNOW
3030
![](https://github.com/opengs/uashield/blob/master/tools/azure/images/7.jpg)
3131
![](https://github.com/opengs/uashield/blob/master/tools/azure/images/8.jpg)
3232

33-
8. Go to &quot;Advanced&quot; tab (above) and paste the script [https://github.com/opengs/uashield/blob/0.0.x/tools/azure/azure-custom-data-script.sh](https://github.com/opengs/uashield/blob/0.0.x/tools/azure/azure-custom-data-script.sh) (just copy it as a text) to &quot;Custom data&quot;.
33+
8. Go to &quot;Advanced&quot; tab (above) and paste the script [https://github.com/opengs/uashield/blob/master/tools/azure/azure-custom-data-script.sh](https://github.com/opengs/uashield/blob/master/tools/azure/azure-custom-data-script.sh) (just copy it as a text) to &quot;Custom data&quot;.
3434
![](https://github.com/opengs/uashield/blob/master/tools/azure/images/9.jpg)
3535
9. Go to &quot;Disk&quot; tab and change &quot;OS disk type&quot; from &quot;Premium SSD&quot; to &quot;Standart SSD&quot;.
3636
![](https://github.com/opengs/uashield/blob/master/tools/azure/images/10.jpg)

‎tools/azure/azure-custom-data-script.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ version: \"3.3\"
2222
services:
2323
worker:
2424
image: ghcr.io/opengs/uashield:latest
25+
restart: always
2526
command:
2627
- \"7500\"
2728
- \"true\"" >> /home/docker-compose.yaml
@@ -32,5 +33,8 @@ cd /home/
3233

3334
sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)
3435

35-
sudo echo "*/30 * * * * cd /home/ && sudo docker-compose down && sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)" >> /home/cronjob
36+
sudo echo "*/30 * * * * cd /home/ && sudo docker-compose down -t 1 && sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)" >> /home/cronjob
37+
38+
# restart:always should do the job to run container on startup, but the hard restart is good here to avoid problems
39+
sudo echo "@reboot cd /home/ && sudo docker-compose down -t 1 && sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)" >> /home/cronjob
3640
crontab /home/cronjob

‎tools/helm/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ helm upgrade --install \
3333
| fullnameOverride | string | `""` | |
3434
| image.pullPolicy | string | `"IfNotPresent"` | |
3535
| image.repository | string | `"ghcr.io/opengs/uashield"` | |
36-
| image.tag | string | `"0.0.x"` | |
36+
| image.tag | string | `"master"` | |
3737
| imagePullSecrets | list | `[]` | |
3838
| nameOverride | string | `""` | |
3939
| nodeSelector | object | `{}` | |

‎tools/helm/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ image:
1515
repository: ghcr.io/opengs/uashield
1616
pullPolicy: IfNotPresent
1717
# We can find a tag here: https://github.com/opengs/uashield/pkgs/container/uashield
18-
tag: "0.0.x"
18+
tag: "master"
1919

2020
resources:
2121
# We usually recommend not to specify default resources and to leave this as a conscious

‎tools/terraform-do-uashield/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[![DigitalOcean Referral Badge](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=4e29ef6429c9&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)
2+
3+
[Get $100 to try DigitalOcean, link for sing in above](https://try.digitalocean.com/freetrialoffer/)
4+
5+
6+
## Requirements
7+
- [Instal terraform](https://www.terraform.io/downloads)
8+
- [Add SSH key](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-account/) to DO with name `ssh`
9+
10+
11+
## Export environment vars
12+
Extra logs
13+
```
14+
export TF_LOG=INFO
15+
```
16+
## Create and export DO PAT
17+
- [DO PAT](https://docs.digitalocean.com/reference/api/create-personal-access-token/)
18+
```
19+
export DO_PAT="<your_pat>"
20+
```
21+
## Init terraform
22+
```
23+
terraform init
24+
```
25+
26+
```
27+
terraform apply \
28+
-var "do_token=${DO_PAT}" \
29+
-var "pvt_key=$HOME/.ssh/id_ed25519"
30+
```
31+
32+
```
33+
terraform destroy \
34+
-var "do_token=${DO_PAT}" \
35+
-var "pvt_key=$HOME/.ssh/id_ed25519"
36+
```
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
terraform {
2+
required_providers {
3+
digitalocean = {
4+
source = "digitalocean/digitalocean"
5+
version = "~> 2.0"
6+
}
7+
}
8+
}
9+
10+
provider "digitalocean" {
11+
token = var.do_token
12+
}
13+
14+
data "digitalocean_ssh_key" "ssh" {
15+
name = "drvdo"
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
sudo apt-get install -y \
4+
ca-certificates \
5+
curl \
6+
gnupg \
7+
lsb-release \
8+
wget
9+
10+
curl -sSL https://repos.insights.digitalocean.com/install.sh | sudo bash
11+
12+
wget -O - https://get.docker.com/ | bash
13+
14+
sudo systemctl enable docker.service
15+
sudo systemctl start docker.service
16+
17+
mkdir -p ~/.docker/cli-plugins/
18+
curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
19+
chmod +x ~/.docker/cli-plugins/docker-compose
20+
sudo chown $USER /var/run/docker.sock
21+
22+
sudo echo "
23+
version: \"3.3\"
24+
services:
25+
worker:
26+
image: ghcr.io/opengs/uashield:latest
27+
restart: always
28+
command:
29+
- \"7500\"
30+
- \"true\"" >> /home/docker-compose.yaml
31+
32+
sudo apt install -y docker-compose
33+
34+
cd /home/
35+
36+
sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)
37+
38+
sudo echo "*/30 * * * * cd /home/ && sudo docker-compose down -t 1 && sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)" >> /home/cronjob
39+
crontab /home/cronjob
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "digitalocean_droplet" "uashield" {
2+
count = var.droplet_instance_number
3+
image = "ubuntu-20-04-x64"
4+
name = "uashield-${count.index}"
5+
region = "nyc3"
6+
size = var.droplet_instance_size
7+
monitoring = true
8+
9+
ssh_keys = [
10+
data.digitalocean_ssh_key.ssh.id
11+
]
12+
13+
connection {
14+
host = self.ipv4_address
15+
user = "root"
16+
type = "ssh"
17+
private_key = file(var.pvt_key)
18+
timeout = "2m"
19+
}
20+
21+
provisioner "file" {
22+
source = "scripts/uashield.sh"
23+
destination = "/opt/uashield.sh"
24+
}
25+
26+
provisioner "remote-exec" {
27+
inline = [
28+
"chmod +x /opt/uashield.sh",
29+
"/opt/uashield.sh",
30+
]
31+
}
32+
}
33+
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "droplet_instance_number" {
2+
type = number
3+
description = "Digital Ocean droplet instace number"
4+
default = 1
5+
}
6+
7+
variable "droplet_instance_size" {
8+
type = string
9+
description = "Digital Ocean droplet instace size"
10+
default = "s-1vcpu-1gb"
11+
}
12+
13+
variable "do_token" {}
14+
variable "pvt_key" {}

0 commit comments

Comments
 (0)
This repository has been archived.