diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index 8d9041f..d655cc4 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -737,6 +737,111 @@ data: url: https://seerr.dooplex.hu icon: https://web.dooplex.hu/static/white-icons/seerr.png + - type: custom-api + title: Crafty - Minecraft Server + cache: 5s + options: + base-url: ${CRAFTY_URL} + api-key: ${CRAFTY_API_TOKEN} + server-id: ${CRAFTY_SERVER_ID} + display-MOTD: true + allow-insecure: true + template: | + {{/* Required config options */}} + {{ $baseURL := .Options.StringOr "base-url" "" }} + {{ $apiKey := .Options.StringOr "api-key" "" }} + {{ $serverID := .Options.StringOr "server-id" "" }} + + {{/* Optional config options */}} + {{ $displayMOTD := .Options.BoolOr "display-MOTD" true }} + + {{ $serverStats := newRequest (print $baseURL "/api/v2/servers/" $serverID "/stats") + | withHeader "Authorization" (print "Bearer " $apiKey) + | withHeader "Accept" "application/json" + | getResponse }} + + {{ $is_running := $serverStats.JSON.Bool "data.running" }} + {{ $online_players := $serverStats.JSON.Int "data.online" | formatNumber }} + {{ $max_players := $serverStats.JSON.Int "data.max" | formatNumber }} + {{ $name := $serverStats.JSON.String "data.world_name" }} + {{ $size := $serverStats.JSON.String "data.world_size" }} + {{ $version := $serverStats.JSON.String "data.version" }} + {{ $icon := $serverStats.JSON.String "data.icon" }} + {{ $server_ip := $serverStats.JSON.String "data.server_id.server_ip" }} + {{ $server_port := $serverStats.JSON.String "data.server_id.server_port" }} + {{ $motd := $serverStats.JSON.String "data.desc" }} + + {{ $server_addr := "" }} + {{ if and ($is_running) (eq $server_ip "127.0.0.1") }} + {{ $server_addr = printf "%s:%s" (replaceMatches "https?://" "" $baseURL) $server_port }} + {{ else if $is_running }} + {{ $server_addr = printf "%s:%s" $server_ip $server_port }} + {{ end }} + + {{ $starting := false }} + {{ if and ($is_running) (eq $max_players "0") (eq $version "False") }} + {{ $starting = true }} + {{ end }} + + + {{ $updating := $serverStats.JSON.Bool "data.updating" }} + {{ $importing := $serverStats.JSON.Bool "data.importing" }} + {{ $crashed := $serverStats.JSON.Bool "data.crashed" }} + +
+ +
+ {{ if eq $icon "" }} + Server icon + {{ else }} + Server icon + {{ end }} +
+ + +
+ +
+ + {{ $name }} + + + {{ if and ($is_running) (not $starting) (not (eq $server_addr "")) }} +
+ + - {{ $server_addr }} + +
+ {{ end }} +
+ + + {{ if and ($is_running) (not $starting) }} + {{ if and (not (eq $motd "")) ($displayMOTD) }} +
+ {{ replaceMatches "ยง." "" $motd }} +
+ {{ end }} + +
+ {{ $version }} - {{ $online_players }}/{{ $max_players }} players - {{ $size }} +
+ + + {{ else if $starting }} +
Server is starting up..
+ {{ else if $importing }} +
Server is being imported..
+ {{ else if $updating }} +
Server is being updated..
+ {{ else if $crashed }} +
Server has crashed!
+ {{ else }} +
Server is offline
+ {{ end }} +
+
+ - size: full widgets: # YouTube Videos @@ -1343,6 +1448,12 @@ spec: value: "Europe/Budapest" - name: PROMETHEUS_URL value: "http://prometheus.mon-system.svc.cluster.local:9090" + - name: ${CRAFTY_URL} + value: "https://crafty.dooplex.hu" + - name: ${CRAFTY_API_TOKEN} + value: "newtoken" + - name: ${CRAFTY_SERVER_ID} + value: "837c7378-7a76-46f7-b8ea-6f35c0a314f4" ports: - name: http containerPort: 8080