-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstake.sh
More file actions
executable file
·33 lines (25 loc) · 1.1 KB
/
stake.sh
File metadata and controls
executable file
·33 lines (25 loc) · 1.1 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
#!/bin/bash
# Use passed namespace, or default to 'bee-testnet'
NAMESPACE=${1:-bee-testnet}
DOMAIN=${2:-testnet.internal}
echo "Using namespace: $NAMESPACE with domain: $DOMAIN"
# Get list of ingress hosts/IPs matching "testnet.internal" in the given namespace
list=($(kubectl get ingress -n "$NAMESPACE" | grep "$DOMAIN" | awk '{print $3}'))
counter=0
stake_amount=100000000000000000
# Loop through each and send POST to /stake/<amount>
for url in "${list[@]}"; do
echo "POST ${url}/stake/${stake_amount}"
response=$(curl -s -XPOST "${url}/stake/${stake_amount}")
echo "Response from $url: $response"
# Check if response contains "insufficient stake amount"
if echo "$response" | grep -q '"code":400' && echo "$response" | grep -q 'insufficient stake amount'; then
doubled_amount=$((stake_amount * 2))
echo "Retrying ${url} with doubled amount: $doubled_amount"
retry_response=$(curl -s -XPOST "${url}/stake/${doubled_amount}")
echo "Retry response from $url: $retry_response"
fi
((counter++))
done
# Print the total number of ingresses processed
echo "Total ingresses processed: $counter"