Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: pounce |
4 |
# REQUIRE: LOGIN |
5 |
# KEYWORD: shutdown |
6 |
|
7 |
# Add the following lines to /etc/rc.conf to enable pounce: |
8 |
# |
9 |
# pounce_enable="YES" |
10 |
# pounce_user="example" |
11 |
# pounce_flags="example.conf" |
12 |
# |
13 |
# The pounce rc.d script supports multiple profiles. When profiles are |
14 |
# specified, the non-profile-specific parameters become defaults. |
15 |
# Example: |
16 |
# |
17 |
# pounce_enable="YES" |
18 |
# pounce_user="example" |
19 |
# pounce_profiles="server1 server2" |
20 |
# pounce_server1_flags="server1.conf" |
21 |
# pounce_server2_flags="server2.conf" |
22 |
|
23 |
. /etc/rc.subr |
24 |
|
25 |
name='pounce' |
26 |
rcvar='pounce_enable' |
27 |
extra_commands='reload' |
28 |
sig_reload='USR1' |
29 |
|
30 |
load_rc_config "${name}" |
31 |
|
32 |
: ${pounce_enable:='NO'} |
33 |
|
34 |
command='/usr/sbin/daemon' |
35 |
pidprefix="/var/run/${name}" |
36 |
pidfile="${pidprefix}.pid" |
37 |
|
38 |
child_command='%%PREFIX%%/bin/pounce' |
39 |
child_pidfile="${pidprefix}.child.pid" |
40 |
|
41 |
if [ -n "$2" ]; then |
42 |
profile=$2 |
43 |
if [ -n "${pounce_profiles}" ]; then |
44 |
pidfile="${pidprefix}.${profile}.pid" |
45 |
child_pidfile="${pidprefix}.${profile}.child.pid" |
46 |
eval pounce_enable="\${pounce_${profile}_enable:-${pounce_enable}}" |
47 |
eval pounce_flags="\${pounce_${profile}_flags:-${pounce_flags}}" |
48 |
eval pounce_user="\${pounce_${profile}_user:-${pounce_user}}" |
49 |
eval pounce_env="\${pounce_${profile}_env:-${pounce_env}}" |
50 |
export HOME="$(/usr/bin/getent passwd ${pounce_user} | /usr/bin/cut -d: -f6)" |
51 |
else |
52 |
echo "$0: extra argument ignored" |
53 |
fi |
54 |
else |
55 |
if [ -n "${pounce_profiles}" -a -n "$1" ]; then |
56 |
for profile in ${pounce_profiles}; do |
57 |
echo "===> ${name} profile: ${profile}" |
58 |
%%PREFIX%%/etc/rc.d/${name} "$1" "${profile}" || exit "$?" |
59 |
done |
60 |
exit |
61 |
fi |
62 |
fi |
63 |
|
64 |
child_flags=$pounce_flags |
65 |
child_user=$pounce_user |
66 |
unset pounce_flags pounce_user |
67 |
command_args="\ |
68 |
-r -P ${pidfile} -p ${child_pidfile} -T ${name}${profile:+/${profile}} \ |
69 |
${child_user:+-u ${child_user}} \ |
70 |
-- ${child_command} ${child_flags}" |
71 |
|
72 |
pounce_reload() { |
73 |
rc_pid=$(check_pidfile "$child_pidfile" "$child_command") |
74 |
kill "-$sig_reload" "$rc_pid" |
75 |
} |
76 |
reload_cmd='pounce_reload' |
77 |
|
78 |
run_rc_command "$1" |