diff options
author | rafan <rafan@FreeBSD.org> | 2009-01-30 18:24:07 +0800 |
---|---|---|
committer | rafan <rafan@FreeBSD.org> | 2009-01-30 18:24:07 +0800 |
commit | ad9ae7c1c78619576d8330dde328374e6e32376d (patch) | |
tree | 33b0c7a34b3445f9d552296cbd0ef2721b662c67 /www/httptunnel | |
parent | c8a94b670ab290731c0acca69f3950ac528b693a (diff) | |
download | freebsd-ports-gnome-ad9ae7c1c78619576d8330dde328374e6e32376d.tar.gz freebsd-ports-gnome-ad9ae7c1c78619576d8330dde328374e6e32376d.tar.zst freebsd-ports-gnome-ad9ae7c1c78619576d8330dde328374e6e32376d.zip |
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)
Diffstat (limited to 'www/httptunnel')
-rw-r--r-- | www/httptunnel/Makefile | 12 | ||||
-rw-r--r-- | www/httptunnel/files/htc.in | 77 | ||||
-rw-r--r-- | www/httptunnel/files/hts.in | 51 | ||||
-rw-r--r-- | www/httptunnel/files/httptunnel.sh | 62 | ||||
-rw-r--r-- | www/httptunnel/pkg-deinstall | 27 | ||||
-rw-r--r-- | www/httptunnel/pkg-install | 36 | ||||
-rw-r--r-- | www/httptunnel/pkg-plist | 3 |
7 files changed, 198 insertions, 70 deletions
diff --git a/www/httptunnel/Makefile b/www/httptunnel/Makefile index f1e198ff1167..0e55ab66a180 100644 --- a/www/httptunnel/Makefile +++ b/www/httptunnel/Makefile @@ -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> diff --git a/www/httptunnel/files/htc.in b/www/httptunnel/files/htc.in new file mode 100644 index 000000000000..7083d4f4cb49 --- /dev/null +++ b/www/httptunnel/files/htc.in @@ -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" diff --git a/www/httptunnel/files/hts.in b/www/httptunnel/files/hts.in new file mode 100644 index 000000000000..7714b619fdad --- /dev/null +++ b/www/httptunnel/files/hts.in @@ -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" diff --git a/www/httptunnel/files/httptunnel.sh b/www/httptunnel/files/httptunnel.sh deleted file mode 100644 index 6cc2093ea69e..000000000000 --- a/www/httptunnel/files/httptunnel.sh +++ /dev/null @@ -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 diff --git a/www/httptunnel/pkg-deinstall b/www/httptunnel/pkg-deinstall new file mode 100644 index 000000000000..b711522d0c7f --- /dev/null +++ b/www/httptunnel/pkg-deinstall @@ -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 diff --git a/www/httptunnel/pkg-install b/www/httptunnel/pkg-install new file mode 100644 index 000000000000..72e86717a570 --- /dev/null +++ b/www/httptunnel/pkg-install @@ -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 diff --git a/www/httptunnel/pkg-plist b/www/httptunnel/pkg-plist deleted file mode 100644 index 0ed52c93d29f..000000000000 --- a/www/httptunnel/pkg-plist +++ /dev/null @@ -1,3 +0,0 @@ -bin/hts -bin/htc -etc/rc.d/httptunnel.sh |