forked from akash-network/awesome-akash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·45 lines (39 loc) · 1.33 KB
/
run.sh
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
#!/usr/bin/env bash
if [ -z "$WALLET_ADDR" ]; then
echo "WALLET_ADDR not defined"
sleep 300
exit 1
fi
echo "Checking CPU in pod"
if [ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]; then
CPU_COUNT=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
else
CPU_COUNT=$(cat /sys/fs/cgroup/cpu.max | awk '{print $1}')
fi
CPU_COUNT=$(echo "scale=0; $CPU_COUNT/100000" | bc -l) #Convert to threads
echo "Found $CPU_COUNT cpus available."
#Set uploaders to CPU count if higher than default 10
if [[ $CPU_COUNT > 10 ]]; then
UPLOADERS=$CPU_COUNT
else
UPLOADERS=10
fi
declare -a pools
readarray -t pools <<< $(
env | \
grep '^POOL[[:digit:]]\+=' | \
sort | \
cut -d= -f2
)
if [ -z "${pools[0]}" ]; then
pools[0]="$POOL_HOST_DEFAULT"
fi
echo "using pools ${pools[*]}..."
if [[ $VERSION != "v0.5.2" ]]; then
echo "Got version $VERSION, pulling from Github" ; rm packetcrypt-${VERSION}-linux_amd64
wget https://github.com/cjdelisle/packetcrypt_rs/releases/download/packetcrypt-${VERSION}/packetcrypt-${VERSION}-linux_amd64 ; chmod +x packetcrypt-${VERSION}-linux_amd64
./packetcrypt-$VERSION-linux_amd64 ann --paymentaddr "$WALLET_ADDR" "${pools[@]}" --threads $CPU_COUNT --uploaders $UPLOADERS
else
echo "Got default version $VERSION"
./packetcrypt-$VERSION-linux_amd64 ann --paymentaddr "$WALLET_ADDR" "${pools[@]}" --threads $CPU_COUNT --uploaders $UPLOADERS
fi