From c9301bb42fded0a57b52f816185c266ed488e5aa Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Wed, 5 May 2021 16:01:38 -0800 Subject: init: adding init files for OpenRC --- Makefile.am | 8 +++++ acinclude.m4 | 13 +++++-- src/openrc/bbfw.firewall.in | 82 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 src/openrc/bbfw.firewall.in diff --git a/Makefile.am b/Makefile.am index c095072..99585e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -106,6 +106,7 @@ EXTRA_DIST = \ src/firewall.d/rules-example \ src/firewall.d/rules4-example \ src/firewall.d/rules6-example \ + src/openrc/bbfw.firewall.in \ src/rc.firewall.in \ src/firewall.bbfw.service.in CLEANFILES = \ @@ -120,6 +121,7 @@ CLEANFILES = \ $(slackrcd_SCRIPTS) \ src/firewall.bbfw \ src/firewall.bbfw.service \ + src/openrc/bbfw.firewall \ src/rc.firewall \ src/rc.firewall.new \ @PACKAGE_TARNAME@-*.tar.* \ @@ -147,6 +149,9 @@ endif if ENABLE_SLACKWARE slackrcd_SCRIPTS = src/rc.firewall.new endif +if ENABLE_OPENRC +initd_SCRIPTS = src/openrc/bbfw.firewall +endif if ENABLE_INITD initd_SCRIPTS = src/firewall.bbfw endif @@ -188,6 +193,9 @@ src/firewall.bbfw: src/rc.firewall src/firewall.bbfw.service: Makefile src/firewall.bbfw.service.in @$(do_subst_fn) +src/openrc/bbfw.firewall: Makefile src/openrc/bbfw.firewall.in + @$(do_subst_fn) + # local targets install-exec-local: diff --git a/acinclude.m4 b/acinclude.m4 index 5ef1d60..3813ed8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -65,7 +65,7 @@ AC_DEFUN([AC_BBFW_INIT],[dnl withval="" AC_ARG_WITH( init, - [AS_HELP_STRING([--with-init=type], [init system type of slackware, systemd, or init.d [default=auto]])], + [AS_HELP_STRING([--with-init=type], [init system type of init.d, openrc, slackware, or systemd [default=auto]])], [ WINIT=$withval ], [ WINIT=$withval ] ) @@ -84,6 +84,9 @@ AC_DEFUN([AC_BBFW_INIT],[dnl elif test "x${WINIT}" == "xinit.d";then ENABLE_INIT=init.d ENABLE_INITD=yes + elif test "x${WINIT}" == "xopenrc";then + ENABLE_INIT=OpenRC + ENABLE_OPENRC=yes elif test "x${WINIT}" == "xslackware";then ENABLE_INIT=slackware ENABLE_SLACKWARE=yes @@ -91,7 +94,7 @@ AC_DEFUN([AC_BBFW_INIT],[dnl ENABLE_INIT=systemd ENABLE_SYSTEMD=yes elif test ""x${WINIT}" != "xno" && test ""x${WINIT}" != "xyes" && test "x${WINIT}" != "x";then - AC_MSG_ERROR([unknown init system, must be slackware, systemd, or init.d.]) + AC_MSG_ERROR([unknown init system, must be init.d, openrc, slackware, or systemd.]) fi # auto detects init system @@ -99,6 +102,9 @@ AC_DEFUN([AC_BBFW_INIT],[dnl if test -f /etc/slackware-version;then ENABLE_INIT=slackware ENABLE_SLACKWARE=yes + elif test -f /sbin/openrc;then + ENABLE_INIT=OpenRC + ENABLE_OPENRC=yes elif test -d "/etc/systemd/system/";then ENABLE_INIT=systemd ENABLE_SYSTEMD=yes @@ -112,8 +118,9 @@ AC_DEFUN([AC_BBFW_INIT],[dnl fi fi - AM_CONDITIONAL([ENABLE_SLACKWARE], [test "x${ENABLE_SLACKWARE}" == "xyes"]) AM_CONDITIONAL([ENABLE_INITD], [test "x${ENABLE_INITD}" == "xyes"]) + AM_CONDITIONAL([ENABLE_OPENRC], [test "x${ENABLE_OPENRC}" == "xyes"]) + AM_CONDITIONAL([ENABLE_SLACKWARE], [test "x${ENABLE_SLACKWARE}" == "xyes"]) AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x${ENABLE_SYSTEMD}" == "xyes"]) ])dnl diff --git a/src/openrc/bbfw.firewall.in b/src/openrc/bbfw.firewall.in new file mode 100644 index 0000000..dc78f1e --- /dev/null +++ b/src/openrc/bbfw.firewall.in @@ -0,0 +1,82 @@ +#!/sbin/openrc-run +# +# Bindle Binaries Linux Firewall +# Copyright (c) 2021 David M. Syzdek . +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of David M. Syzdek nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# OpenRC init script +# + +description="Bindle Binaries Linux Firewall" +description_reload="Reload configuration" + +extra_commands="sync" +extra_started_commands="dump log reload" + +bbfw_bin="@sbindir@/bbfw" +bbfw_log_bin="@sbindir@/bbfw-log" + +depend() { + before net + use logger + provide firewall +} + +dump() { + $bbfw_bin dump + return 0 +} + +log() { + $bbfw_log_bin + return 0 +} + +reload() { + ebegin "Reloading firewall via bbfw" + $bbfw_bin restart + eend $? +} + +start() { + ebegin "Loading firewall via bbfw" + $bbfw_bin start + eend $? +} + +sync() { + ebegin "Syncing firewall rules via bbfw" + eend 0 +} + +stop() { + ebegin "Flushing firewall via bbfw" + $bbfw_bin start + eend $? +} + +# end of init file -- cgit v1.2.3