Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/manage-slaves
diff options
context:
space:
mode:
Diffstat (limited to 'bin/manage-slaves')
-rwxr-xr-xbin/manage-slaves24
1 files changed, 16 insertions, 8 deletions
diff --git a/bin/manage-slaves b/bin/manage-slaves
index 32883a3..fa1413d 100755
--- a/bin/manage-slaves
+++ b/bin/manage-slaves
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
@@ -10,7 +10,7 @@ usage() {
>&2 echo ''
>&2 echo 'possible actions:'
>&2 echo ' list'
- >&2 echo ' add $name $owner $ssh-key-fingerprint'
+ >&2 echo ' add $name $owner $ssh-key-type $ssh-key-fingerprint'
>&2 echo ' disable $name'
>&2 echo ' enable $name'
exit 1
@@ -48,8 +48,12 @@ case "$1" in
;;
'add')
shift
- if [ $# -ne 3 ]; then
- >&2 printf '"add" expects 3 parameters, %s were given\n' "$#"
+ if [ $# -ne 4 ]; then
+ >&2 printf '"add" expects 4 parameters, %s were given\n' "$#"
+ usage
+ fi
+ if [[ $3 != ssh-* ]]; then
+ >&2 printf '"$ssh-key-type" must start with "ssh-", "%s" was given\n' "${3}"
usage
fi
person_id=$(
@@ -94,10 +98,11 @@ case "$1" in
fi
# shellcheck disable=SC2016
{
- printf 'INSERT INTO `ssh_keys`(`owner`,`fingerprint`)'
+ printf 'INSERT INTO `ssh_keys`(`owner`,`fingerprint`,`type`)'
printf ' VALUES'
- printf ' (%s,"%s");\n' \
+ printf ' (%s,"%s","%s");\n' \
"${person_id}" \
+ "${4}" \
"${3}"
printf 'INSERT INTO `build_slaves`('
printf '`name`,'
@@ -109,10 +114,11 @@ case "$1" in
"${1}"
} | \
mysql_run_query
- printf 'command="%s/bin/slave-build-connect %s" ssh-rsa %s %s@%s\n' \
+ printf 'command="%s/bin/slave-build-connect %s" %s %s %s@%s\n' \
"${base_dir}" \
"${1}" \
"${3}" \
+ "${4}" \
"${2}" \
"${1}" >> \
~/".ssh/authorized_keys"
@@ -135,7 +141,9 @@ case "$1" in
printf '"command=\\\"%s/bin/slave-build-connect ",' \
"${base_dir}"
printf '`build_slaves`.`name`,'
- printf '"\\\" ssh-rsa ",'
+ printf '"\\\" ",'
+ printf '`ssh_keys`.`type`,'
+ printf '" ",'
printf '`ssh_keys`.`fingerprint`,'
printf '" ",'
printf '`persons`.`name`,'