aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-11-21 12:41:30 -0800
committerTrumeet <yuuta@yuuta.moe>2022-11-21 12:41:30 -0800
commit1c1352dd75ae475b3ead741a7696a7977b2c74fb (patch)
treeb5420caeeb45f095dff8b8a0ad3290b8788d58f1
parenta7c0792e85c0cecd41aff24ca737498c0116f0e0 (diff)
downloadhitokoto-1c1352dd75ae475b3ead741a7696a7977b2c74fb.tar
hitokoto-1c1352dd75ae475b3ead741a7696a7977b2c74fb.tar.gz
hitokoto-1c1352dd75ae475b3ead741a7696a7977b2c74fb.tar.bz2
hitokoto-1c1352dd75ae475b3ead741a7696a7977b2c74fb.zip
Add systemd socket / service / conf
-rw-r--r--PKGBUILD16
-rw-r--r--conf13
-rw-r--r--hitokoto.service10
-rw-r--r--hitokoto.socket5
4 files changed, 42 insertions, 2 deletions
diff --git a/PKGBUILD b/PKGBUILD
index b9dcb3c..138bba3 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -10,9 +10,16 @@ license=('custom')
groups=()
depends=(sqlite3 fcgi)
source=("m2.c"
-"init.sql")
+"init.sql"
+"hitokoto.socket"
+"hitokoto.service"
+"conf")
sha256sums=('e17e076e53592da71d45bdc76b801e641232d89674004d8fe6ca87183f4693a9'
- 'e71a00dfb9a2744f482de80e33c02341d6cae19a1f54e53a5346d972bfeff054')
+ 'e71a00dfb9a2744f482de80e33c02341d6cae19a1f54e53a5346d972bfeff054'
+ 'b8bc142afd751158b0350720eedbd123d44053ecc2a398db71d87142d6a076db'
+ '7df72ca1eef5545b4c88325605c0724b14574d66d4d73b65125f0fac75c4def0'
+ '955a23a929ce2c4da46ac372df3dd50badadef944270431973b550d5b6d57844')
+backup=('etc/conf.d/hitokoto')
build() {
cd "$srcdir"
@@ -26,4 +33,9 @@ package() {
chmod 755 $pkgdir/usr/bin/hitokoto
mkdir -p $pkgdir/usr/share/$pkgdir/doc/
cp init.sql $pkgdir/usr/share/$pkgdir/doc/
+ mkdir -p $pkgdir/usr/lib/systemd/system/
+ cp hitokoto.socket $pkgdir/usr/lib/systemd/system/
+ cp hitokoto.service $pkgdir/usr/lib/systemd/system/
+ mkdir -p $pkgdir/etc/conf.d/
+ cp conf $pkgdir/etc/conf.d/hitokoto
}
diff --git a/conf b/conf
new file mode 100644
index 0000000..ff738ea
--- /dev/null
+++ b/conf
@@ -0,0 +1,13 @@
+# hitokoto(1) configuration file
+# This file is an environment file, so a restart is
+# required to apply the changes.
+
+# SQLite3 database for hitokoto(1) to read.
+# It must be accessible to any users (--r).
+# Run /usr/share/hitokoto/doc/init.sql to setup
+# schema.
+# Administrators can edit that file to manage
+# quotes and sources.
+# Any changes to the db is instantly reflected to
+# hitokoto(1), so no restart is needed.
+DB="/path/to/hitokoto.db"
diff --git a/hitokoto.service b/hitokoto.service
new file mode 100644
index 0000000..9b3159b
--- /dev/null
+++ b/hitokoto.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Hitokoto
+
+[Service]
+EnvironmentFile=/etc/conf.d/hitokoto
+ExecStart=/usr/bin/hitokoto $DB
+DynamicUser=yes
+ProtectHome=yes
+ProtectSystem=strict
+StandardInput=socket
diff --git a/hitokoto.socket b/hitokoto.socket
new file mode 100644
index 0000000..9a79e17
--- /dev/null
+++ b/hitokoto.socket
@@ -0,0 +1,5 @@
+[Socket]
+ListenStream=/run/hitokoto.sock
+
+[Install]
+WantedBy=sockets.target