aboutsummaryrefslogtreecommitdiff
path: root/net/socat
diff options
context:
space:
mode:
authorEmanuel Haupt <ehaupt@FreeBSD.org>2013-03-08 06:40:12 +0000
committerEmanuel Haupt <ehaupt@FreeBSD.org>2013-03-08 06:40:12 +0000
commitef17068bee7090421d73accb2f459a15128dbefd (patch)
tree387f57a434bc433ae78b41652a972452150cc047 /net/socat
parentd62d1c29b2db16539c364d6d9c61d78b5672fab1 (diff)
downloadports-ef17068bee7090421d73accb2f459a15128dbefd.tar.gz
ports-ef17068bee7090421d73accb2f459a15128dbefd.zip
Change rc script to launch socat using daemon and remove the unnecessary
wrapper script. PR: 176321 Submitted by: Mark Felder <feld@feld.me>
Notes
Notes: svn path=/head/; revision=313620
Diffstat (limited to 'net/socat')
-rw-r--r--net/socat/Makefile4
-rw-r--r--net/socat/files/socat.in12
-rw-r--r--net/socat/files/socat_wrapper91
3 files changed, 10 insertions, 97 deletions
diff --git a/net/socat/Makefile b/net/socat/Makefile
index 92952481b753..fbeb601b0310 100644
--- a/net/socat/Makefile
+++ b/net/socat/Makefile
@@ -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 @@ MAKE_JOBS_SAFE= yes
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 @@ do-install:
.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 --git a/net/socat/files/socat.in b/net/socat/files/socat.in
index e781a35f359a..8b6b943044dc 100644
--- a/net/socat/files/socat.in
+++ b/net/socat/files/socat.in
@@ -22,9 +22,13 @@ 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
+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 --git a/net/socat/files/socat_wrapper b/net/socat/files/socat_wrapper
deleted file mode 100644
index db6afeb119d9..000000000000
--- a/net/socat/files/socat_wrapper
+++ /dev/null
@@ -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$
-#
-# 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