From 43fa3509c4d5f36692589512d1b4771c8f8d8cf7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 17 Apr 2018 14:36:01 +0200 Subject: bin/slave-build-connect: write ssh-log into database --- bin/slave-build-connect | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'bin/slave-build-connect') diff --git a/bin/slave-build-connect b/bin/slave-build-connect index 7c6dedc..8e9dbcf 100755 --- a/bin/slave-build-connect +++ b/bin/slave-build-connect @@ -16,14 +16,28 @@ if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \ fi - printf '%s %s %s\n' "$(date '+%F %T')" "$1" "${SSH_ORIGINAL_COMMAND}" >> \ - "${work_dir}/ssh-log" - # shellcheck disable=SC2016 { + printf 'INSERT INTO `ssh_log` (`date`,`build_slave`,`action`,`parameters`)' + printf ' SELECT NOW(),`build_slaves`.`id`' + printf ',from_base64("%s")' \ + "$( + print '%s' "${SSH_ORIGINAL_COMMAND%% *}" | \ + base64 -w0 + )" \ + "$( + print '%s' "${#* }" | \ + base64 -w0 + )" + printf ' FROM `build_slaves`' + printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ + "$( + printf '%s' "$1" | \ + base64 -w0 + )" printf 'UPDATE `build_slaves`' printf ' SET `build_slaves`.`last_connection`=NOW()' - printf ' WHERE `build_slaves`.`name`=from_base64("%s")\n' \ + printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ "$( printf '%s' "$1" | \ base64 -w0 -- cgit v1.2.3-70-g09d2