aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-09-28 06:00:49 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-09-28 06:00:49 +0300
commit41997666e4109b9ce22bb41407314402fe53f260 (patch)
tree7c4dccacba0785920d3502ca7b90096c5b0dfcc7 /bin
parent35b9daa63ac127e5a2a769cf96a56a0acd8da725 (diff)
downloadarching-kaos-tools-41997666e4109b9ce22bb41407314402fe53f260.tar.gz
arching-kaos-tools-41997666e4109b9ce22bb41407314402fe53f260.tar.bz2
arching-kaos-tools-41997666e4109b9ce22bb41407314402fe53f260.zip
Fixed temporary folder/file handling
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak-stellar-get-participants25
1 files changed, 18 insertions, 7 deletions
diff --git a/bin/ak-stellar-get-participants b/bin/ak-stellar-get-participants
index 8921fad..bac4635 100755
--- a/bin/ak-stellar-get-participants
+++ b/bin/ak-stellar-get-participants
@@ -1,5 +1,8 @@
#!/bin/bash
PROGRAM="$(basename $0)"
+tempdir=`mktemp -d`
+tempfile="$tempdir/tmp"
+tempaddr="$tempdir/tmpaddr"
logit(){
ak-logthis "<$PROGRAM>" "$1" "$2"
}
@@ -13,6 +16,14 @@ if [ ! -f "$stellarParticipantsOnline" ]
then
touch $stellarParticipantsOnline
fi
+if [ ! -f "$tempdir" ]
+then
+ touch $tempdir
+fi
+if [ ! -f "$tempaddr" ]
+then
+ touch $tempaddr
+fi
if [ ! -z $1 ] && [ "$1" == "-l" ] && [ ! -z $2 ]
then
@@ -26,7 +37,7 @@ show_ids(){
flag=0
while [ "$i" -lt "$limit" ]
do
- test="$(cat tmp | jq '.["_embedded"]' | jq .'["records"]' | jq '.['$i']' | jq '.["id"]' | sed -e 's/\"//g')"
+ test="$(cat $tempfile | jq '.["_embedded"]' | jq .'["records"]' | jq '.['$i']' | jq '.["id"]' | sed -e 's/\"//g')"
while IFS="" read -r p || [ -n "$p" ]
do
if [ "$p" == "$test" ]
@@ -47,17 +58,17 @@ show_ids(){
}
get_next_page(){
- cat tmp | grep -1 next | grep https | sed -e 's/^.*https/https/' | sed -e 's/\u0026/\&/g; s/"//g; s/\\//g'
+ cat $tempfile | grep -1 next | grep https | sed -e 's/^.*https/https/' | sed -e 's/\u0026/\&/g; s/"//g; s/\\//g'
}
proceed_to_next_page(){
nextURL="$(get_next_page)"
- curl "$nextURL" > tmp 2>/dev/null
+ curl "$nextURL" > $tempfile 2>/dev/null
}
get_asset_holders(){
- curl https://horizon.stellar.org/accounts\?asset\=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2\&limit\=$limit > tmp 2>/dev/null
+ curl https://horizon.stellar.org/accounts\?asset\=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2\&limit\=$limit > $tempfile 2>/dev/null
}
get_asset_holders
@@ -67,9 +78,9 @@ do
proceed_to_next_page
done
-grep G $stellarParticipants > tmpaddr
-cat tmpaddr > $stellarParticipants
-rm tmp tmpaddr
+grep G $stellarParticipants > $tempaddr
+cat $tempaddr > $stellarParticipants
+rm $tempfile $tempaddr
while IFS="" read -r p || [ -n "$p" ]
do
flag=0