Compare commits
5 Commits
14528b4ceb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2235e7eb71 | ||
|
|
30279f4649 | ||
|
|
3450a97a03 | ||
|
|
5db3aefb79 | ||
|
|
4b9f23adf1 |
30
all.sh
Executable file
30
all.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
./req.sh login 1>/dev/null
|
||||
|
||||
./req.sh users 1>/dev/null
|
||||
./req.sh devices 1>/dev/null
|
||||
./req.sh export-backup 1>/dev/null
|
||||
./req.sh export-logs 1>/dev/null
|
||||
./req.sh alarms-amount 1>/dev/null
|
||||
./req.sh alarms 1>/dev/null
|
||||
./req.sh geo 1>/dev/null
|
||||
./req.sh argus 1>/dev/null
|
||||
./req.sh argus1 1>/dev/null
|
||||
#elif [[ $1 == "argus2" ]]; then
|
||||
#elif [[ $1 == "argus3" ]]; then
|
||||
./req.sh device-group 1>/dev/null
|
||||
#elif [[ $1 == "device-group1" ]]; then
|
||||
./req.sh logs-amount 1>/dev/null
|
||||
./req.sh logs 1>/dev/null
|
||||
#elif [[ $1 == "transport-group-create" ]]; then
|
||||
./req.sh sensor-data 1>/dev/null
|
||||
./req.sh factory-models 1>/dev/null
|
||||
./req.sh grouped-sensors A56AF66F17D902B8 1>/dev/null
|
||||
./req.sh multi-device-sensors all "\"A56AF66F17D902B8\"" 1>/dev/null
|
||||
./req.sh device-params A56AF66F17D902B8 1>/dev/null
|
||||
./req.sh device-params-v2 A56AF66F17D902B8 1>/dev/null
|
||||
./req.sh connected-chart 1>/dev/null
|
||||
./req.sh connected-chart-v2 1>/dev/null
|
||||
88
req.sh
88
req.sh
@@ -1,13 +1,14 @@
|
||||
#ADDR=api-fema.ekatgortrans.ru:39080
|
||||
#ADDR=https://api.fema.krbl.ru
|
||||
#ADDR=62.217.183.88:8080
|
||||
ADDR=0.0.0.0:8080
|
||||
ADDR=0.0.0.0:8080/api/v1
|
||||
LOGIN=admin
|
||||
PASSWORD=admin
|
||||
#PASSWORD=IR7?BoouErjhXsxg
|
||||
#PASSWORD=ra8KvcMxS2baUxe*
|
||||
#MASTER_CODE=685658
|
||||
MASTER_CODE=111111
|
||||
MFA_OFF="YES"
|
||||
|
||||
|
||||
#set -x
|
||||
@@ -17,16 +18,18 @@ H="-H \"Authorization: Bearer $(cat tmp.token)\""
|
||||
if [[ $1 == "login" ]]; then
|
||||
# Login
|
||||
RESP=$(curl -X POST -H "Content-Type: application/json" -d "{ \"login\": \"$LOGIN\", \"password\": \"$PASSWORD\" }" "$ADDR/auth/signin")
|
||||
# if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
||||
# echo "Failed to login"
|
||||
# echo $RESP | jq '.error'
|
||||
# exit 1
|
||||
# fi
|
||||
#
|
||||
# # 2FA
|
||||
# RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
|
||||
if [ "$MFA_OFF" != "YES" ]; then
|
||||
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
||||
echo "Failed to login"
|
||||
echo "Failed to login1"
|
||||
echo $RESP | jq '.error'
|
||||
exit 1
|
||||
fi
|
||||
# 2FA
|
||||
RESP=$(curl -X POST -H "Content-Type: application/json" "$ADDR/auth/2fa?login=$LOGIN&code=$MASTER_CODE")
|
||||
fi
|
||||
|
||||
if [[ $(echo $RESP | jq '.message') != "\"OK\"" ]]; then
|
||||
echo "Failed to login2"
|
||||
echo $RESP | jq '.error'
|
||||
exit 1
|
||||
fi
|
||||
@@ -49,12 +52,28 @@ elif [[ $1 == "devices-status" ]]; then
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" "$ADDR/data/getDevices" | jq ".devices[] | (.SERIAL) +\" -- \"+ (.IS_CONNECTED|tostring)+\" -- \"+ (.REG_NUMBER)" | tr -d "\""
|
||||
elif [[ $1 == "export-backup" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d '{ "startTime": 1758880189, "endTime": 1753024741 }' \
|
||||
-d "{ \"startTime\": $(($(date +%s)-20000)), \"endTime\": $(date +%s) }" \
|
||||
"$ADDR/data/backup/export" --output export.zip
|
||||
elif [[ $1 == "export-logs" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d '{ "devices": ["KerbClientEmulat"], "start": 1, "end": 1748442522, "timezone": "GMT+03:00"}' \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"], \"start\": 1, \"end\": $(date +%s), \"timezone\": \"GMT+03:00\"}" \
|
||||
"$ADDR/data/logs/exportLogsReport" | jq
|
||||
elif [[ $1 == "export-alarms" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"], \"start\": 1, \"end\": $(date +%s), \"timezone\": \"GMT+03:00\"}" \
|
||||
"$ADDR/data/alarms/exportIncidentsReport" | jq
|
||||
elif [[ $1 == "export-sensors-readings" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"], \"sensors\": [\"TEMPERATURE/85\"], \"start\": 1, \"end\": $(date +%s), \"timezone\": \"GMT+03:00\"}" \
|
||||
"$ADDR/data/sensors/exportSensorReadings" | jq
|
||||
elif [[ $1 == "export-alarm-settings" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"] }" \
|
||||
"$ADDR/data/alarms/exportIncidentDetectionSensorSettingsReport" | jq
|
||||
elif [[ $1 == "export-vehicle" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"] }" \
|
||||
"$ADDR/data/exportVehiclesReport" | jq
|
||||
elif [[ $1 == "get-from-redis" ]]; then
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
"$ADDR/data/getDataFromRedis?fileID=$2"
|
||||
@@ -64,11 +83,48 @@ elif [[ $1 == "alarms-amount" ]]; then
|
||||
"$ADDR/data/alarms/getAlarmsAmount" | jq
|
||||
elif [[ $1 == "alarms" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d '{ "devices": ["A56AF66F17D902B8"], "start_time": 1757890398, "end_time": 1757892398, "page_number": 1, "page_size": 30}' \
|
||||
-d "{ \"devices\": [\"A56AF66F17D902B8\"], \"start_time\": 1, \"end_time\": $(date +%s), \"order\": [[\"sensor_id\", \"+\"]], \"page_number\": 1, \"page_size\": 30}" \
|
||||
"$ADDR/data/alarms/getAlarms" | jq
|
||||
elif [[ $1 == "geo" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"requests\": [ { \"type\": 2, \"mark\": \"$2\" } ] }" \
|
||||
"$ADDR/data/geo/getSerial" | jq
|
||||
elif [[ $1 == "argus" ]]; then
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
"$ADDR/settings/argusServerAddr?device=A56AF66F17D902B8" | jq
|
||||
elif [[ $1 == "argus1" ]]; then
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"device\": \"A56AF66F17D902B8\", \"addr\": \"test-addr1\" }" \
|
||||
"$ADDR/settings/argusServerAddr" | jq
|
||||
elif [[ $1 == "argus2" ]]; then
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
"$ADDR/settings/argusSerial?device=A56AF66F17D902B8" | jq
|
||||
elif [[ $1 == "argus3" ]]; then
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"device\": \"A56AF66F17D902B8\", \"argusSerial\": \"argus-test-erial\" }" \
|
||||
"$ADDR/settings/argusSerial" | jq
|
||||
elif [[ $1 == "device-group" ]]; then
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
"$ADDR/settings/deviceGroup?device=A56AF66F17D902B8" | jq
|
||||
elif [[ $1 == "device-group1" ]]; then
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"device\": \"A56AF66F17D902B8\", \"group\": 3 }" \
|
||||
"$ADDR/settings/deviceGroup" | jq
|
||||
elif [[ $1 == "logs-amount" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [ \"A56AF66F17D902B8\" ] }" \
|
||||
"$ADDR/data/logs/getLogsAmount" | jq
|
||||
elif [[ $1 == "logs" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"devices\": [ \"A56AF66F17D902B8\" ], \"page_number\": 1, \"page_size\": 1000, \"search\": \"test%\", \"order\": [ [\"time\", \"+\" ] ] }" \
|
||||
"$ADDR/data/logs/getLogs" | jq
|
||||
elif [[ $1 == "transport-group-create" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"name\": \"test-group-1\" }" \
|
||||
"$ADDR/transport/createGroup" | jq
|
||||
elif [[ $1 == "sensor-data" ]]; then
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"device\": \"A56AF66F17D902B8\", \"sensor\": \"TEMPERATURE/85\", \"start\": $(($(date +%s)-1000)), \"end\": $(date +%s), \"skip\": 1 }" \
|
||||
-d "{ \"device\": \"2025082700003820\", \"sensor\": \"TEMPERATURE/PIIZI_TEMPERATURE_1\", \"start\": $(($(date +%s)-5000)), \"end\": $(date +%s), \"skip\": 1 }" \
|
||||
"$ADDR/data/sensors/getDeviceSensorData" | jq
|
||||
elif [[ $1 == "factory-models" ]]; then
|
||||
if [[ $2 == "" ]]; then
|
||||
@@ -111,7 +167,9 @@ elif [[ $1 == "device-params" ]]; then
|
||||
echo "No serial presented"
|
||||
exit 1
|
||||
fi
|
||||
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" -d "{ \"serial\": \"$2\" }" "$ADDR/settings/deviceSettings" | jq
|
||||
curl -X POST -s -H "Content-Type: application/json" -H "Authorization: Bearer $(cat tmp.token)" \
|
||||
-d "{ \"serial\": \"$2\" }" \
|
||||
"$ADDR/settings/deviceSettings" | jq
|
||||
elif [[ $1 == "set-device-params" ]]; then
|
||||
if [[ $2 == "" ]]; then
|
||||
echo "No params file presenter"
|
||||
|
||||
Reference in New Issue
Block a user