Skip to content

Commit

Permalink
Merge branch 'deb-bug-625555' of git://github.com/jollyroger/buildbot
Browse files Browse the repository at this point in the history
* 'deb-bug-625555' of git://github.com/jollyroger/buildbot:
  Fix weird *_ENABLED behaviour in /etc/default/* files
  Remove trailing whitespace
  Init script fixes from Debian BTS (bug #625555).
  buildmaster init script should use /etc/default/buildmaster
  • Loading branch information
djmitche committed May 31, 2011
2 parents 5c894bb + eb771d1 commit 49ba1e7
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 56 deletions.
5 changes: 5 additions & 0 deletions master/NEWS
Expand Up @@ -16,6 +16,11 @@ step's functionality.

** Deprecations, Removals, and Non-Compatible Changes

*** Init script now uses /etc/default/buildmaster for instance configuration.
Also MASTER_ENABLED used in /etc/default/buildmaster now accepts 'true|yes|1'
to enable instance and 'false|no|0' to disable(not case sensitive). Other
values will be considered as syntax error.

*** 'buildbot.status.words.IRC' now defaults to `AllowForce=False` to prevent
IRC bots from being allowed to force builds by default.

Expand Down
8 changes: 6 additions & 2 deletions master/contrib/init-scripts/buildmaster.default
@@ -1,8 +1,12 @@
MASTER_RUNNER=/usr/bin/buildbot

MASTER_ENABLED[1]=0 # 0-enabled, other-disabled
# NOTE: MASTER_ENABLED has changed its behaviour in version 0.8.4. Use
# 'true|yes|1' to enable instance and 'false|no|0' to disable. Other
# values will be considered as syntax error.

MASTER_ENABLED[1]=0 # 1-enabled, 0-disabled
MASTER_NAME[1]="buildmaster #1" # short name printed on start/stop
MASTER_USER[1]="buildbot" # user to run master as
MASTER_BASEDIR[1]="" # basedir to master (absolute path)
MASTER_OPTIONS[1]="" # buildbot options
MASTER_OPTIONS[1]="" # buildbot options
MASTER_PREFIXCMD[1]="" # prefix command, i.e. nice, linux32, dchroot
85 changes: 58 additions & 27 deletions master/contrib/init-scripts/buildmaster.init.sh
Expand Up @@ -18,29 +18,74 @@ MASTER_RUNNER=/usr/bin/buildbot
. /lib/lsb/init-functions

# Source buildmaster configuration
[[ -r /etc/default/buildbot ]] && . /etc/default/buildbot
#[[ -r /etc/sysconfig/buildbot ]] && . /etc/sysconfig/buildbot
[[ -r /etc/default/buildmaster ]] && . /etc/default/buildmaster
#[[ -r /etc/sysconfig/buildmaster ]] && . /etc/sysconfig/buildmaster

# Or define/override the configuration here
#MASTER_ENABLED[1]=0 # 0-enabled, other-disabled
#MASTER_ENABLED[1]=0 # 1-enabled, 0-disabled
#MASTER_NAME[1]="buildmaster #1" # short name printed on start/stop
#MASTER_USER[1]="buildbot" # user to run master as
#MASTER_BASEDIR[1]="" # basedir to master (absolute path)
#MASTER_OPTIONS[1]="" # buildbot options
#MASTER_OPTIONS[1]="" # buildbot options
#MASTER_PREFIXCMD[1]="" # prefix command, i.e. nice, linux32, dchroot

if [[ ! -x ${MASTER_RUNNER} ]]; then
log_failure_msg "does not exist or not an executable file: ${MASTER_RUNNER}"
exit 1
fi

function is_enabled() {
ANSWER=`echo $1|tr "[:upper:]" "[:lower:]"`
[[ "$ANSWER" == "yes" ]] || [[ "$ANSWER" == "true" ]] || [[ "$ANSWER" == "1" ]]
return $?
}

function is_disabled() {
ANSWER=`echo $1|tr "[:upper:]" "[:lower:]"`
[[ "$ANSWER" == "no" ]] || [[ "$ANSWER" == "false" ]] || [[ "$ANSWER" == "0" ]]
return $?
}


function master_config_valid() {
# Function validates buildmaster instance startup variables based on array
# index
local errors=0
local index=$1

if ! is_enabled "${MASTER_ENABLED[$index]}" && ! is_disabled "${MASTER_ENABLED[$index]}" ; then
log_warning_msg "buildmaster #${i}: invalid enabled status"
errors=$(($errors+1))
fi

if [[ -z ${MASTER_NAME[$index]} ]]; then
log_failure_msg "buildmaster #${i}: no name"
errors=$(($errors+1))
fi

if [[ -z ${MASTER_USER[$index]} ]]; then
log_failure_msg "buildmaster #${i}: no run user specified"
errors=$( ($errors+1) )
elif ! getent passwd ${MASTER_USER[$index]} >/dev/null; then
log_failure_msg "buildmaster #${i}: unknown user ${MASTER_USER[$index]}"
errors=$(($errors+1))
fi

if [[ ! -d "${MASTER_BASEDIR[$index]}" ]]; then
log_failure_msg "buildmaster ${i}: basedir does not exist ${MASTER_BASEDIR[$index]}"
errors=$(($errors+1))
fi

return $errors
}

function check_config() {
itemcount="${#MASTER_ENABLED[@]}
${#MASTER_NAME[@]}
${#MASTER_USER[@]}
${#MASTER_BASEDIR[@]}
${#MASTER_OPTIONS[@]}
${#MASTER_PREFIXCMD[@]}"
${#MASTER_PREFIXCMD[@]}"

if [[ $(echo "$itemcount" | tr -d ' ' | sort -u | wc -l) -ne 1 ]]; then
log_failure_msg "MASTER_* arrays must have an equal number of elements!"
Expand All @@ -49,28 +94,12 @@ function check_config() {

errors=0
for i in $( seq ${#MASTER_ENABLED[@]} ); do
if [[ ${MASTER_ENABLED[$i]} -ne 0 ]]; then
log_failure_msg "buildmaster #${i}: unknown run status"
errors=$(($errors+1))
fi

if [[ -z ${MASTER_NAME[$i]} ]]; then
log_failure_msg "buildmaster #${i}: no name"
errors=$(($errors+1))
fi

if [[ -z ${MASTER_USER[$i]} ]]; then
log_failure_msg "buildmaster #${i}: no run user specified"
errors=$( ($errors+1) )
elif ! getent passwd ${MASTER_USER[$i]} >/dev/null; then
log_failure_msg "buildmaster #${i}: unknown user ${MASTER_USER[$i]}"
errors=$(($errors+1))
fi

if [[ ! -d "${MASTER_BASEDIR[$i]}" ]]; then
log_failure_msg "buildmaster ${i}: basedir does not exist ${MASTER_BASEDIR[$i]}"
errors=$(($errors+1))
if is_disabled "${MASTER_ENABLED[$i]}" ; then
log_warning_msg "buildmaster #${i}: disabled"
continue
fi
master_config_valid $i
errors=$(($errors+$?))
done

[[ $errors == 0 ]]; return $?
Expand All @@ -93,7 +122,9 @@ function master_op () {
function do_op () {
errors=0
for i in $( seq ${#MASTER_ENABLED[@]} ); do
[[ ${MASTER_ENABLED[$i]} -ne 0 ]] && continue
if is_disabled "${MASTER_ENABLED[$i]}" ; then
continue
fi

# Some rhels don't come with all the lsb goodies
if iscallable log_daemon_msg; then
Expand Down
5 changes: 5 additions & 0 deletions slave/NEWS
Expand Up @@ -10,6 +10,11 @@ systems. This means that in most cases child processes are cleaned up
properly, and removes the most common use for usePTY. As of this version,
usePTY should be set to False for almost all users of Buildbot.

** Init script now uses /etc/default/buildslave for instance configuration.
Also SLAVE_ENABLED used in /etc/default/buildslave now accepts 'true|yes|1'
to enable instance and 'false|no|0' to disable(not case sensitive). Other
values will be considered as syntax error.


* Buildbot-Slave 0.8.3 (December 19, 2010)

Expand Down
8 changes: 6 additions & 2 deletions slave/contrib/init-scripts/buildslave.default
@@ -1,8 +1,12 @@
SLAVE_RUNNER=/usr/bin/buildslave

SLAVE_ENABLED[1]=0 # 0-enabled, other-disabled
# NOTE: SLAVE_ENABLED has changed its behaviour in version 0.8.4. Use
# 'true|yes|1' to enable instance and 'false|no|0' to disable. Other
# values will be considered as syntax error.

SLAVE_ENABLED[1]=0 # 1-enabled, 0-disabled
SLAVE_NAME[1]="buildslave #1" # short name printed on start/stop
SLAVE_USER[1]="buildbot" # user to run slave as
SLAVE_BASEDIR[1]="" # basedir to slave (absolute path)
SLAVE_OPTIONS[1]="" # buildbot options
SLAVE_OPTIONS[1]="" # buildbot options
SLAVE_PREFIXCMD[1]="" # prefix command, i.e. nice, linux32, dchroot
81 changes: 56 additions & 25 deletions slave/contrib/init-scripts/buildslave.init.sh
Expand Up @@ -17,7 +17,7 @@ SLAVE_RUNNER=/usr/bin/buildslave

. /lib/lsb/init-functions

# Source buildslave configuration
# Source buildslave configuration
[[ -r /etc/default/buildslave ]] && . /etc/default/buildslave
#[[ -r /etc/sysconfig/buildslave ]] && . /etc/sysconfig/buildslave

Expand All @@ -26,21 +26,66 @@ SLAVE_RUNNER=/usr/bin/buildslave
#SLAVE_NAME[1]="buildslave #1" # short name printed on start/stop
#SLAVE_USER[1]="buildbot" # user to run slave as
#SLAVE_BASEDIR[1]="" # basedir to slave (absolute path)
#SLAVE_OPTIONS[1]="" # buildbot options
#SLAVE_OPTIONS[1]="" # buildbot options
#SLAVE_PREFIXCMD[1]="" # prefix command, i.e. nice, linux32, dchroot

if [[ ! -x ${SLAVE_RUNNER} ]]; then
log_failure_msg "does not exist or not an executable file: ${SLAVE_RUNNER}"
exit 1
fi

function is_enabled() {
ANSWER=`echo $1|tr "[:upper:]" "[:lower:]"`
[[ "$ANSWER" == "yes" ]] || [[ "$ANSWER" == "true" ]] || [[ "$ANSWER" == "1" ]]
return $?
}

function is_disabled() {
ANSWER=`echo $1|tr "[:upper:]" "[:lower:]"`
[[ "$ANSWER" == "no" ]] || [[ "$ANSWER" == "false" ]] || [[ "$ANSWER" == "0" ]]
return $?
}


function slave_config_valid() {
# Function validates buildmaster instance startup variables based on array
# index
local errors=0
local index=$1

if ! is_enabled "${SLAVE_ENABLED[$index]}" && ! is_disabled "${SLAVE_ENABLED[$index]}" ; then
log_warning_msg "buildmaster #${i}: invalid enabled status"
errors=$(($errors+1))
fi

if [[ -z ${SLAVE_NAME[$index]} ]]; then
log_failure_msg "buildmaster #${i}: no name"
errors=$(($errors+1))
fi

if [[ -z ${SLAVE_USER[$index]} ]]; then
log_failure_msg "buildmaster #${i}: no run user specified"
errors=$( ($errors+1) )
elif ! getent passwd ${SLAVE_USER[$index]} >/dev/null; then
log_failure_msg "buildmaster #${i}: unknown user ${SLAVE_USER[$index]}"
errors=$(($errors+1))
fi

if [[ ! -d "${SLAVE_BASEDIR[$index]}" ]]; then
log_failure_msg "buildmaster ${i}: basedir does not exist ${SLAVE_BASEDIR[$index]}"
errors=$(($errors+1))
fi

return $errors
}

function check_config() {
itemcount="${#SLAVE_ENABLED[@]}
${#SLAVE_NAME[@]}
${#SLAVE_USER[@]}
${#SLAVE_BASEDIR[@]}
${#SLAVE_OPTIONS[@]}
${#SLAVE_PREFIXCMD[@]}"
${#SLAVE_PREFIXCMD[@]}"

if [[ $(echo "$itemcount" | tr -d ' ' | sort -u | wc -l) -ne 1 ]]; then
log_failure_msg "SLAVE_* arrays must have an equal number of elements!"
Expand All @@ -49,28 +94,12 @@ function check_config() {

errors=0
for i in $( seq ${#SLAVE_ENABLED[@]} ); do
if [[ ${SLAVE_ENABLED[$i]} -ne 0 ]]; then
log_failure_msg "buildslave #${i}: unknown run status"
errors=$(($errors+1))
fi

if [[ -z ${SLAVE_NAME[$i]} ]]; then
log_failure_msg "buildslave #${i}: no name"
errors=$(($errors+1))
fi

if [[ -z ${SLAVE_USER[$i]} ]]; then
log_failure_msg "buildslave #${i}: no run user specified"
errors=$( ($errors+1) )
elif ! getent passwd ${SLAVE_USER[$i]} >/dev/null; then
log_failure_msg "buildslave #${i}: unknown user ${SLAVE_USER[$i]}"
errors=$(($errors+1))
fi

if [[ ! -d "${SLAVE_BASEDIR[$i]}" ]]; then
log_failure_msg "buildslave ${i}: basedir does not exist ${SLAVE_BASEDIR[$i]}"
errors=$(($errors+1))
if is_disabled "${SLAVE_ENABLED[$i]}" ; then
log_warning_msg "buildslave #${i}: disabled"
continue
fi
slave_config_valid $i
errors=$(($errors+$?))
done

[[ $errors == 0 ]]; return $?
Expand All @@ -93,7 +122,9 @@ function slave_op () {
function do_op () {
errors=0
for i in $( seq ${#SLAVE_ENABLED[@]} ); do
[[ ${SLAVE_ENABLED[$i]} -ne 0 ]] && continue
if is_disabled "${SLAVE_ENABLED[$i]}" ; then
continue
fi

# Some rhels don't come with all the lsb goodies
if iscallable log_daemon_msg; then
Expand Down

0 comments on commit 49ba1e7

Please sign in to comment.