1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-19 00:13:33 +00:00

Rework on rc script for www/httptunnel.

- Use fixed uid and gid
- Rewrite the rc script to use the new rc.d style and split into two scripts:
  hts (for server) and htc (for client)
- Bump PORTREVISION for this

PR:		ports/125714 (based on)
Submitted by:	G.V. Tjong A Hung <gvtjongahung at users.sourceforge.net> (based on)
This commit is contained in:
Rong-En Fan 2009-01-30 10:24:07 +00:00
parent c8bb0fd24d
commit cebdb0c2fc
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=227156
10 changed files with 208 additions and 70 deletions

1
GIDs
View File

@ -104,6 +104,7 @@ wildfire:*:340:
stunnel:*:341:
openfire:*:342:
_iodined:*:353:
httptunnel:*:361:
ldap:*:389:
tiarra:*:398:
drweb:*:426:

1
UIDs
View File

@ -115,6 +115,7 @@ wildfire:*:340:340::0:0:Wildfire Daemon:/nonexistent:/usr/sbin/nologin
stunnel:*:341:341::0:0:Stunnel Daemon:/nonexistent:/usr/sbin/nologin
openfire:*:342:342::0:0:Openfire IM Daemon:/nonexistent:/usr/sbin/nologin
_iodined:*:353:353::0:0:Iodine Daemon:/nonexistent:/usr/sbin/nologin
httptunnel:*:361:361::0:0:httptunnel Daemon:/nonexistent:/usr/sbin/nologin
ldap:*:389:389::0:0:OpenLDAP Server:/nonexistent:/usr/sbin/nologin
tiarra:*:398:398::0:0:Tiarra IRC Proxy:/nonexistent:/usr/sbin/nologin
drweb:*:426:426::0:0:Dr.Web Mail Scanner:/nonexistent:/usr/sbin/nologin

View File

@ -6,6 +6,14 @@ You should get into the habit of checking this file for changes each
time you update your ports collection, before attempting any port
upgrades.
20090130:
AFFECTS: users of www/httptunnel
AUTHOR: rafan@FreeBSD.org
The startup script has been converted to new rc.d style and split
into two scripts: htc (client) and hts (server). Please check the scripts
for how to set variables in /etc/rc.conf.
20090127:
AFFECTS: gstreamer-plugins
AUTHOR: kwm@FreeBSD.org

View File

@ -7,7 +7,7 @@
PORTNAME= httptunnel
PORTVERSION= 3.3
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= www
MASTER_SITES= http://www.Awfulhak.org/httptunnel/ \
ftp://ftp.nocrew.org/pub/nocrew/unix/ \
@ -16,16 +16,18 @@ MASTER_SITES= http://www.Awfulhak.org/httptunnel/ \
MAINTAINER= ports@FreeBSD.org
COMMENT= Tunnel a tcp/ip connection through a http/tcp/ip connection
HAS_CONFIGURE= yes
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --quiet
.if defined(ENABLE_DEBUG)
CONFIGURE_ARGS+=--enable-debug
.endif
MAN1= hts.1 htc.1
USE_RC_SUBR= hts htc
PLIST_FILES= bin/hts bin/htc
post-install:
${SED} -e 's,%%PREFIX%%,${PREFIX},g' ${FILESDIR}/httptunnel.sh \
>${PREFIX}/etc/rc.d/httptunnel.sh
${CHMOD} 755 ${PREFIX}/etc/rc.d/httptunnel.sh
@${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
.include <bsd.port.mk>

View File

@ -0,0 +1,77 @@
#!/bin/sh
# PROVIDE: htc
# REQUIRE: LOGIN
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# htc_enable (bool): Set to NO by default.
# Set it to YES to enable httptunnel client.
# htc_port (string): host:port where hts is running
# htc_forward (string): Talk to this socket.
# htc_device (string): *or* talk to this device.
#
# htc_proxy (string): host:port of proxy to talk to hts via
# htc_proxyauth (string): user:password to pass to proxy, or a file
# htc_proxybuffer (string): Buffer size for buffered proxies.
# Default set to "1K".
# htc_browser (string): Pretend to be this browser.
# Default set to "Mozilla/4.7 [en] (X11; I; Linux 2.2.12 i386)".
# htc_flags (string): additional arguments to htc. Default set to -S.
#
. %%RC_SUBR%%
name="htc"
rcvar=${name}_enable
command=%%PREFIX%%/bin/${name}
start_precmd="htc_prestart"
htc_prestart()
{
if checkyesno htc_enable; then
if [ -z "$htc_device" -a -z "$htc_forward" ]; then
err 1 "Specify either htc_device or htc_forward"
fi
fi
return 0
}
load_rc_config $name
: ${htc_enable="NO"}
: ${htc_user="httptunnel"}
: ${htc_port=""}
: ${htc_forward=""}
: ${htc_device=""}
: ${htc_proxy=""}
: ${htc_proxyauth=""}
: ${htc_proxybuffer="1K"}
: ${htc_browser="Mozilla/4.7 [en] (X11; I; Linux 2.2.12 i386)"}
: ${htc_flags="-S"}
[ -n "$htc_forward" ] && command_args="-F $htc_forward"
[ -n "$htc_device" ] && command_args="-d $htc_device"
[ -n "$htc_browser" ] && command_args="-U '\"'\"'$htc_browser'\"'\"' $command_args"
if [ -n "$htc_proxy" ]; then
[ -n "$htc_proxybuffer" ] && command_args="-B $htc_proxybuffer $command_args"
if [ -n "$htc_proxyauth" ]; then
if [ -f "$htc_proxyauth" ]; then
command_args="--proxy-authorization-file $htc_proxyauth $command_args"
else
command_args="-A $htc_proxyauth $command_args"
fi
fi
command_args="-P $htc_proxy $command_args"
fi
command_args="$command_args $htc_port"
run_rc_command "$1"

View File

@ -0,0 +1,51 @@
#!/bin/sh
# PROVIDE: hts
# REQUIRE: LOGIN
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# hts_enable (bool): Set to NO by default.
# Set it to YES to enable httptunnel server.
# hts_port (string): [host:]port to listen for htc connection.
# Set to 8888 by default.
# hts_forward (string): Talk to this socket.
# hts_device (string): *or* talk to this device.
# hts_flags (string): Additional flags for hts.
#
. %%RC_SUBR%%
name="hts"
rcvar=${name}_enable
command=%%PREFIX%%/bin/${name}
start_precmd="hts_prestart"
hts_prestart()
{
if checkyesno hts_enable; then
if [ -z "$hts_device" -a -z "$hts_forward" ]; then
err 1 "Specify either hts_device or hts_forward"
fi
fi
return 0
}
load_rc_config $name
: ${hts_enable="NO"}
: ${hts_user="httptunnel"}
: ${hts_port="8888"}
: ${hts_device=""}
: ${hts_forward=""}
[ -n "$hts_device" ] && command_args="-d $hts_device"
[ -n "$hts_forward" ] && command_args="-F $hts_forward"
command_args="$command_args $hts_port"
run_rc_command "$1"

View File

@ -1,62 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
USER=httptunnel
HTS=%%PREFIX%%/bin/hts # The installed hts program
HTSPORT= # [host:]port to listen for htc connection
HTSFORWARD= # Talk to this socket
HTSDEVICE= # *or* talk to this device
HTC=%%PREFIX%%/bin/htc # The installed htc program
HTCPORT= # host:port where hts is running
HTCFORWARD= # Talk to this socket
HTCDEVICE= # *or* talk to this device
HTCPROXY= # host:port of proxy to talk to hts via
HTCPROXYAUTH= # user:password to pass to proxy
HTCPROXYBUFFER=1K # Buffer size for buffered proxies
HTCBROWSER='Mozilla/4.7 [en] (X11; I; Linux 2.2.12 i386)' # Pretend to be this
HTCARGS=-S # Any other arguments required
case $1 in
start)
if [ -n "$HTSPORT" -a -x $HTS ]; then
[ -n "$HTSFORWARD" ] && args="-F $HTSFORWARD"
[ -n "$HTSDEVICE" ] && args="-d $HTSDEVICE"
su -m $USER -c "$HTS $args $HTSPORT" && echo -n ' hts'
fi
if [ -n "$HTCPORT" -a -x $HTC ]; then
[ -n "$HTCFORWARD" ] && args="-F $HTCFORWARD"
[ -n "$HTCDEVICE" ] && args="-d $HTCDEVICE"
[ -n "$HTCBROWSER" ] && args="-U \"$HTCBROWSER\" $args"
if [ -n "$HTCPROXY" ]; then
[ -n "$HTCPROXYBUFFER" ] &&
args="-B $HTCPROXYBUFFER $args"
if [ -n "$HTCPROXYAUTH" ]
then
if [ -f "$HTCPROXYAUTH" ]
then
args="--proxy-authorization-file $HTCPROXYAUTH $args"
else
args="-A $HTCPROXYAUTH $args"
fi
fi
args="-P $HTCPROXY $args"
fi
su -m $USER -c "$HTC $args $HTCARGS $HTCPORT" && echo -n ' htc'
fi
;;
stop)
killall htc && echo -n ' htc'
killall hts && echo -n ' hts'
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exit 0

View File

@ -0,0 +1,27 @@
#!/bin/sh
case $2 in
POST-DEINSTALL)
USER=httptunnel
GROUP=${USER}
PW=/usr/sbin/pw
if ${PW} groupshow "${GROUP}" 2>/dev/null 1>&2; then
if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
echo "To delete the ${USER} group permanently, use '${PW} groupdel ${GROUP}'."
else
${PW} groupdel ${USER}
fi
fi
if ${PW} usershow "${USER}" 2>/dev/null 1>&2; then
if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
echo "To delete the ${USER} user permanently, use '${PW} userdel ${USER}'."
else
${PW} userdel ${USER}
fi
fi
exit 0
;;
esac

View File

@ -0,0 +1,36 @@
#!/bin/sh
case $2 in
POST-INSTALL)
USER=httptunnel
GROUP=${USER}
UID=361
GID=${UID}
PW=/usr/sbin/pw
if ${PW} group show "${GROUP}" 2>/dev/null; then
echo "You already have a group \"${GROUP}\", so I will use it."
else
if ${PW} groupadd ${GROUP} -g ${GID}; then
echo "Added group \"${GROUP}\"."
else
echo "Adding group \"${GROUP}\" failed..."
exit 1
fi
fi
if ${PW} user show "${USER}" 2>/dev/null; then
echo "You already have a user \"${USER}\", so I will use it."
else
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
-d "/var/empty" -s /sbin/nologin -c "OSPF Daemon"
then
echo "Added user \"${USER}\"."
else
echo "Adding user \"${USER}\" failed..."
exit 1
fi
fi
exit 0
;;
esac

View File

@ -1,3 +0,0 @@
bin/hts
bin/htc
etc/rc.d/httptunnel.sh