-
Notifications
You must be signed in to change notification settings - Fork 0
/
New_Agent.sh
executable file
·65 lines (52 loc) · 1.25 KB
/
New_Agent.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
#https://spacetraders.io/
echo "Enter Agent name: "
read AgentName
case $AgentName
in
"" ) echo "null value not allowed"
exit 1;;
*) echo "Agent's name is $AgentName"
echo "checking availability" ;;
esac
curl --silent --request POST \
--url 'https://api.spacetraders.io/v2/register' \
--header 'Content-Type: application/json' \
--data "{ \"symbol\": \"$AgentName\", \"faction\": \"COSMIC\"}" > New_Agent.json
ReturnCode=$(jq '.[] |.code' New_Agent.json)
ReturnError=$(jq '.error.data.symbol[0]' New_Agent.json)
if [ $ReturnCode == "422" ]
then
echo "Something went wrong"
echo "$ReturnError"
exit 1
else
echo "Agent $AgentName created"
fi
#Get Token
#Use '-r' to het raw data, so without quotes
#
Token=$(jq -r '.[] |.token' New_Agent.json)
echo $Token > Token.txt
Agent=$(jq '.[] |.agent' New_Agent.json)
echo $Agent > Agent.json
Contract=$(jq '.[] |.contract' New_Agent.json)
echo $Contract > Contract.json
Faction=$(jq '.[] |.faction' New_Agent.json)
echo $Faction > Faction.json
# SHIP INFO
# jq '.<info>' Ship.txt
# <info> can be
# - crew
# - fuel
# - frame
# - reactor
# - engine
# - modules
# - mounts
# - registration
# - cargo
#
Ship=$(jq '.[] |.ship' New_Agent.json)
echo $Ship > Ship.json