emma
/
protonkey
Archived
1
0
Fork 0
This repository has been archived on 2024-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
protonkey/protonkey

44 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-12-18 01:23:19 +00:00
#!/bin/sh
2022-12-18 04:03:03 +00:00
# Copyright (c) 2022 Emma Tebibyte
# SPDX-License-Identifier: AGPL-3.0-or-later
2023-03-09 04:54:56 +00:00
#
2022-12-18 04:03:03 +00:00
# Protonkey 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.
#
# Protonkey is distributed in the hope that it will be useful, but WITHOUT
# 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.
#
# 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/.
2023-03-10 21:36:29 +00:00
if test -z "$1"; then
2023-01-04 01:18:06 +00:00
printf "Usage: %s [ProtonMail address]\n" "$0" 1>&2
exit 64 # syexits(3) EX_USAGE
2022-12-18 01:23:19 +00:00
fi
2023-01-04 01:13:36 +00:00
for command in \
2023-01-04 01:18:06 +00:00
curl \
gpg
2023-01-04 01:13:36 +00:00
do
2023-01-04 01:18:06 +00:00
if ! command -v "$command" > /dev/null; then
printf "%s: Missing dependency: %s(1)\n" "$0" "$command" 1>&2
exit 69 # sysexits(3) EX_UNAVAILABLE
fi
2023-01-04 01:13:36 +00:00
done
2022-12-18 01:23:19 +00:00
2023-01-04 01:13:36 +00:00
URL="https://api.protonmail.ch/pks/lookup?op=get&search=$1"
2023-01-04 01:07:44 +00:00
RESPONSE="$(curl -s "$URL")"
2022-12-18 01:23:19 +00:00
2023-03-10 21:36:29 +00:00
if [ "$RESPONSE" = 'No key found' ]; then
2023-01-04 01:18:06 +00:00
printf "%s\n" "$RESPONSE" 1>&2
exit 76 # sysexits(3) EX_PROTOCOL
2022-12-18 01:23:19 +00:00
else
2023-03-10 21:36:29 +00:00
printf "%s\n" "$RESPONSE"
2023-01-04 01:18:06 +00:00
exit 0
2022-12-18 01:23:19 +00:00
fi