Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/slave-build-connect
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-05-03 17:41:40 +0000
committerAndreas Baumann <mail@andreasbaumann.cc>2018-05-03 17:41:40 +0000
commit8430ab734e78aa2ef93a9849ca85459250e774bf (patch)
tree794ff707459f88f915dcbe31827c4e009f230331 /bin/slave-build-connect
parent942531d3630ba90125b38142bdf2ae8d708e5017 (diff)
parent0bc88d347f7d5f3b4fc51e277c3e0489d34dfe04 (diff)
Merge branch 'master' into fixes
Diffstat (limited to 'bin/slave-build-connect')
-rwxr-xr-xbin/slave-build-connect29
1 files changed, 21 insertions, 8 deletions
diff --git a/bin/slave-build-connect b/bin/slave-build-connect
index b176c8f..4fcb38a 100755
--- a/bin/slave-build-connect
+++ b/bin/slave-build-connect
@@ -17,9 +17,27 @@ if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \
fi
# shellcheck disable=SC2016
+ slave_id=$(
+ {
+ printf 'SELECT `build_slaves`.`id` FROM `build_slaves`'
+ printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \
+ "$(
+ printf '%s' "$1" | \
+ base64 -w0
+ )"
+ } | \
+ mysql_run_query
+ )
+ if [ -z "${slave_id}" ]; then
+ >&2 printf 'Build slave "%s" is unnknown to the database.\n' "$1"
+ exit 42
+ fi
+
+ # shellcheck disable=SC2016
{
printf 'INSERT INTO `ssh_log` (`build_slave`,`action`,`parameters`)'
- printf ' SELECT `build_slaves`.`id`'
+ printf ' VALUES (%s' \
+ "${slave_id}"
printf ',from_base64("%s")' \
"$(
printf '%s' "${SSH_ORIGINAL_COMMAND%% *}" | \
@@ -29,16 +47,11 @@ if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \
printf '%s' "${SSH_ORIGINAL_COMMAND#* }" | \
base64 -w0
)"
- printf ' FROM `build_slaves`'
- printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \
- "$(
- printf '%s' "$1" | \
- base64 -w0
- )"
+ printf ');\n'
} | \
mysql_run_query 'unimportant'
- slave="$1" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"
+ slave="$1" slave_id="${slave_id}" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"
else