index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-05-03 17:41:40 +0000 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-05-03 17:41:40 +0000 |
commit | 8430ab734e78aa2ef93a9849ca85459250e774bf (patch) | |
tree | 794ff707459f88f915dcbe31827c4e009f230331 /bin/slave-build-connect | |
parent | 942531d3630ba90125b38142bdf2ae8d708e5017 (diff) | |
parent | 0bc88d347f7d5f3b4fc51e277c3e0489d34dfe04 (diff) |
-rwxr-xr-x | bin/slave-build-connect | 29 |
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 |