about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-10-08 13:26:55 -0400
committerJune McEnroe <june@causal.agency>2023-10-08 13:26:55 -0400
commit6a60cf8431373fec813cfdb8d7a948d04e609d0f (patch)
tree6150a37b196f64696f754d26417d19dad824c686
parentImplement it (diff)
downloadkitd-6a60cf8431373fec813cfdb8d7a948d04e609d0f.tar.gz
kitd-6a60cf8431373fec813cfdb8d7a948d04e609d0f.zip
Add rc script
-rw-r--r--.gitignore1
-rw-r--r--Makefile21
-rw-r--r--rc.in9
3 files changed, 29 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 055d74a..3ae5628 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 kitd
+rc
diff --git a/Makefile b/Makefile
index 8922511..d6a8580 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,23 @@
+PREFIX ?= /usr/local
+MANDIR ?= ${PREFIX}/man
+
 CFLAGS += -std=c11 -Wall -Wextra
 
-all: kitd
+all: kitd rc
+
+rc: rc.in
+	sed 's|%%PREFIX%%|${PREFIX}|g' rc.in >rc
 
 clean:
-	rm -f kitd
+	rm -f kitd rc
+
+install: kitd kitd.8 rc
+	install -d ${DESTDIR}${PREFIX}/sbin ${DESTDIR}${MANDIR}/man8
+	install -d ${DESTDIR}/etc/rc.d
+	install kitd ${DESTDIR}${PREFIX}/sbin
+	install -m 644 kitd.8 ${DESTDIR}${MANDIR}/man8
+	install rc ${DESTDIR}/etc/rc.d/kitd
+
+uninstall:
+	rm -f ${DESTDIR}${PREFIX}/sbin/kitd ${DESTDIR}${MANDIR}/man8/kitd.8
+	rm -f ${DESTDIR}/etc/rc.d/kitd
diff --git a/rc.in b/rc.in
new file mode 100644
index 0000000..b18db96
--- /dev/null
+++ b/rc.in
@@ -0,0 +1,9 @@
+#!/bin/ksh
+
+daemon="%%PREFIX%%/sbin/kitd -n ${0##*/}"
+
+. /etc/rc.d/rc.subr
+
+pexp="kitd: ${0##*/}"
+
+rc_cmd $1