2022-12-17 18:23:19 -07:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
2023-03-21 18:11:44 -06:00
|
|
|
|
# Copyright (c) 2022–2023 Emma Tebibyte <emma@tebibyte.media>
|
2022-12-17 21:03:03 -07:00
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2023-03-08 21:54:56 -07:00
|
|
|
|
#
|
2023-03-21 18:11:44 -06:00
|
|
|
|
# This program is free software: you can redistribute it and/or modify it under
|
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
|
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
|
|
|
# later version.
|
2022-12-17 21:03:03 -07:00
|
|
|
|
#
|
2023-03-21 18:11:44 -06:00
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
2022-12-17 21:03:03 -07:00
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
|
# details.
|
|
|
|
|
#
|
2023-03-21 18:11:44 -06:00
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
|
# with this program. If not, see https://www.gnu.org/licenses/.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
argv0="$0"
|
2022-12-17 21:03:03 -07:00
|
|
|
|
|
2023-03-21 22:53:19 -06:00
|
|
|
|
if ! command -v curl > /dev/null; then
|
|
|
|
|
printf "%s: Missing dependency: curl(1)\n" "$0" 1>&2
|
|
|
|
|
exit 69 # sysexits(3) EX_UNAVAILABLE
|
|
|
|
|
fi
|
2022-12-17 18:23:19 -07:00
|
|
|
|
|
2023-12-24 03:14:08 -07:00
|
|
|
|
if test -z "$1"; then
|
|
|
|
|
printf "Usage: %s [ProtonMail address...]\n" "$argv0" 1>&2
|
|
|
|
|
exit 64 # syexits(3) EX_USAGE
|
|
|
|
|
fi
|
|
|
|
|
|
2023-03-21 18:11:44 -06:00
|
|
|
|
while test -n "$1"; do
|
|
|
|
|
URL="https://api.protonmail.ch/pks/lookup?op=get&search=$1"
|
|
|
|
|
RESPONSE="$(curl -s "$URL")"
|
2022-12-17 18:23:19 -07:00
|
|
|
|
|
2023-03-21 18:11:44 -06:00
|
|
|
|
if [ "$RESPONSE" = 'No key found' ]; then
|
|
|
|
|
printf "%s: %s: %s\n" "$argv0" "$1" "$RESPONSE" 1>&2
|
|
|
|
|
exit 76 # sysexits(3) EX_PROTOCOL
|
|
|
|
|
else
|
|
|
|
|
printf "%s\n" "$RESPONSE"
|
|
|
|
|
fi
|
|
|
|
|
shift
|
|
|
|
|
done
|