From nobody Fri Mar 11 17:04:27 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8B09D19F9166; Fri, 11 Mar 2022 17:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KFXNC3WGPz4hKx; Fri, 11 Mar 2022 17:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647018267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eYsgRdL6CUfGlfyYJkur+mhNmba0JU4pT+vgmXaI0gU=; b=NkM5l+i7aEjMlNK7KQUEgMnIX8ayJ4rfOU3Xnxt8fyExqt73fqFc8M/uOx+/hdWAdiKhi/ GMlUv8KWIcIlBG/zUzgwiqTquV3OGLZAs3NII11xi1Wwm0WQUqKjIsnfVC2aHlgD2T0VnL M+cZkR1ef38C9p3wvULOnVBAgjt4O1UvAwapxjD9sYNFxeU+O0+HCXBYo+yyQEtkzGIU4m byNi10utofA0/uOtdU+H9XCPL5e2Zhi3yyndbn1ErDMPPyl91jt6v90QL52Q7jtZe6tJO6 JX0zz4M/mdfCDXiZ87pUQFBaI7VQWDe57UHbFiiR2y/9LLq+MJxp+J5sZ/+uNg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58B031D118; Fri, 11 Mar 2022 17:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22BH4Rtv025595; Fri, 11 Mar 2022 17:04:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22BH4RKn025594; Fri, 11 Mar 2022 17:04:27 GMT (envelope-from git) Date: Fri, 11 Mar 2022 17:04:27 GMT Message-Id: <202203111704.22BH4RKn025594@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: 9f8f30458b30 - main - www/openarc: Add rc script List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f8f30458b301818b5d53345829a2931a2b943ca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647018267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eYsgRdL6CUfGlfyYJkur+mhNmba0JU4pT+vgmXaI0gU=; b=KZ5aduMpwzt1N7403rCZGC7DUKfReluO6f5e7ypMAnO52sXOjbYo4xbAW17w/NIxMqFcIV 5ld2X79XC20yu8D4sd1NbNXaKOF2j5ntWsW9//u3qcX7FDU4WhKqGxKtO3V7/ZI+HJdZIv rE8KdQHbqG7DHzPqAqFMgrXIzu+NeqVxHGRWkRbDG1KNoUoaBs/scLgw/P5DZJpWGwogcA U1vujC0l5OTOFtZ+NUCSp8p50TJaB2wuC2G3ucNXrO2XGHTnR0Kxi0cTnV8Xk+L1LUehe9 80JzTKKs24++ggY/Zkinw116tQiyMVz5Pn8QSMWfMCyjHB5zDDdthQ9WzB8c9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647018267; a=rsa-sha256; cv=none; b=QD5waN+Q3MMjTFqv5q83lDwigwCs6Y3TUDDET1aG+aCm1EuD60/a/WM0L8OK+K4fnG/DJx B3TL2yM/3+ljhrpj8hjvt/1OXroYRZcsiyUcfngYAxdrP75wVu1w8bg9WwjrVenDHtJvI4 OWQk9Pd5+NYBFI0EHED0xKsAwz0EZVTlTf+fdpxwpUa2wTN3FHZo3pWAXO2aEpglMLmRQk OJ5psgjxTgDTWzbyNUB1A2mNOsvVYlits7gdyjrEWh/ES47dbD7SZxqVZVrPl578mS/gG7 /72p9rJsZFNJkz987WaCV6UewXtvBREBPcYPoCSMR2oP/yUEzQtoaYLvn1LxIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=9f8f30458b301818b5d53345829a2931a2b943ca commit 9f8f30458b301818b5d53345829a2931a2b943ca Author: Yuri Victorovich AuthorDate: 2022-03-11 17:03:39 +0000 Commit: Yuri Victorovich CommitDate: 2022-03-11 17:04:25 +0000 www/openarc: Add rc script Submitted by: Erwan Martin --- www/openarc/Makefile | 3 + www/openarc/files/openarc.in | 166 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) diff --git a/www/openarc/Makefile b/www/openarc/Makefile index 2c20d758f919..65dc4a720300 100644 --- a/www/openarc/Makefile +++ b/www/openarc/Makefile @@ -1,5 +1,6 @@ PORTNAME= openarc PORTVERSION= 1.0.0.b3.20201016 +PORTREVISION= 1 CATEGORIES= www MAINTAINER= yuri@FreeBSD.org @@ -21,6 +22,8 @@ GH_TAGNAME= eb430db GNU_CONFIGURE= yes +USE_RC_SUBR= ${PORTNAME} + INSTALL_TARGET= install-strip OPTIONS_DEFINE= DOCS diff --git a/www/openarc/files/openarc.in b/www/openarc/files/openarc.in new file mode 100644 index 000000000000..0f6ba1798384 --- /dev/null +++ b/www/openarc/files/openarc.in @@ -0,0 +1,166 @@ +#!/bin/sh + +# PROVIDE: milter-openarc +# REQUIRE: DAEMON +# BEFORE: mail +# KEYWORD: shutdown + +# Define these milteropenarc_* variables in one of these files: +# /etc/rc.conf +# /etc/rc.conf.local +# /etc/rc.conf.d/milteropenarc +# +# milteropenarc_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable arc-milter +# milteropenarc_uid (str): Set username to run milter. +# milteropenarc_gid (str): Set group to run milter. +# milteropenarc_profiles (list): Set to "" by default. +# Define your profiles here. +# milteropenarc_cfgfile (str): Configuration file. See openarc.conf(5) +# +# milteropenarc_${profile}_* : Variables per profile. +# Sockets must be different from each other. +# +# milteropenarc_socket_perms (str): Permissions for local|unix socket. +# + +. /etc/rc.subr + +name="milteropenarc" +rcvar=milteropenarc_enable + +extra_commands="reload" +start_precmd="arc_prepcmd" +start_postcmd="arc_start_postcmd" +stop_postcmd="arc_postcmd" +command="/usr/local/sbin/openarc" +_piddir="/var/run/milteropenarc" +pidfile="${_piddir}/pid" +sig_reload="USR1" + +load_rc_config $name + +# +# DO NOT CHANGE THESE DEFAULT VALUES HERE +# +: ${milteropenarc_enable="NO"} +: ${milteropenarc_uid="mailnull"} +: ${milteropenarc_gid="mailnull"} +: ${milteropenarc_cfgfile="/usr/local/etc/mail/openarc.conf"} +: ${milteropenarc_socket_perms="0755"} + +# Options other than above can be set with $milteropenarc_flags. +# see arc-milter documentation for detail. + +if [ -n "$2" ]; then + profile="$2" + if [ "x${milteropenarc_profiles}" != "x" ]; then + pidfile="${_piddir}/${profile}.pid" + eval milteropenarc_enable="\${milteropenarc_${profile}_enable:-${milteropenarc_enable}}" + eval milteropenarc_socket="\${milteropenarc_${profile}_socket:-}" + eval milteropenarc_socket_perms="\${milteropenarc_${profile}_socket_perms:-}" + if [ "x${milteropenarc_socket}" = "x" ];then + echo "You must define a socket (milteropenarc_${profile}_socket)" + exit 1 + fi + eval milteropenarc_cfgfile="\${milteropenarc_${profile}_cfgfile:-${milteropenarc_cfgfile}}" + if [ -f "${milteropenarc_cfgfile}" ];then + milteropenarc_cfgfile="-c ${milteropenarc_cfgfile}" + else + milteropenarc_cfgfile="" + fi + if [ "x${milteropenarc_socket}" != "x" ];then + _socket_prefix="-p" + fi + if [ "x${milteropenarc_uid}" != "x" ];then + _uid_prefix="-u" + if [ "x${milteropenarc_gid}" != "x" ];then + milteropenarc_uid=${milteropenarc_uid}:${milteropenarc_gid} + fi + fi + command_args="-l ${_socket_prefix} ${milteropenarc_socket} ${_uid_prefix} ${milteropenarc_uid} -P ${pidfile} ${milteropenarc_cfgfile}" + else + echo "$0: extra argument ignored" + fi +else + if [ "x${milteropenarc_profiles}" != "x" -a "x$1" != "x" ]; then + if [ "x$1" != "xrestart" ]; then + for profile in ${milteropenarc_profiles}; do + echo "===> milteropenarc profile: ${profile}" + /usr/local/etc/rc.d/milter-openarc $1 ${profile} + retcode="$?" + if [ "0${retcode}" -ne 0 ]; then + failed="${profile} (${retcode}) ${failed:-}" + else + success="${profile} ${success:-}" + fi + done + exit 0 + else + restart_precmd="" + fi + else + if [ -f "${milteropenarc_cfgfile}" ];then + milteropenarc_cfgfile="-c ${milteropenarc_cfgfile}" + else + milteropenarc_cfgfile="" + fi + if [ "x${milteropenarc_socket}" != "x" ];then + _socket_prefix="-p" + fi + if [ "x${milteropenarc_uid}" != "x" ];then + _uid_prefix="-u" + if [ "x${milteropenarc_gid}" != "x" ];then + milteropenarc_uid=${milteropenarc_uid}:${milteropenarc_gid} + fi + fi + command_args="-l ${_socket_prefix} ${milteropenarc_socket} ${_uid_prefix} ${milteropenarc_uid} -P ${pidfile} ${milteropenarc_cfgfile}" + fi +fi + +arc_prepcmd () +{ + if [ -S ${milteropenarc_socket##local:} ] ; then + rm -f ${milteropenarc_socket##local:} + elif [ -S ${milteropenarc_socket##unix:} ] ; then + rm -f ${milteropenarc_socket##unix:} + fi + if [ ! -d ${_piddir} ] ; then + mkdir -p ${_piddir} + fi + if [ -n "${milteropenarc_uid}" ] ; then + chown ${milteropenarc_uid} ${_piddir} + fi + if [ -n "${milteropenarc_gid}" ] ; then + chgrp ${milteropenarc_gid} ${_piddir} + fi + chmod ${milteropenarc_socket_perms} ${_piddir} +} + +arc_start_postcmd () +{ + if [ "x${milteropenarc_socket}" != "x" ] ; then + # postcmd is executed too fast and socket is not created before checking... + sleep 1 + if [ -S ${milteropenarc_socket##local:} ] ; then + chmod ${milteropenarc_socket_perms} ${milteropenarc_socket##local:} + elif [ -S ${milteropenarc_socket##unix:} ] ; then + chmod ${milteropenarc_socket_perms} ${milteropenarc_socket##unix:} + fi + fi +} + +arc_postcmd() +{ + if [ "x${milteropenarc_socket}" != "x" ] ; then + if [ -S ${milteropenarc_socket##local:} ] ; then + rm -f ${milteropenarc_socket##local:} + elif [ -S ${milteropenarc_socket##unix:} ] ; then + rm -f ${milteropenarc_socket##unix:} + fi + fi + # just if the directory is empty + rmdir ${_piddir} > /dev/null 2>&1 +} + +run_rc_command "$1"