From f5eb3c5b008c044a253c0be753e9573e215d1f6c Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 2 Nov 2019 05:19:02 -0400 Subject: Add calico rc script --- .gitignore | 4 ++-- Makefile | 11 ++++++----- README.7 | 6 +++--- rc.d/calico | 27 +++++++++++++++++++++++++++ rc.d/pounce | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rc.pounce | 60 ------------------------------------------------------------ 6 files changed, 98 insertions(+), 70 deletions(-) create mode 100644 rc.d/calico create mode 100644 rc.d/pounce delete mode 100644 rc.pounce diff --git a/.gitignore b/.gitignore index c66cc95..c7ce8fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ *.conf *.o -calico +/calico +/pounce config.mk localhost.crt localhost.key -pounce tags diff --git a/Makefile b/Makefile index 62cf6b0..5000038 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,11 @@ CFLAGS += -I${LIBRESSL_PREFIX}/include LDFLAGS += -L${LIBRESSL_PREFIX}/lib LDLIBS = -ltls --include config.mk - BINS = calico pounce MANS = ${BINS:=.1} +RCS = ${BINS:%=rc.d/%} + +-include config.mk OBJS += bounce.o OBJS += client.o @@ -37,16 +38,16 @@ tags: *.c *.h clean: rm -f tags ${BINS} ${OBJS} dispatch.o -install: ${BINS} ${MANS} rc.pounce +install: ${BINS} ${MANS} ${RCS} install -d ${PREFIX}/bin ${MANDIR}/man1 ${ETCDIR}/rc.d install ${BINS} ${PREFIX}/bin install -m 644 ${MANS} ${MANDIR}/man1 - install rc.pounce ${ETCDIR}/rc.d/pounce + install ${RCS} ${ETCDIR}/rc.d uninstall: rm -f ${BINS:%=${PREFIX}/bin/%} rm -f ${MANS:%=${MANDIR}/man1/%} - rm -f ${ETCDIR}/rc.d/pounce + rm -f ${RCS:%=${ETCDIR}/%} localhost.crt: printf "[dn]\nCN=localhost\n[req]\ndistinguished_name=dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth" \ diff --git a/README.7 b/README.7 index 4225afa..ff6e463 100644 --- a/README.7 +++ b/README.7 @@ -1,4 +1,4 @@ -.Dd November 1, 2019 +.Dd November 2, 2019 .Dt README 7 .Os "Causal Agency" . @@ -68,10 +68,10 @@ buffer between server and clients configuration parsing .It Pa dispatch.c SNI socket dispatcher -.It Pa rc.pounce +.It Pa rc.d/ .Fx .Xr rc 8 -script +scripts .El . .Sh SEE ALSO diff --git a/rc.d/calico b/rc.d/calico new file mode 100644 index 0000000..583b65b --- /dev/null +++ b/rc.d/calico @@ -0,0 +1,27 @@ +#!/bin/sh + +# PROVIDE: calico +# REQUIRE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +name='calico' +rcvar='calico_enable' + +load_rc_config "${name}" + +: ${calico_enable:="NO"} + +command='/usr/sbin/daemon' +child_command='/usr/local/bin/calico' +pidfile="/var/run/${name}.pid" + +child_flags=$calico_flags +child_user=$calico_user +unset calico_flags calico_user +command_args="\ + -p ${pidfile} -T ${name} ${child_user:+-u ${child_user}} \ + -- ${child_command} ${child_flags}" + +run_rc_command "$1" diff --git a/rc.d/pounce b/rc.d/pounce new file mode 100644 index 0000000..599c585 --- /dev/null +++ b/rc.d/pounce @@ -0,0 +1,60 @@ +#!/bin/sh + +# PROVIDE: pounce +# REQUIRE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +name='pounce' +rcvar='pounce_enable' +extra_commands='reload' +sig_reload='USR1' + +load_rc_config "${name}" + +: ${pounce_enable:="NO"} + +command='/usr/sbin/daemon' +pidprefix="/var/run/${name}" +pidfile="${pidprefix}.pid" + +child_command='/usr/local/bin/pounce' +child_pidfile="${pidprefix}.child.pid" + +if [ -n "$2" ]; then + profile=$2 + if [ -n "${pounce_profiles}" ]; then + pidfile="${pidprefix}.${profile}.pid" + child_pidfile="${pidprefix}.${profile}.child.pid" + eval pounce_enable="\${pounce_${profile}_enable:-${pounce_enable}}" + eval pounce_flags="\${pounce_${profile}_flags:-${pounce_flags}}" + eval pounce_user="\${pounce_${profile}_user:-${pounce_user}}" + else + echo "$0: extra argument ignored" + fi +else + if [ -n "${pounce_profiles}" -a -n "$1" ]; then + for profile in ${pounce_profiles}; do + echo "===> ${name} profile: ${profile}" + /usr/local/etc/rc.d/${name} "$1" "${profile}" || exit "$?" + done + exit + fi +fi + +child_flags=$pounce_flags +child_user=$pounce_user +unset pounce_flags pounce_user +command_args="\ + -r -P ${pidfile} -p ${child_pidfile} -T ${name}${profile:+/${profile}} \ + ${child_user:+-u ${child_user}} \ + -- ${child_command} ${child_flags}" + +pounce_reload() { + rc_pid=$(check_pidfile "$child_pidfile" "$child_command") + kill "-$sig_reload" "$rc_pid" +} +reload_cmd='pounce_reload' + +run_rc_command "$1" diff --git a/rc.pounce b/rc.pounce deleted file mode 100644 index 599c585..0000000 --- a/rc.pounce +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -# PROVIDE: pounce -# REQUIRE: LOGIN -# KEYWORD: shutdown - -. /etc/rc.subr - -name='pounce' -rcvar='pounce_enable' -extra_commands='reload' -sig_reload='USR1' - -load_rc_config "${name}" - -: ${pounce_enable:="NO"} - -command='/usr/sbin/daemon' -pidprefix="/var/run/${name}" -pidfile="${pidprefix}.pid" - -child_command='/usr/local/bin/pounce' -child_pidfile="${pidprefix}.child.pid" - -if [ -n "$2" ]; then - profile=$2 - if [ -n "${pounce_profiles}" ]; then - pidfile="${pidprefix}.${profile}.pid" - child_pidfile="${pidprefix}.${profile}.child.pid" - eval pounce_enable="\${pounce_${profile}_enable:-${pounce_enable}}" - eval pounce_flags="\${pounce_${profile}_flags:-${pounce_flags}}" - eval pounce_user="\${pounce_${profile}_user:-${pounce_user}}" - else - echo "$0: extra argument ignored" - fi -else - if [ -n "${pounce_profiles}" -a -n "$1" ]; then - for profile in ${pounce_profiles}; do - echo "===> ${name} profile: ${profile}" - /usr/local/etc/rc.d/${name} "$1" "${profile}" || exit "$?" - done - exit - fi -fi - -child_flags=$pounce_flags -child_user=$pounce_user -unset pounce_flags pounce_user -command_args="\ - -r -P ${pidfile} -p ${child_pidfile} -T ${name}${profile:+/${profile}} \ - ${child_user:+-u ${child_user}} \ - -- ${child_command} ${child_flags}" - -pounce_reload() { - rc_pid=$(check_pidfile "$child_pidfile" "$child_command") - kill "-$sig_reload" "$rc_pid" -} -reload_cmd='pounce_reload' - -run_rc_command "$1" -- cgit 1.4.1