diff options
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/home.luax | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/pages/home.luax b/pages/home.luax index 002d9bf..6ab86bc 100644 --- a/pages/home.luax +++ b/pages/home.luax @@ -13,6 +13,38 @@ local art = [[ __| |__ ]] +local function is_service_live(service, is_user) + local opt = '' + if is_user then + opt = '-U ' + end + local handle = io.popen('rc-service ' .. opt .. service .. ' status 2>&1') + local output = handle:read('*a') + + + local is_dummy = string.match(output, "not found") + if is_dummy then + return "unknown" + end + local is_running = string.match(output, "started") + if is_running then + return "online" + else + return "offline" + end +end + +local function Service(props) + return <div class="service-info"> + <div class="service-name"> + {$ props.attrs.service $} + </div> + <div class={"service-status service-status-" .. is_service_live(props.attrs.service, props.attrs.is_user)}> + {$ is_service_live(props.attrs.service, props.attrs.is_user) $} + </div> + </div> +end + return function(props) return <div class="main-info"> <div class="main-info-title"> @@ -21,12 +53,13 @@ return function(props) <div class="ascii-art"> {$ art $} </div> - <div class="main-info-subtitle"> - apparently like - <div class="main-info-highlight"> - {$ tostring(props.attrs.visits) $} - </div> - people saw this + <div class="service-group"> + <Service service="tailscale" is_user={true} /> + <Service service="reluax" /> + <Service service="nginx" /> + <Service service="fcgiwrap" /> + <Service service="sshd" /> + <Service service="git-daemon" /> </div> </div> end |
