Skip to content

Commit

Permalink
Update the shell script to fix the swork.IllegalFilesTransition error.
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaixian1984 committed May 6, 2024
1 parent 068ee5e commit 0cea420
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
22 changes: 17 additions & 5 deletions docs/Q&AForMember-node-related.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,28 @@ The solution is as follows:
- Keep sowkrer service online
- Execute the following command
```shell
#!/bin/bash

account=$(curl http://localhost:12222/api/v0/enclave/id_info | jq .account)
params=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/scan/extrinsics' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0", "call": "report_works", "module": "swork", "no_params": false, "page": 0, "row": 1, "signed": "signed", "success": true,"address": '$account'}' | jq -r .data.extrinsics | jq -r .[0].params | sed 's/\\//g' | jq .)
extrinsic_index=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/v2/scan/extrinsics' --header 'Content-Type: application/json' --data-raw '{"page": 0, "row": 1, "signed": "all", "call": "report_works", "module": "swork", "success": true, "address": '$account'}' | jq -r '.data|.extrinsics[0]|.extrinsic_index')
params=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/scan/extrinsic' --header 'Content-Type: application/json' --data-raw '{"extrinsic_index": "'$extrinsic_index'", "events_limit": 10, "only_extrinsic_event": true, "focus": ""}' | jq -r .data.params | sed 's/\\//g' | jq .)

added_files=($(echo $params | jq .[6].value | jq -r .[].col1))
deleted_files=($(echo $params | jq .[7].value | jq -r .[].col1))
input_data='{"added_files": ['
for file in ${added_files[@]}; do input_data="${input_data}\"$(echo $file | xxd -r -p)\","; done
if [ ${#added_files[@]} -ne 0 ]; then input_data=${input_data:0:len-1}; fi
for file in ${added_files[@]}; do
input_data="${input_data}\"$(echo $file | xxd -r -p)\",";
done
if [ ${#added_files[@]} -ne 0 ]; then
input_data=${input_data:0:len-1};
fi
input_data="${input_data}], \"deleted_files\": ["
for file in ${deleted_files[@]}; do input_data="${input_data}\"$(echo $file | xxd -r -p)\","; done
if [ ${#deleted_files[@]} -ne 0 ]; then input_data=${input_data:0:len-1}; fi
for file in ${deleted_files[@]}; do
input_data="${input_data}\"$(echo $file | xxd -r -p)\",";
done
if [ ${#deleted_files[@]} -ne 0 ]; then
input_data=${input_data:0:len-1};
fi
input_data="${input_data}]}"
curl -XPOST "http://localhost:12222/api/v0/file/recover_illegal" --header 'Content-Type: application/json' --data-raw "$input_data"
```
Expand Down
22 changes: 17 additions & 5 deletions website/translated_docs/zh-CN/Q&AForMember-node-related.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,28 @@ Member配置的账户与其他member重复
- 保持sowkrer服务在线
- 执行如下命令
```shell
#!/bin/bash

account=$(curl http://localhost:12222/api/v0/enclave/id_info | jq .account)
params=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/scan/extrinsics' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0", "call": "report_works", "module": "swork", "no_params": false, "page": 0, "row": 1, "signed": "signed", "success": true,"address": '$account'}' | jq -r .data.extrinsics | jq -r .[0].params | sed 's/\\//g' | jq .)
extrinsic_index=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/v2/scan/extrinsics' --header 'Content-Type: application/json' --data-raw '{"page": 0, "row": 1, "signed": "all", "call": "report_works", "module": "swork", "success": true, "address": '$account'}' | jq -r '.data|.extrinsics[0]|.extrinsic_index')
params=$(curl -s -XPOST 'https://crust.webapi.subscan.io/api/scan/extrinsic' --header 'Content-Type: application/json' --data-raw '{"extrinsic_index": "'$extrinsic_index'", "events_limit": 10, "only_extrinsic_event": true, "focus": ""}' | jq -r .data.params | sed 's/\\//g' | jq .)

added_files=($(echo $params | jq .[6].value | jq -r .[].col1))
deleted_files=($(echo $params | jq .[7].value | jq -r .[].col1))
input_data='{"added_files": ['
for file in ${added_files[@]}; do input_data="${input_data}\"$(echo $file | xxd -r -p)\","; done
if [ ${#added_files[@]} -ne 0 ]; then input_data=${input_data:0:len-1}; fi
for file in ${added_files[@]}; do
input_data="${input_data}\"$(echo $file | xxd -r -p)\",";
done
if [ ${#added_files[@]} -ne 0 ]; then
input_data=${input_data:0:len-1};
fi
input_data="${input_data}], \"deleted_files\": ["
for file in ${deleted_files[@]}; do input_data="${input_data}\"$(echo $file | xxd -r -p)\","; done
if [ ${#deleted_files[@]} -ne 0 ]; then input_data=${input_data:0:len-1}; fi
for file in ${deleted_files[@]}; do
input_data="${input_data}\"$(echo $file | xxd -r -p)\",";
done
if [ ${#deleted_files[@]} -ne 0 ]; then
input_data=${input_data:0:len-1};
fi
input_data="${input_data}]}"
curl -XPOST "http://localhost:12222/api/v0/file/recover_illegal" --header 'Content-Type: application/json' --data-raw "$input_data"
```
Expand Down

0 comments on commit 0cea420

Please sign in to comment.