ports/176321: [PATCH] net/socat: rc script / daemon changes
Mark Felder
feld at feld.me
Thu Feb 21 13:40:03 UTC 2013
>Number: 176321
>Category: ports
>Synopsis: [PATCH] net/socat: rc script / daemon changes
>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: Thu Feb 21 13:40:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: feld
>Release: FreeBSD 9.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD mwi1.coffeenet.org 9.1-RELEASE FreeBSD 9.1-RELEASE #6 r243808: Mon Dec 3 07:51:34
>Description:
Last year when I submitted a patch to make socat properly daemonize I was unaware
of the existence of daemon(8). This patch changes the rc script to
launch socat using daemon and removes the unnecessary wrapper script.
Removed file(s):
- files/socat_wrapper
Port maintainer (ehaupt at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix)
>How-To-Repeat:
>Fix:
--- socat-1.7.2.1_1.patch begins here ---
diff -ruN --exclude=CVS ../socat.orig/Makefile ./Makefile
--- ../socat.orig/Makefile 2013-01-15 07:46:57.000000000 -0600
+++ ./Makefile 2013-02-21 07:26:49.436309121 -0600
@@ -3,6 +3,7 @@
PORTNAME= socat
PORTVERSION= 1.7.2.1
+PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= http://www.dest-unreach.org/socat/download/ \
CRITICAL
@@ -21,7 +22,7 @@
PORTSCOUT= skipv:2.0.0-b2
MAN1= socat.1
-PLIST_FILES= bin/filan bin/procan bin/socat sbin/socat_wrapper
+PLIST_FILES= bin/filan bin/procan bin/socat
PORTDOCS= EXAMPLES README SECURITY FAQ
.if ${CC} == clang
@@ -36,7 +37,6 @@
.for f in filan procan socat
${INSTALL_PROGRAM} ${WRKSRC}/${f} ${PREFIX}/bin
.endfor
- ${INSTALL_SCRIPT} ${FILESDIR}/socat_wrapper ${PREFIX}/sbin
${INSTALL_MAN} ${WRKSRC}/doc/${MAN1} ${MAN1PREFIX}/man/man1
.if ${PORT_OPTIONS:MDOCS}
${MKDIR} ${DOCSDIR}
diff -ruN --exclude=CVS ../socat.orig/files/socat.in ./files/socat.in
--- ../socat.orig/files/socat.in 2012-11-17 00:00:21.000000000 -0600
+++ ./files/socat.in 2013-02-21 07:23:42.692312424 -0600
@@ -22,9 +22,13 @@
: ${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
+start_cmd="${name}_start"
+pidfile=/var/run/socat.pid
+command="%%PREFIX%%/bin/socat"
+
+socat_start() {
+ echo "Starting ${name}."
+ /usr/sbin/daemon -f -p ${pidfile} ${command} ${socat_flags}
+}
run_rc_command "$1"
diff -ruN --exclude=CVS ../socat.orig/files/socat_wrapper ./files/socat_wrapper
--- ../socat.orig/files/socat_wrapper 2012-11-17 00:00:21.000000000 -0600
+++ ./files/socat_wrapper 1969-12-31 18:00:00.000000000 -0600
@@ -1,91 +0,0 @@
-#!/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/net/socat/files/socat_wrapper,v 1.2 2012/11/17 06:00:21 svnexp Exp $
-#
-# socat_wrapper socat [options]
-#
-# A simple wrapper script for socat (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.1_1.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list