New backup 2025-10-09 15:00:02
This commit is contained in:
parent
84a991872a
commit
0824bb0e50
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
mcstatus_cache="${HOME}/.cache/mcstatus.json"
|
cache_path="${HOME}/.cache/mcstatus"
|
||||||
|
mcstatus_cache="${cache_path}/mcstatus.json"
|
||||||
|
mkdir -p "${cache_path}"
|
||||||
server_list=("mc.pogmom.me" "mc.pogmom.me")
|
server_list=("mc.pogmom.me" "mc.pogmom.me")
|
||||||
|
|
||||||
update_cache_json(){
|
update_cache_json(){
|
||||||
|
@ -8,10 +10,13 @@ update_cache_json(){
|
||||||
for s in "${server_list[@]}";do
|
for s in "${server_list[@]}";do
|
||||||
mcstatus "${s}" json | jq '. += {"address":"'"${s}"'"}'
|
mcstatus "${s}" json | jq '. += {"address":"'"${s}"'"}'
|
||||||
done | jq -n '[inputs]' | tee "${mcstatus_cache}" >/dev/null
|
done | jq -n '[inputs]' | tee "${mcstatus_cache}" >/dev/null
|
||||||
|
jq -rc '.[] | "\(.address) \(.status.icon)"' ~/.cache/mcstatus.json | while read name icon;do
|
||||||
|
base64 --decode "${icon/*base64,/}" | tee "${cache_path}/${name}.png"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! $(find "${mcstatus_cache}" -cmin -60 -print 2>/dev/null) ]]; then
|
if [[ ! $(find "${mcstatus_cache}" -cmin -60 -print 2>/dev/null) ]]; then
|
||||||
update_cache_json
|
update_cache_json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat "${mcstatus_cache}"
|
#cat "${mcstatus_cache}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue