New backup 2025-11-05 17:30:03
This commit is contained in:
parent
dc3068383b
commit
01dbf71df7
2 changed files with 7 additions and 19 deletions
|
|
@ -1,4 +1,4 @@
|
|||
(defpoll servers_status :initial '[{"online": true,"kind":"Java","status":{"players":{"online":0,"max":0,"sample":null},"version":{"name":"version","protocol":0},"motd":"Message of the day","latency":0,"icon":""},"address":"ip.addre.ss"}]'
|
||||
(defpoll servers_status :initial '[{"online": true,"kind":"Java","players":{"online":0,"max":0,"list":null},"version":{"name":"version","protocol":0},"motd":"Message of the day","ping":0,"address":"ip.addre.ss"}]'
|
||||
:interval "21600s"
|
||||
'scripts/home/mcstatus')
|
||||
|
||||
|
|
@ -45,18 +45,18 @@
|
|||
)
|
||||
(label
|
||||
:xalign 0
|
||||
:text "${server.status.players.online}/${server.status.players.max} players online"
|
||||
:text "${server.players.online}/${server.players.max} players online"
|
||||
)
|
||||
(label
|
||||
:class 'motd'
|
||||
:text "${replace(server.status.motd,'§.','')}"
|
||||
:text "${server.motd}"
|
||||
:wrap true
|
||||
:wrap-mode 'word'
|
||||
; :truncate true
|
||||
)
|
||||
(label
|
||||
:xalign 0
|
||||
:text " ${round(server.status.latency,0)}ms"
|
||||
:text " ${round(server.ping,0)}ms"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,25 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cache_path="${HOME}/.cache/mcstatus"
|
||||
mcstatus_cache="${cache_path}/mcstatus.json"
|
||||
cache_path="${HOME}/.cache/mc-server-info"
|
||||
mcstatus_cache="${cache_path}/cache.json"
|
||||
mkdir -p "${cache_path}"
|
||||
#server_list=("mc.pogmom.me" "wedontownit.duckdns.org" "ian.hotn.gay")
|
||||
server_list=("mc.pogmom.me" "ian.hotn.gay")
|
||||
|
||||
update_cache_json(){
|
||||
|
||||
for s in "${server_list[@]}";do
|
||||
mcstatus "${s}" json | jq '. += {"address":"'"${s}"'","icon_path":"'"${cache_path}/${s}"'.png"}'
|
||||
done | jq -n '[inputs]' | tee "${mcstatus_cache}" >/dev/null
|
||||
jq -rc '.[] | "\(.address) \(.status.icon)"' "${mcstatus_cache}" | while read name icon;do
|
||||
# echo "${name}"
|
||||
# echo "${icon/*base64,/}"
|
||||
echo "${icon/*base64,/}" | base64 --decode > "${cache_path}/${name}.png"
|
||||
done
|
||||
mc-server-info json | tee "${mcstatus_cache}" >/dev/null
|
||||
}
|
||||
|
||||
if [[ ! $(find "${mcstatus_cache}" -cmin -15 -print 2>/dev/null) ]]; then
|
||||
update_cache_json
|
||||
fi
|
||||
|
||||
cat "${mcstatus_cache}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue