Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: pounce |
4 |
# REQUIRE: LOGIN |
5 |
# KEYWORD: shutdown |
6 |
|
7 |
. /etc/rc.subr |
8 |
|
9 |
name='pounce' |
10 |
rcvar='pounce_enable' |
11 |
extra_commands='reload' |
12 |
sig_reload='USR1' |
13 |
|
14 |
load_rc_config "${name}" |
15 |
|
16 |
: ${pounce_enable:='NO'} |
17 |
: ${pounce_chdir:="%%PREFIX%%/etc/${name}"} |
18 |
|
19 |
command='/usr/sbin/daemon' |
20 |
pidprefix="/var/run/${name}" |
21 |
pidfile="${pidprefix}.pid" |
22 |
required_dirs=$pounce_chdir |
23 |
|
24 |
child_command='%%PREFIX%%/bin/pounce' |
25 |
child_pidfile="${pidprefix}.child.pid" |
26 |
|
27 |
if [ -n "$2" ]; then |
28 |
profile=$2 |
29 |
if [ -n "${pounce_profiles}" ]; then |
30 |
pidfile="${pidprefix}.${profile}.pid" |
31 |
child_pidfile="${pidprefix}.${profile}.child.pid" |
32 |
eval pounce_enable="\${pounce_${profile}_enable:-${pounce_enable}}" |
33 |
eval pounce_flags="\${pounce_${profile}_flags:-${pounce_flags}}" |
34 |
eval pounce_chdir="\${pounce_${profile}_chdir:-${pounce_chdir}}" |
35 |
eval pounce_user="\${pounce_${profile}_user:-${pounce_user}}" |
36 |
eval pounce_env="\${pounce_${profile}_env:-${pounce_env}}" |
37 |
export HOME="$(/usr/bin/getent passwd ${pounce_user} | /usr/bin/cut -d: -f6)" |
38 |
else |
39 |
echo "$0: extra argument ignored" |
40 |
fi |
41 |
else |
42 |
if [ -n "${pounce_profiles}" -a -n "$1" ]; then |
43 |
for profile in ${pounce_profiles}; do |
44 |
echo "===> ${name} profile: ${profile}" |
45 |
%%PREFIX%%/etc/rc.d/${name} "$1" "${profile}" || exit "$?" |
46 |
done |
47 |
exit |
48 |
fi |
49 |
fi |
50 |
|
51 |
child_flags=$pounce_flags |
52 |
child_user=$pounce_user |
53 |
unset pounce_flags pounce_user |
54 |
command_args="\ |
55 |
-r -P ${pidfile} -p ${child_pidfile} -T ${name}${profile:+/${profile}} \ |
56 |
${child_user:+-u ${child_user}} \ |
57 |
-- ${child_command} ${child_flags}" |
58 |
|
59 |
pounce_reload() { |
60 |
rc_pid=$(check_pidfile "$child_pidfile" "$child_command") |
61 |
kill "-$sig_reload" "$rc_pid" |
62 |
} |
63 |
reload_cmd='pounce_reload' |
64 |
|
65 |
run_rc_command "$1" |