-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencrypt-keyring.sh
47 lines (37 loc) · 1.17 KB
/
encrypt-keyring.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
#!/bin/bash
echo "Please specify the path to the GPG keyring file or leave it empty to use the default."
echo -n "Keyring file path (~/.gnupg/secring.gpg): "
read -s keyring
echo
if [ -z "$keyring" ]; then
echo "Using default GPG keyring from ~/.gnupg/secring.gpg."
keyring=~/.gnupg/secring.gpg
fi
if [ ! -f $keyring ]; then
echo "The keyring file was not found! Exiting."
exit 1
fi
echo
echo -n Please enter the password to encrypt the signing key:
read -s password1
echo
echo -n Retype the password:
read -s password2
echo
echo
if [ "$password1" != "$password2" ]; then
echo "The entered passwords are not equal. Exiting."
exit 1
fi
export envKeyringPassword=$password1
openssl aes-256-cbc -e -pass "env:envKeyringPassword" -in $keyring -out ./etc/sign.enc
if [ "$1" == "-d" ]; then
echo "Printing out the MD5 sums of the processes files:"
md5sum $keyring
md5sum ./etc/sign.enc
fi
echo
echo "Use the following environment variable in the build options on Travis CI."
printf -v escapedPwd "%q" "$password1"
echo "envKeyringPassword=$escapedPwd"
echo "Make sure you disabled the option 'Display value in build log'!"