Menu style for setting trust level

This commit is contained in:
Bob Mottram 2018-03-17 21:42:19 +00:00
parent f85e37e49e
commit df1961e553
1 changed files with 18 additions and 27 deletions

View File

@ -283,34 +283,25 @@ function gpg_set_trust {
fpr=$(gpg --with-colons --fingerprint "$TRUST_ADDRESS" | grep fpr | head -n 1 | awk -F ':' '{print $10}') fpr=$(gpg --with-colons --fingerprint "$TRUST_ADDRESS" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
if [ ${#fpr} -gt 2 ]; then if [ ${#fpr} -gt 2 ]; then
data=$(mktemp 2>/dev/null) W=(1 $"I don't know or won't say"
dialog --backtitle $"Freedombone User Control Panel" \ 2 $"I do NOT trust"
--title $"Trust a PGP/GPG key or website domain" \ 3 $"I trust marginally"
--radiolist $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 \ 4 $"I trust fully"
1 $"I don't know or won't say" off \ 5 $"I trust ultimately")
2 $"I do NOT trust" off \
3 $"I trust marginally" on \ # shellcheck disable=SC2068
4 $"I trust fully" off \ TRUST_LEVEL=$(dialog --backtitle $"Freedombone User Control Panel" --title $"Trust a PGP/GPG key or website domain" --menu $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 "${W[@]}" 3>&2 2>&1 1>&3)
5 $"I trust ultimately" off 2> "$data"
sel=$? if [ ! "$TRUST_LEVEL" ]; then
case $sel in return;
1) rm -f "$data" fi
return;;
255) rm -f "$data" if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
return;; gpg --update-trustdb
esac dialog --title $"Trust a PGP/GPG key or website domain" \
TRUST_LEVEL=$(cat "$data") --backtitle $"Freedombone User Control Panel" \
if [ "${TRUST_LEVEL}" -ge 1 ] ; then --msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
if [ "${TRUST_LEVEL}" -le 5 ] ; then
if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
gpg --update-trustdb
dialog --title $"Trust a PGP/GPG key or website domain" \
--backtitle $"Freedombone User Control Panel" \
--msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
fi
fi
fi fi
rm -f "$data"
fi fi
} }