aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile26
-rw-r--r--utils/PKGBUILD26
-rw-r--r--utils/gocgi.conf.example6
-rw-r--r--utils/gocgi@.service18
5 files changed, 77 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01a544f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/gocgi
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9a981d7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+VERSION ?= 0.2
+SOURCE_DATE_EPOCH ?= $(shell date +%s)
+
+all: gocgi-${VERSION}.tar.gz clean
+
+gocgi-${VERSION}.tar.gz: gocgi-${VERSION}
+ tar --sort=name \
+ --numeric-owner \
+ --owner=0 \
+ --group=0 \
+ --gzip \
+ --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
+ -cf gocgi-${VERSION}.tar.gz \
+ gocgi-${VERSION}
+
+gocgi-${VERSION}:
+ mkdir gocgi-${VERSION}
+ cp main.go gocgi-${VERSION}/
+ cp README.md gocgi-${VERSION}/
+ cp go.mod gocgi-${VERSION}/
+ cp Makefile gocgi-${VERSION}/
+ find gocgi-${VERSION} -print0 | \
+ xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
+
+clean:
+ rm -R gocgi-${VERSION}
diff --git a/utils/PKGBUILD b/utils/PKGBUILD
new file mode 100644
index 0000000..e559c9d
--- /dev/null
+++ b/utils/PKGBUILD
@@ -0,0 +1,26 @@
+pkgname="gocgi"
+pkgver=0.2
+pkgrel=1
+pkgdesc='a small go daemon to host cgi scripts'
+arch=('x86_64')
+
+source=(
+ "${pkgname}-${pkgver}.tar.gz"
+ "gocgi@.service"
+ "gocgi.conf.example"
+ )
+
+b2sums=(
+ 'aba9f188f146aca50b37251d1930ec061d7ad9fa24446456c13ce5d504ff4f67043fa706a722ca68e95c0552b6a9872215d04ca40fa5f20d55a52530fbaa66d9'
+ '3492816ef2c676ac8d1feff3736074c362f57a8dce8d13614ba262b660912db99b9e827959452c44f67c19af6b5366ebdf124564c5dae3a6237336b997e840c3'
+ 'e61ef545c47d38b79e0f99138d00ea99982b0a90523ce1697df658e9beae230079f274283c44924a0c5f525bc397ed5a7cd3d316a18d4c0258ca3d6a3b4225f3'
+ )
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ go build -trimpath
+
+ install -Dm 0755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
+ install -Dm 644 ${srcdir}/${pkgname}@.service -t "${pkgdir}/usr/lib/systemd/system"
+ install -Dm 644 ${srcdir}/${pkgname}.conf.example -t "${pkgdir}/etc/gocgi"
+}
diff --git a/utils/gocgi.conf.example b/utils/gocgi.conf.example
new file mode 100644
index 0000000..699a7e8
--- /dev/null
+++ b/utils/gocgi.conf.example
@@ -0,0 +1,6 @@
+# Path to the binary to call when a request was accepted.
+GOCGI_BIN=""
+# Set a number of environment variables to give to the binary.
+GOCGI_ENV=""
+# Set the working directory for this instance.
+GOCGI_WORKDIR="/"
diff --git a/utils/gocgi@.service b/utils/gocgi@.service
new file mode 100644
index 0000000..9f2cf4a
--- /dev/null
+++ b/utils/gocgi@.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=CGI HTTP instance %i
+After=network.target
+
+[Service]
+Type=simple
+EnvironmentFile=/etc/gocgi/%i.conf
+ExecStart=/usr/bin/gocgi --path "${GOCGI_BIN}" --dir "${GOCGI_WORKDIR}" --env="${GOCGI_ENV}" --listen "${STATE_DIRECTORY}/%i.sock"
+
+RuntimeDirectory=gocgi
+DynamicUser=yes
+ProtectSystem=yes
+PrivateDevices=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+
+[Install]
+WantedBy=multi-user.target