ports/166947: [PATCH] net/socat: fix rc script issues
Mark Felder
feld at feld.me
Sat Apr 14 18:00:23 UTC 2012
>Number: 166947
>Category: ports
>Synopsis: [PATCH] net/socat: fix rc script issues
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Apr 14 18:00:22 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Mark Felder
>Release: FreeBSD 9.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD mwi1.coffeenet.org 9.0-STABLE FreeBSD 9.0-STABLE #1 r230267: Tue Jan 17 15:11:44 CST
>Description:
Added file(s):
- files/socat_wrapper
Utilized wrapper from www/gatling to fix the start-on-boot issues plaguing this port.
Redports report here: https://redports.org/buildarchive/20120414160814-64429/
Known to not build on Clang.
Port maintainer (ehaupt at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.99_5 (mode: change, diff: suffix)
>How-To-Repeat:
>Fix:
--- socat-1.7.2.0_1.patch begins here ---
diff -ruN --exclude=CVS ../socat.orig/Makefile ./Makefile
--- ../socat.orig/Makefile 2011-12-06 02:49:25.000000000 -0600
+++ ./Makefile 2012-04-14 11:08:01.000000000 -0500
@@ -7,6 +7,7 @@
PORTNAME= socat
PORTVERSION= 1.7.2.0
+PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= http://www.dest-unreach.org/socat/download/ \
CRITICAL
@@ -25,7 +26,11 @@
PORTSCOUT= skipv:2.0.0-b2
MAN1= socat.1
-PLIST_FILES= bin/filan bin/procan bin/socat
+PLIST_FILES= bin/filan bin/procan bin/socat sbin/socat_wrapper
+
+bin= filan \
+ procan \
+ socat
.include <bsd.port.pre.mk>
@@ -33,9 +38,12 @@
PORTDOCS= EXAMPLES README SECURITY FAQ
.endif
-post-install:
+do-install:
+ cd ${WRKSRC} && ${INSTALL_PROGRAM} ${bin} ${PREFIX}/bin
+ ${INSTALL_SCRIPT} ${FILESDIR}/socat_wrapper ${PREFIX}/sbin
+ cd ${WRKSRC} && ${INSTALL_MAN} doc/${MAN1} ${MAN1PREFIX}/man/man1
.if !defined(NOPORTDOCS)
- @${MKDIR} ${DOCSDIR}
+ ${MKDIR} ${DOCSDIR}
cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}
.endif
diff -ruN --exclude=CVS ../socat.orig/files/socat.in ./files/socat.in
--- ../socat.orig/files/socat.in 2012-01-14 02:56:27.000000000 -0600
+++ ./files/socat.in 2012-04-14 11:08:01.000000000 -0500
@@ -18,11 +18,13 @@
name="socat"
rcvar=socat_enable
-command=%%PREFIX%%/bin/${name}
-command_args="&"
-
load_rc_config $name
: ${socat_enable="NO"}
+socat_flags="%%PREFIX%%/bin/socat ${socat_flags} &"
+command="%%PREFIX%%/sbin/socat_wrapper"
+command_interpreter="/bin/sh -T"
+pidfile=/var/run/socat_wrapper.pid
+
run_rc_command "$1"
diff -ruN --exclude=CVS ../socat.orig/files/socat_wrapper ./files/socat_wrapper
--- ../socat.orig/files/socat_wrapper 1969-12-31 18:00:00.000000000 -0600
+++ ./files/socat_wrapper 2012-04-14 11:08:01.000000000 -0500
@@ -0,0 +1,91 @@
+#!/bin/sh -T
+#
+#-
+# Copyright 2009 Thomas-Martin Seck. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. 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.
+#
+# THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR OR CONTRIBUTORS 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.
+#
+# $FreeBSD: ports/www/gatling/files/gatling_wrapper,v 1.1 2009/05/28 17:21:46 dhn Exp $
+#
+# gatling_wrapper {gatling|tlsgatling} [options]
+#
+# A simple wrapper script for gatling (or any other program that does not
+# daemonize itself and logs to stdout).
+#
+# This wrapper tries to emulate part of the functionality usually supplied
+# by software like daemontools or runit.
+# It can be used by a FreeBSD port rc.d script to start a program
+# that does not daemonize itself and logs to stdout/stderr. It redirects stdout
+# and stderr to logger(1) via a fifo.
+#
+# Note: We need a shell that can offer us asynchronous trap handling in order
+# to be able to abort the infinite loop from outside. FreeBSD's /bin/sh offers
+# the "-T" switch for this purpose.
+#
+# TODO: send fd 2 output to never-never land to get rid of "Terminated" when we
+# kill this script but provide a way for errx() to communicate with the outside
+# world via stderr.
+
+errx() {
+ echo "${me}: $@" >&2
+ exit 1
+}
+
+cleanup() {
+ rm -rf ${tmpdir}
+ rm -f ${pidfile}
+}
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+me=${0##*/}
+logger=/usr/bin/logger
+daemon_log_facility=daemon.notice
+self_log_facility=daemon.notice
+pidfile=/var/run/${me}.pid
+daemon_name=socat
+daemon_program="$1"
+shift
+
+test -x "${daemon_program}" || errx "cannot execute ${daemon_program}!"
+test -x ${logger} || errx "cannot execute ${logger}!"
+test -f ${pidfile} && errx "${pidfile} is already present -- is another instance of ${me} running?"
+echo $$ >${pidfile} || errx "cannot write to ${pidfile}!"
+tmpdir=`mktemp -d /tmp/${me}.XXXXXXXXXX` || errx "cannot generate tmpdir!"
+
+logfifo=${tmpdir}/fifo
+mkfifo -m 0600 ${logfifo} || errx "cannot generate fifo!"
+
+while true; do
+ trap 'break' 1 2 3 6 9 15
+ ${logger} -i -p ${daemon_log_facility} -t ${daemon_name} <${logfifo} &
+ log_pid=$!
+ "${daemon_program}" $@ >${logfifo} 2>&1 &
+ daemon_pid=$!
+ wait ${daemon_pid}
+ ${logger} -i -p ${self_log_facility} -t ${me} "${daemon_program} died -- restarting..."
+ sleep 2
+done
+
+kill -TERM ${daemon_pid} 2>/dev/null
+wait
+cleanup
--- socat-1.7.2.0_1.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list