-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_script.sh
49 lines (42 loc) · 1.51 KB
/
bash_script.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
#! /bin/bash
gpg_setup(){
gpg --full-generate-key
keygen=$(gpg --list-secret-keys --keyid-format=long|awk '/sec/{if (length($2)>0) print $2}')
line=$(gpg --list-secret-keys --keyid-format=long|awk '/sec/{if (length($2)>0) print $2}' | grep -c ".*");
keyspli=$(echo $keygen | awk "NR==$line{print}")
IFS='/'
read -a keyarr2 <<<"$keyspli"
key=${keyarr[1]}
git config --global --unset gpg.format
git config --global user.signingkey $key
git config --global commit.gpgsign true
gpg --armor --export $key
echo
echo "Copy your GPG key, beginning with -----BEGIN PGP PUBLIC KEY BLOCK----- and ending with -----END PGP PUBLIC KEY BLOCK-----"
echo "Add the GPG key to your GitHub account."
echo
echo "Thanks for using us"
}
bool=$(gpg --list-secret-keys --keyid-format=long)
if [ $bool = "\n" ];
then
gpg_setup
else
echo "A GPG KEY ALREADY EXISTS ON YOUR SYSTEM"
read -p "Do you still want to make new a one and set it as signingkey(y/n): " choice
if [ $choice == "y" ]; then
gpg_setup
else
read -p "Do you want to set signingkey(y/n): " choice2
if [ $choice2 == "y" ]; then
gpg --list-secret-keys --keyid-format=long
read -p "Give your keyID to set as Signingkey: " sigkey
git config --global --unset gpg.format
git config --global user.signingkey $sigkey
git config --global commit.gpgsign true
echo "Thanks for using us"
else
echo "Thanks for using us"
fi
fi
fi