Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# $FreeBSD$ |
4 |
# PROVIDE: buildbot-worker |
5 |
# REQUIRE: LOGIN |
6 |
# KEYWORD: shutdown |
7 |
# |
8 |
# Add the following lines to /etc/rc.conf to run buildbot-worker: |
9 |
# |
10 |
# buildbot_worker_enable (bool): Set to "YES" to enable buildbot-worker. |
11 |
# Default: "NO" |
12 |
# |
13 |
# buildbot_worker_flags (flags): Set extra command flags here. See buildbot-worker(8) |
14 |
# Default: Empty (""). |
15 |
# |
16 |
# buildbot_worker_uid (user): User to run buildbot-worker as. |
17 |
# Default: "buildbot" |
18 |
# |
19 |
# buildbot_worker_gid (group): Group to run buildbot-worker as. |
20 |
# Default: "buildbot" |
21 |
# |
22 |
# buildbot_worker_basedir (path): Location for buildbot-worker base directory |
23 |
# Default: %%PREFIX%%/etc/buildbot-worker |
24 |
# |
25 |
# buildbot_worker_profiles (str): Define profiles names. Space-delimited. |
26 |
# Default: Empty ("") |
27 |
# |
28 |
# This rc.d script supports multiple "profiles". When profiles are |
29 |
# specified, the non-profile specific parameters become defaults. |
30 |
# |
31 |
# Example: |
32 |
# |
33 |
# buildbot_worker_profiles="foo bar" |
34 |
# |
35 |
# buildbot_worker_foo_enable="YES" |
36 |
# buildbot_worker_foo_basedir="/usr/home/foo/buildbot" |
37 |
# buildbot_worker_foo_uid="foo" |
38 |
# buildbot_worker_foo_gid="foo" |
39 |
# |
40 |
# buildbot_worker_bar_enable="YES" |
41 |
# buildbot_worker_bar_basedir="/usr/home/buildbot/" |
42 |
|
43 |
. /etc/rc.subr |
44 |
|
45 |
export PATH=${PATH}:%%LOCALBASE%%/bin |
46 |
|
47 |
name=buildbot-worker |
48 |
desc="Buildbot Buildworker" |
49 |
rcvar=buildbot_worker_enable |
50 |
|
51 |
load_rc_config ${name} |
52 |
|
53 |
# These are just the defaults, they might get overriden for a specific profile. |
54 |
eval ": \${${name}_enable:=\"NO\"}" |
55 |
eval ": \${${name}_flags:=\"\"}" |
56 |
eval ": \${${name}_uid:=\"buildbot\"}" |
57 |
eval ": \${${name}_gid:=\"buildbot\"}" |
58 |
eval ": \${${name}_basedir:=\"%%PREFIX%%/etc/${name}\"}" |
59 |
|
60 |
command="%%PREFIX%%/bin/twistd" |
61 |
command_interpreter="%%PYTHON_CMD%%" |
62 |
pidfile="${buildbot_worker_basedir}/twistd.pid" |
63 |
|
64 |
# A specific profile is specified in the command |
65 |
if [ -n "$2" ]; then |
66 |
profile="$2" |
67 |
# Override defaults with profile-specific values |
68 |
if [ -n "${buildbot_worker_profiles}" ]; then |
69 |
eval buildbot_worker_enable="\${buildbot_worker_${profile}_enable:-${buildbot_worker_enable}}" |
70 |
eval buildbot_worker_flags="\${buildbot_worker_${profile}_flags:-${buildbot_worker_flags}}" |
71 |
eval buildbot_worker_uid="\${buildbot_worker_${profile}_uid:-${buildbot_worker_uid}}" |
72 |
eval buildbot_worker_gid="\${buildbot_worker_${profile}_gid:-${buildbot_worker_gid}}" |
73 |
eval buildbot_worker_basedir="\${buildbot_worker_${profile}_basedir:-${buildbot_worker_basedir}}" |
74 |
eval pidfile="\${buildbot_worker_${profile}_basedir:-${buildbot_worker_basedir}}/twistd.pid" |
75 |
else |
76 |
echo "%%PREFIX%%/etc/rc.d/${name}: extra argument ignored" |
77 |
fi |
78 |
# A specific profile is not in the command |
79 |
else |
80 |
# Check if any profiles are defined |
81 |
if [ -n "$1" -a -n "${buildbot_worker_profiles}" ]; then |
82 |
# Loop through them |
83 |
for profile in ${buildbot_worker_profiles}; do |
84 |
eval _enable="\${buildbot_worker_${profile}_enable}" |
85 |
case "${_enable:-${buildbot_worker_enable}}" in |
86 |
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) |
87 |
continue |
88 |
;; |
89 |
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) |
90 |
;; |
91 |
*) |
92 |
if test -z "$_enable"; then |
93 |
_var=buildbot_worker_enable |
94 |
else |
95 |
_var=buildbot_worker_"${profile}"_enable |
96 |
fi |
97 |
warn "Bad value" \ |
98 |
"'${_enable:-${buildbot_worker_enable}}'" \ |
99 |
"for ${_var}. " \ |
100 |
"Profile ${profile} skipped." |
101 |
continue |
102 |
;; |
103 |
esac |
104 |
echo "===> ${name} profile: ${profile}" |
105 |
if %%PREFIX%%/etc/rc.d/${name} $1 ${profile}; then |
106 |
success="${profile} ${success:-}" |
107 |
else |
108 |
failed="${profile} (${retcode}) ${failed:-}" |
109 |
fi |
110 |
done |
111 |
# Exit so that non-profile rc.d is not started when there are profiles |
112 |
exit 0 |
113 |
fi |
114 |
fi |
115 |
|
116 |
# run_rc_command would send ${name}_flags as parameters to $command (daemon) |
117 |
# This ensures they are actually passed to fcgiwrap instead. |
118 |
actual_buildbot_worker_flags="${buildbot_worker_flags}" |
119 |
buildbot_worker_flags="" |
120 |
command_args="--uid=${buildbot_worker_uid} --gid=${buildbot_worker_gid} --pidfile=${pidfile} --python=${buildbot_worker_basedir}/buildbot.tac ${actual_buildbot_worker_flags}" |
121 |
run_rc_command "$1" |