-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·55 lines (42 loc) · 2.21 KB
/
run.sh
File metadata and controls
executable file
·55 lines (42 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
cd "$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" || return 1
source .env
SCALE="${SCALE:-1}"
if [ -z "$TOKEN" ]; then
echo "Empty TOKEN"
exit 1
fi
if [ -z "$ORG_NAME" ]; then
echo "Empty ORG_NAME"
exit 1
fi
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.lo.disable_ipv6=1
docker compose up --scale github-runner="$SCALE" -d
br_name=$(docker network ls --filter name=self-hosted-runners_default --format 'br-{{.ID}}')
nft delete table inet filter
tc qdisc del dev "$br_name" root
nft add table inet filter
nft add chain inet filter forward '{ type filter hook forward priority 0; }'
nft add set inet filter cn_ip '{ type ipv4_addr; flags interval; }'
nft add set inet filter local_ip '{ type ipv4_addr; flags interval; }'
nft add element inet filter cn_ip "{ $(curl -4sSkL https://raw.githubusercontent.com/herrbischoff/country-ip-blocks/master/ipv4/cn.cidr | grep -E '^[0-9./]+$' | paste -sd, -) }"
nft add element inet filter local_ip '{ 10.0.0.0/8 }'
nft add rule inet filter forward ip saddr != @cn_ip ip saddr != @local_ip counter meta mark set 0x1
nft add rule inet filter forward ip saddr @cn_ip counter meta mark set 0x2
tc qdisc add dev "$br_name" root handle 1: htb default 30
tc class add dev "$br_name" parent 1: classid 1:10 htb rate 100mbit ceil 100mbit quantum 100
tc class add dev "$br_name" parent 1: classid 1:20 htb rate 800mbit ceil 800mbit quantum 100000
tc class add dev "$br_name" parent 1: classid 1:30 htb rate 100gbit ceil 100gbit quantum 10000000
tc qdisc replace dev "$br_name" parent 1:10 fq_codel target 20ms interval 200ms memory_limit 1024Mb
tc qdisc replace dev "$br_name" parent 1:20 fq_codel target 20ms interval 200ms memory_limit 1024Mb
tc qdisc replace dev "$br_name" parent 1:30 fq_codel target 20ms interval 200ms memory_limit 1024Mb
tc filter add dev "$br_name" protocol ip parent 1:0 prio 1 handle 1 fw flowid 1:10
tc filter add dev "$br_name" protocol ip parent 1:0 prio 2 handle 2 fw flowid 1:20
echo "Starting Daemon..."
while true; do
docker compose rm -f 2>/dev/null
docker compose up --scale github-runner="$SCALE" -d 2>&1 | grep -E 'Creating|Recreating|Restarting'
sleep 1
done