diff --git a/contrib/telodendria.rc b/contrib/telodendria.rc new file mode 100755 index 0000000..bd85315 --- /dev/null +++ b/contrib/telodendria.rc @@ -0,0 +1,11 @@ +#!/bin/ksh + +daemon="/usr/local/bin/telodendria" +daemon_timeout=5 + +. /etc/rc.d/rc.subr + +rc_bg=YES +rc_stop_signal=INT + +rc_cmd $1 diff --git a/tools/bin/td b/tools/bin/td index e061e98..0dccbc5 100644 --- a/tools/bin/td +++ b/tools/bin/td @@ -30,6 +30,8 @@ : "${LDFLAGS:=-lm -pthread -static -flto -fdata-sections -ffunction-sections -s -Wl,-static -Wl,-gc-sections}" : "${PROG:=telodendria}" +: "${PREFIX:=/usr/local}" + # If a .env file exists in the current directory, we load it. # As Telodendria's build infrastructure relies heavily on # environment variables, we allow users to specify their @@ -98,6 +100,29 @@ recipe_build() { fi } +recipe_install() { + cp -v "build/$PROG" "$PREFIX/bin/$PROG" + cp -v "contrib/production.conf" "/etc/telodendria.conf" + cp -v "contrib/telodendria.rc" "/etc/rc.d/telodendria" + + mkdir "/var/telodendria" + useradd _telodendria + chown "_telodendria:_telodendria" "/var/telodendria" + + find man -name 'telodendria*\.[1-8]' -exec cp -v {} "$PREFIX/{}" \; +} + +recipe_uninstall() { + rm -v "$PREFIX/bin/$PROG" + rm -v "/etc/telodendria.conf" + rm -v "/etc/rc.d/telodendria" + + userdel "_telodendria" + groupdel "_telodendria" + + find "$PREFIX/man" -name 'telodendria*\.[1-8]' -delete +} + recipe_run() { if [ -f "build/$PROG" ]; then "build/$PROG" -f contrib/development.conf