summaryrefslogtreecommitdiff
path: root/pages/home.luax
blob: 6ab86bc789ef1c6e08faa3a1d8d7b0580526f526 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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">
        they do lots of things!
      </div>
      <div class="ascii-art">
        {$ art $}
      </div>
      <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