#!/usr/bin/env bash

# Copyright (C) 2013-2016 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2015-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2014-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only

# {{ ansible_managed }}

# Lookup SSH public keys

username="${1}"

if [ -d /etc/ssh/authorized_keys_lookup.d ] ; then
    keys="$(/bin/run-parts --arg="${username}" /etc/ssh/authorized_keys_lookup.d)"

    if [ -n "${keys}" ] ; then
        echo "${keys}"
    fi
fi
