Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: microsocks |
4 |
# REQUIRE: LOGIN |
5 |
# KEYWORD: shutdown |
6 |
|
7 |
# Add these lines to /etc/rc.conf.local or /etc/rc.conf |
8 |
# to enable this service: |
9 |
# |
10 |
# microsocks_enable (bool): Enable microsocks |
11 |
# Default: NO |
12 |
# microsocks_user (str): User to run microsocks under |
13 |
# Default: unset |
14 |
# microsocks_args (str): Arguments for microsocks |
15 |
# Default: unset |
16 |
# microsocks_syslog_enable(bool): Enable writing output to syslog. |
17 |
# Default: YES |
18 |
# microsocks_syslog_tag(str): Syslog tag if syslog enabled. |
19 |
# Default: microsocks |
20 |
# microsocks_syslog_priority(str): Syslog priority if syslog enabled. |
21 |
# Default: info |
22 |
# microsocks_syslog_facility(str): Syslog facility if syslog enabled. |
23 |
# Default: daemon |
24 |
|
25 |
. /etc/rc.subr |
26 |
|
27 |
name=microsocks |
28 |
rcvar=microsocks_enable |
29 |
|
30 |
load_rc_config $name |
31 |
|
32 |
: ${microsocks_enable:="NO"} |
33 |
: ${microsocks_syslog_enable:="YES"} |
34 |
|
35 |
start_precmd=microsocks_prestart |
36 |
stop_postcmd=microsocks_poststop |
37 |
|
38 |
if checkyesno microsocks_syslog_enable; then |
39 |
if [ -n "${microsocks_syslog_tag}" ]; then |
40 |
microsocks_syslog_flags="-T ${microsocks_syslog_tag}" |
41 |
else |
42 |
microsocks_syslog_flags="-T ${name}" |
43 |
fi |
44 |
if [ -n "${microsocks_syslog_priority}" ]; then |
45 |
microsocks_syslog_flags="${microsocks_syslog_flags} -s ${microsocks_syslog_priority}" |
46 |
fi |
47 |
if [ -n "${microsocks_syslog_facility}" ]; then |
48 |
microsocks_syslog_flags="${microsocks_syslog_flags} -l ${microsocks_syslog_facility}" |
49 |
fi |
50 |
fi |
51 |
|
52 |
pidfile="/var/run/${name}.pid" |
53 |
microsocks_command="%%PREFIX%%/bin/${name}" |
54 |
command="/usr/sbin/daemon" |
55 |
command_args="-f ${microsocks_syslog_flags} -P ${pidfile} -t ${name} ${microsocks_command} ${microsocks_args}" |
56 |
|
57 |
microsocks_prestart() |
58 |
{ |
59 |
if [ -z "${microsocks_user}" ]; then |
60 |
err 3 "microsocks: microsocks_user unset. Set it to an existing user and try again." |
61 |
fi |
62 |
install -m 0600 -o "${microsocks_user}" /dev/null "${pidfile}" |
63 |
} |
64 |
|
65 |
microsocks_poststop() |
66 |
{ |
67 |
rm -f "${pidfile}" |
68 |
} |
69 |
|
70 |
run_rc_command "$1" |