-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtools.sh
368 lines (322 loc) · 10.3 KB
/
tools.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#
# Command-line "tools" pulled from my .zshrc file
#
# Ansible
alias run="ansible-playbook -i hosts.yml -i secrets.yml"
alias dst="ansible-playbook -i hosts.yml playbooks/discord-stock-ticker.yml --limit"
alias tf="tofu -chdir=infra"
function ansible-encrypt () {
echo "enter var name: "
read name
echo "enter var secret: "
read secret
ansible-vault encrypt_string "$secret" --name "$name"
}
# DST
function addbot () {
###
# addbot <id> <token>
###
curl -X PUT -s "discord-bot-manager.r.ss/bot/free?bot_id=$1" | jq -e '.id' || curl -X POST -s "discord-bot-manager.r.ss/bot/store?bot_id=$1&bot_token=$2" | jq -e '.id'
}
function newbots () {
curl -setting "discord-bot-manager.r.ss/bot/unclaimed" | jq .
}
function popnewbot () {
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $newbot | jq .
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newcrypto () {
###
# newcrypto <ip>:<port> <id>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/ticker --data "
{
\"name\": \"$2\",
\"crypto\": true,
\"color\": true,
\"frequency\": 10,
\"decimals\": 8,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
curl -X PUT -s "discord-bot-manager.r.ss/bot/photo?bot_id=$id&photo_url=$(curl -s https://api.coingecko.com/api/v3/coins/$2 | jq -r .image.large | cut -d'?' -f1)"
}
# \"currency\": \"BRL\",
# \"currencySymbol\": \"R$\",
# \"currency\": \"PHP\",
# \"currencySymbol\": \"₱\",
function newstock () {
###
# newstock <ip>:<port> <id> <name>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/ticker --data "
{
\"ticker\": \"$2\",
\"name\": \"$3\",
\"color\": true,
\"frequency\": 10,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newgas () {
###
# newgas <ip>:<port> <network>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/gas --data "
{
\"network\": \"$2\",
\"frequency\": 10,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newmarketcap () {
###
# newmarketcap <ip>:<port> <id>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/marketcap --data "
{
\"name\": \"$2\",
\"color\": true,
\"frequency\": 10,
\"ticker\": \" \",
\"decorator\": \" \",
\"decimals\": 0,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
curl -X PUT -s "discord-bot-manager.r.ss/bot/photo?bot_id=$id&photo_url=$(curl -s https://api.coingecko.com/api/v3/coins/$2 | jq -r .image.large | cut -d'?' -f1)"
}
function newcirculating () {
###
# newcirculating <ip>:<port> <id>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/circulating --data "
{
\"name\": \"$2\",
\"frequency\": 10,
\"activity\": \"Circulating Supply\",
\"ticker\": \" \",
\"decimals\": 0,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newtotalvaluelocked () {
###
# newtotalvaluelocked <ip>:<port> <id>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/valuelocked --data "
{
\"name\": \"$2\",
\"frequency\": 10,
\"activity\": \"Sperax TVL\",
\"currency\": \"USD\",
\"currency_symbol\": \"$\",
\"nickname\": true,
\"source\": \"llama\",
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newfloor () {
###
# newfloor <ip>:<port> <marketplace> <collection>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/floor --data "
{
\"marketplace\": \"$2\",
\"name\": \"$3\",
\"frequency\": 10,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newtoken () {
###
# newtoken <ip>:<port> <network> <address> <name> <source>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/token --data "
{
\"network\": \"$2\",
\"contract\": \"$3\",
\"source\": \"$5\",
\"name\": \"$4\",
\"frequency\": 10,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function newholders () {
###
# newholders <ip>:<port> <network> <address> <activity>
###
newbot=$(curl -s 'discord-bot-manager.r.ss/bot/get' | jq -c .)
id=$(echo $newbot | jq -r .id)
token=$(echo $newbot | jq -r .token)
echo $id
curl -s -X POST $1/holders --data "
{
\"network\": \"$2\",
\"address\": \"$3\",
\"activity\": \"$4\",
\"frequency\": 10,
\"nickname\": true,
\"discord_bot_token\": \"$token\",
\"client_id\": \"$id\"
}
" | jq -r '.client_id' | read id && echo "<https://discord.com/api/oauth2/authorize?permissions=335544320&scope=bot&client_id=$id>"
curl -X PUT -s "discord-bot-manager.r.ss/bot/claim?bot_id=$id" | jq -c .
}
function botimage () {
###
# botimage <id> <url>
###
curl -X PUT "discord-bot-manager.r.ss/bot/photo?bot_id=$1&photo_url=$2"
}
function tokentest () {
###
# tokentest <address>
###
echo "DexLab:"
curl "https://api.dexlab.space/v1/trades/$1/24h"
echo
echo "Pancakeswap:"
curl "https://api.pancakeswap.info/api/v2/tokens/$1"
echo
echo "1inch ETH:"
curl "https://api.1inch.exchange/v3.0/1/quote?fromTokenAddress=$1&toTokenAddress=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&amount=10000000000000000000"
echo
echo "1inch BSC:"
curl "https://api.1inch.exchange/v3.0/56/quote?fromTokenAddress=$1&toTokenAddress=0x55d398326f99059ff775485246999027b3197955&amount=10000000"
echo
echo "1inch MATIC"
curl "https://api.1inch.exchange/v3.0/137/quote?fromTokenAddress=$1&toTokenAddress=0x2791bca1f2de4661ed88a30c99a7a9449aa84174&amount=10000000000000000000"
echo
}
function price () {
###
# price <coin id>
###
curl -s "https://api.coingecko.com/api/v3/coins/$1" | jq .market_data.current_price.usd
}
function restartclient () {
###
# restartclient <client>
###
ansible-playbook -i $HOME/isengard/hosts.yml $HOME/isengard/playbooks/restart-service.yml --limit oc -e "{\"service\":\"$1\"}"
}
function updateclient () {
###
# updateclient <client>
###
ansible-playbook -i $HOME/isengard/hosts.yml $HOME/isengard/playbooks/discord-stock-ticker-update.yml --limit oracle_arm_dst -e "{\"client\":\"$1\"}"
}
function dbpull() {
rclone copy s3:discord-stock-ticker/database/$1.state ./
}
function claim () {
dbpull $1 && reclaim -db $1.state
}
alias getenv='export $(cat ../.env | xargs); export AWS_ACCESS_KEY_ID=$MINIO_USER; export AWS_SECRET_ACCESS_KEY=$MINIO_PASSWORD'
function signal () {
message=$@
curl -X POST http://signal-api.r.ss/v2/send --data "
{
\"message\": \"$message\",
\"number\": \"+14808407117\",
\"recipients\": [
\"+15159792049\"
]
}"
}
function signal_survivor () {
message=$@
curl -X POST http://signal-api.r.ss/v2/send --data "
{
\"message\": \"$message\",
\"number\": \"+14808407117\",
\"recipients\": [
\"group.ZTVTUzdvNjZSbGFsYTlrR1p0M21KbTQ3eFZNa2ZRWHMzZm1acFlnd1c1Yz0=\"
]
}"
}
function signal_nicole () {
message=$@
curl -X POST http://signal-api.r.ss/v2/send --data "
{
\"message\": \"$message\",
\"number\": \"+14808407117\",
\"recipients\": [
\"+15155097579\"
]
}"
}
function rm-ns-force () {
kubectl get namespace "$1" -o json \
| tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
| kubectl replace --raw /api/v1/namespaces/$1/finalize -f -
}
function frigate-deploy () {
curl -X POST -H 'content-type: application/json' --url 'https://app.harness.io/gateway/pipeline/api/webhook/custom/v2?accountIdentifier=wlgELJ0TTre5aZhzpt8gVA&orgIdentifier=default&projectIdentifier=home_lab&pipelineIdentifier=deploy&triggerIdentifier=frigate_http'
}