aboutsummaryrefslogtreecommitdiff
path: root/www/httptunnel/files/htc.in
blob: f01bb78b0a93ac557488ce147d086df9613cb414 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/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.
#

. /etc/rc.subr

name="htc"
rcvar=htc_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_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"