-
Notifications
You must be signed in to change notification settings - Fork 21
/
thunar-gpg-verify-signature.sh
executable file
·98 lines (85 loc) · 1.64 KB
/
thunar-gpg-verify-signature.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
#
# Verify the gpg signature of *.asc or *.sig files.
#
# * Put this file into your home binary dir: ~/bin/
# * Make it executable: chmod +x
#
#
# Required Software:
# -------------------------
# * gpg
# * zenity
#
#
# Thunar Integration
# ------------------------
#
# Command: ~/bin/thunar-gpg-verify-signature.sh -f %f
# File Pattern: *
# Appear On: Other Files
#
#
# Usage:
# -------------------------
# thunar-gpg-verify-signature.sh -f <filename>
#
# required:
# -f input filename
#
# Note:
# -------------------------
#
# Feel free to adjust/improve and commit back to:
# https://github.com/cytopia/thunar-custom-actions
#
usage() {
echo "$0 -f <filename>"
echo
echo " required:"
echo " -f input filename"
echo
}
while getopts ":f:" i; do
case "${i}" in
f)
f=${OPTARG}
;;
*)
echo "Error - unrecognized option $1" 1>&2;
usage
;;
esac
done
shift $((OPTIND-1))
# Check if file is specified
if [ -z "${f}" ]; then
echo "Error - no file specified" 1>&2;
usage
exit 1
fi
# Check if gpg exists
if ! command -v gpg >/dev/null 2>&1 ; then
echo "Error - 'gpg' not found." 1>&2
exit 1
fi
# Check if zenity exists
if ! command -v zenity >/dev/null 2>&1 ; then
echo "Error - 'zenity' not found." 1>&2
exit 1
fi
verify() {
output="$(gpg --keyid-format 0xlong --verify "${f}" 2>&1)"
error=$?
echo "${output}"
return $error
}
output="$(verify "${f}")"
error=$?
if [ "$error" -eq "0" ]; then
zenity --info --title="GPG Good signature" --no-markup --text="${output}"
exit $?
else
zenity --error --title="GPG Signature Error" --text="Error verifying the signature:\n\n${output}"
exit 1
fi