dustin
/
jenkinsagent
Archived
1
0
Fork 0
This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
jenkinsagent/rootfs/overlay/usr/libexec/fetch-sshkeys.sh

30 lines
529 B
Bash
Executable File

#!/bin/sh -e
umask 0077
mkdir -p ~/.ssh
: > ~/.ssh/authorized_keys
fetch_keys() {
curl -fsSL "${1}" >> ~/.ssh/authorized_keys
}
# shellcheck disable=SC2046
set -- $(cat /proc/cmdline)
while [ $# -ge 1 ]; do
case "$1" in
sshkeys.*=*)
arg=${1#*.}
user=${arg%=*}
url=${arg#*=}
if [ "${user}" = "${USER}" ]; then
fetch_keys "${url}"
fi
;;
esac
shift
done
if [ -x "$(command -v selinuxenabled)" ] && selinuxenabled; then
restorecon -RF ~/.ssh
fi