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:
authorErich Eckner <git@eckner.net>2018-04-25 16:07:47 +0200
committerErich Eckner <git@eckner.net>2018-04-25 16:07:47 +0200
commitf25ab9159d34ffc58ce3f9a3edd76c0315fdedc4 (patch)
tree603ee9791a7ffbb3890f260789ae36084aa3dd1e /bin/slave-build-connect
parent47e2bc0ba30bf2eb66abf59429ae085366c01056 (diff)
bin/slave-build-connect: extract id slave of slave for further commands
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