diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-26 14:35:46 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-26 14:35:46 -0400 |
commit | 0c2bf8bec3ff0f558785b29980c193b054c3b529 (patch) | |
tree | 13b9885d67ede3e33863264cee8d46d22bed735c /config-parabola-service-myhostname.PKGBUILD | |
parent | d6801ddd960843ca9c503acb937e7b807852bcf8 (diff) |
Rename everything from config-* to config-parabola-*
Diffstat (limited to 'config-parabola-service-myhostname.PKGBUILD')
-rw-r--r-- | config-parabola-service-myhostname.PKGBUILD | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/config-parabola-service-myhostname.PKGBUILD b/config-parabola-service-myhostname.PKGBUILD new file mode 100644 index 0000000..fe1bbb3 --- /dev/null +++ b/config-parabola-service-myhostname.PKGBUILD @@ -0,0 +1,100 @@ +. ${BUILDFILE%/*}/common.sh +pkgver=20180826 + +package() { +preamble +# #### Host information + +depends+=(config-mgmt-nginx) + +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; + + add_header "Access-Control-Allow-Origin" "*"; + + location = /sysinfo { + uwsgi_pass unix:/run/uwsgi/myhostname.sock; + uwsgi_modifier1 9; # Standard CGI request + include uwsgi_params; + } +} +EOF + +# Let's have a simple CGI script show server info + +depends+=( + config-mgmt-uwsgi + uwsgi-plugin-cgi +) + +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 + +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 + +# Expose the pacman cache so pinned packages can be duplicated +ln -s /var/cache/pacman/pkg srv/http/myhostname/pkg + +# Expose collectd via RRD files +ln -s /var/lib/collectd srv/http/myhostname/collectd + +depends+=( + config-base-collectd + rrdtool + 'systemd>=239' # for systemd-time-wait-sync.service +) + +add-unit etc/systemd/system/sysinit.target.wants/systemd-time-wait-sync.service + +add-file -m644 etc/systemd/system/collectd.service.d/time-sync.conf <<EOF +[Unit] +# Because we write RRD files with timestamps in them, we need to have +# a functional clock. Otherwise the RRD files will get garbled. +After=time-sync.target +EOF + +postamble +} |