#!/bin/bash

frpc_json=/etc/frp/config.json
wt_json=/home/linaro/wtdiagnose/file/usbconfig.json
current_json=/home/linaro/wtcurrent/file/config.json
serial_num=$(cat /proc/serialnum)
extracted_num=$(echo "$serial_num" | cut -d '-' -f 2)
jq --arg sn "$extracted_num" '.SN = $sn' ${frpc_json} > /tmp/temp.json && sudo mv /tmp/temp.json ${frpc_json}
jq --arg sn "$extracted_num"  '[.[] | .SN = $sn ]' ${wt_json} > temp.json && mv temp.json ${wt_json}
jq --arg sn "$extracted_num"  '.sn = $sn' ${current_json} > temp.json && mv temp.json ${current_json}