/etc/init.d/buildslave is in buildbot-slave 0.8.8-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | #!/bin/bash
### Maintain compatibility with chkconfig
# chkconfig: 2345 83 17
# description: buildslave
### BEGIN INIT INFO
# Provides: buildslave
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Buildbot slave init script
# Description: This file allows running buildbot slave instances at
# startup
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
SLAVE_RUNNER=/usr/bin/buildslave
# Source buildslave configuration
[[ -r /etc/default/buildslave ]] && . /etc/default/buildslave
# Get some LSB-like functions
if [ -r /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
else
function log_success_msg() {
echo "$@"
}
function log_failure_msg() {
echo "$@"
}
function log_warning_msg() {
echo "$@"
}
fi
# Some systems don't have seq (e.g. Solaris)
if type seq >/dev/null 2>&1; then
:
else
function seq() {
for ((i=1; i<=$1; i+=1)); do
echo $i
done
}
fi
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[@]}"
if [[ $(echo "$itemcount" | tr -d ' ' | sort -u | wc -l) -ne 1 ]]; then
log_failure_msg "SLAVE_* arrays must have an equal number of elements!"
return 1
fi
errors=0
for i in $( seq ${#SLAVE_ENABLED[@]} ); do
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 $?
}
check_config || exit $?
function iscallable () { type $1 2>/dev/null | grep -q 'shell function'; }
function slave_op () {
op=$1 ; mi=$2
if [ `uname` = SunOS ]; then
suopt=""
else
suopt="-s /bin/sh"
fi
${SLAVE_PREFIXCMD[$mi]} \
su $suopt - ${SLAVE_USER[$mi]} \
-c "$SLAVE_RUNNER $op --quiet ${SLAVE_OPTIONS[$mi]} ${SLAVE_BASEDIR[$mi]}"
return $?
}
function do_op () {
errors=0
for i in $( seq ${#SLAVE_ENABLED[@]} ); do
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
log_daemon_msg "$3 \"${SLAVE_NAME[$i]}\""
if eval $1 $2 $i; then
log_end_msg 0
else
log_end_msg 1
errors=$(($errors+1))
fi
else
if eval $1 $2 $i; then
log_success_msg "$3 \"${SLAVE_NAME[$i]}\""
else
log_failure_msg "$3 \"${SLAVE_NAME[$i]}\""
errors=$(($errors+1))
fi
fi
done
return $errors
}
case "$1" in
start)
do_op "slave_op" "start" "Starting buildslave"
exit $?
;;
stop)
do_op "slave_op" "stop" "Stopping buildslave"
exit $?
;;
reload)
do_op "slave_op" "reload" "Reloading buildslave"
exit $?
;;
restart|force-reload)
do_op "slave_op" "restart" "Restarting buildslave"
exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
;;
esac
exit 0
|