blob: 4b6dd5c4a9e9dd00ff96a516514659281d4e0ee3 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/sh
# PROVIDE: buildbot-worker
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable buildbot-worker:
#
# buildbot_worker_enable (bool): Set to "YES" to enable buildbot-worker.
# Default: "NO"
# buildbot_worker_flags (flags): Set extra command flags here. See buildbot-worker(8)
# Default: Empty ("").
# buildbot_worker_user (user): User to run buildbot-worker as.
# Default: "buildbot"
# buildbot_worker_basedir (path): Location for buildbot-worker base directory
# Default: /usr/local/etc/buildbot-worker
# buildbot_worker_profiles (str): Define profiles names. Space-delimited.
# Default: Empty ("")
#
# This rc.d script supports multiple "profiles". When profiles are
# specified, the non-profile specific parameters become defaults.
#
# Example:
#
# buildbot_worker_profiles="foo bar"
#
# buildbot_worker_foo_enable="YES"
# buildbot_worker_foo_basedir="/var/db/buildbot/workers/foo"
# buildbot_worker_foo_user="foo"
#
# buildbot_worker_bar_enable="YES"
# buildbot_worker_bar_basedir="/var/db/buildbot/workers/bar"
. /etc/rc.subr
export PATH=${PATH}:%%LOCALBASE%%/bin
name="buildbot_worker"
desc="Buildbot Buildworker"
rcvar=buildbot_worker_enable
command="/usr/local/bin/buildbot-worker-3.9"
load_rc_config ${name}
# These are just the defaults, they might get overriden for a specific profile.
eval ": \${${name}_enable:=\"NO\"}"
eval ": \${${name}_flags:=\"\"}"
eval ": \${${name}_user:=\"buildbot\"}"
eval ": \${${name}_basedir:=\"/var/db/buildbot/workers\"}"
reload_cmd="${name}_reload"
start_precmd="${name}_prestart"
stop_precmd="${name}_prestop"
pidfile="${buildbot_worker_basedir}/twistd.pid"
procname="%%PYTHON_CMD%%"
# A specific profile is specified in the command
if [ -n "$2" ]; then
profile="$2"
# Override defaults with profile-specific values
if [ -n "${buildbot_worker_profiles}" ]; then
eval buildbot_worker_enable="\${buildbot_worker_${profile}_enable:-${buildbot_worker_enable}}"
eval buildbot_worker_flags="\${buildbot_worker_${profile}_flags:-${buildbot_worker_flags}}"
eval buildbot_worker_user="\${buildbot_worker_${profile}_user:-${buildbot_worker_user}}"
eval buildbot_worker_basedir="\${buildbot_worker_${profile}_basedir:-${buildbot_worker_basedir}/${profile}}"
eval pidfile="\${buildbot_worker_${profile}_basedir:-${buildbot_worker_basedir}}/twistd.pid"
else
echo "$0: extra argument ignored"
fi
# A specific profile is not in the command
else
# Check if any profiles are defined
if [ -n "$1" -a -n "${buildbot_worker_profiles}" ]; then
# Loop through them
for profile in ${buildbot_worker_profiles}; do
eval _enable="\${buildbot_worker_${profile}_enable}"
case "${_enable:-${buildbot_worker_enable}}" in
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
continue
;;
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
;;
*)
if test -z "$_enable"; then
_var=buildbot_worker_enable
else
_var=buildbot_worker_"${profile}"_enable
fi
warn "Bad value" \
"'${_enable:-${buildbot_worker_enable}}'" \
"for ${_var}. " \
"Profile ${profile} skipped."
continue
;;
esac
echo "===> ${name} profile: ${profile}"
if $0 $1 ${profile}; then
success="${profile} ${success:-}"
else
failed="${profile} (${retcode}) ${failed:-}"
fi
done
# Exit so that non-profile rc.d is not started when there are profiles
exit 0
fi
fi
buildbot_worker_prestart()
{
if [ ! -f "${buildbot_worker_basedir}/buildbot.tac" ]; then
echo "Worker is not configured."
echo "Run the following command to create a new worker:"
echo "su -m ${buildbot_worker_user} -c \"exec ${command} create-worker ${buildbot_worker_basedir} <MASTER HOST> <MASTER USER> <MASTER_PASS>\""
exit 1
fi
rc_flags="start ${buildbot_worker_basedir} ${rc_flags}"
}
buildbot_worker_prestop()
{
rc_flags="stop ${buildbot_worker_basedir} ${rc_flags}"
}
buildbot_worker_reload()
{
rc_flags="${buildbot_worker_basedir} ${rc_flags}"
${command} sighup ${rc_flags}
}
run_rc_command "$1"
|