blob: e83d2cde134a03e6686be652814a83a177719176 (
plain)
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
66
67
68
69
70
71
72
73
74
75
|
. ${BUILDFILE%/*}/common.sh
pkgver=20161111.10
package() {
preamble
depends+=(
config-mgmt-nginx
config-mgmt-uwsgi
uwsgi-plugin-cgi
)
add-file etc/nginx/sites/server-myhostname.conf <<EOF
# -*- Mode: nginx; nginx-indent-level: 8; indent-tabs-mode: t -*-
server {
server_name \$hostname;
listen 443 ssl http2;
listen [::]:443 ssl http2;
error_log /var/log/nginx/nginx.http.myhostname.error.log error;
access_log /var/log/nginx/nginx.http.myhostname.access.log specific;
root /srv/http/myhostname;
autoindex on;
location = /sysinfo {
uwsgi_pass unix:/run/uwsgi/myhostname.sock;
uwsgi_modifier1 9; # Standard CGI request
include uwsgi_params;
}
}
EOF
add-file -m755 srv/http/myhostname/sysinfo <<EOF
#!/bin/bash
# Copyright 2016 Luke Shumaker
cmds=(
'hostnamectl status'
"systemctl status | sed '1d;/^\\s*CGroup:/,\\\$d'"
'uptime'
'free -h'
"df -Th | sed -n '1p;/^\\/dev/p'"
)
printf '%s\\r\\n' \\
'Content-Type: text/plain; charset=utf-8' \\
''
for cmd in "\${cmds[@]}"; do
printf '\$ %s\\n' "\$cmd"
(eval "\$cmd")
echo
done
EOF
ln -s /var/cache/pacman/pkg srv/http/myhostname/pkg
add-file etc/uwsgi/myhostname.ini <<EOF
[uwsgi]
master = true
processes = 1
uid = nobody
gid = http
plugins = cgi
cgi = /srv/http/myhostname/sysinfo
EOF
add-unit etc/systemd/system/sockets.target.wants/uwsgi@myhostname.socket
postamble
}
|