-
Notifications
You must be signed in to change notification settings - Fork 3
/
keygen.sh
58 lines (46 loc) · 1.92 KB
/
keygen.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
#!/bin/bash
# Define destination directory
mkdir -p vendor/extra
destination_dir="vendor/extra"
# Check if the directory for certificates already exists
if [ -d ~/.android-certs ]; then
read -p "~/.android-certs already exists. Do you want to delete it and proceed? (y/n): " choice
if [ "$choice" != "y" ]; then
echo "Exiting script."
exit 1
fi
rm -rf ~/.android-certs
fi
# Define default subject line
default_subject="/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]"
# Ask the user if they want to use default values or enter new ones
read -p "Do you want to use the default subject line: '$default_subject'? (y/n): " use_default
if [ "$use_default" == "y" ]; then
subject="$default_subject"
else
# Prompt user for certificate subject information
echo "Please enter the following details:"
read -p "Country Shortform (C): " C
read -p "Country Longform (ST): " ST
read -p "Location (L): " L
read -p "Organization (O): " O
read -p "Organizational Unit (OU): " OU
read -p "Common Name (CN): " CN
read -p "Email Address (emailAddress): " emailAddress
# Construct subject string for certificates
subject="/C=$C/ST=$ST/L=$L/O=$O/OU=$OU/CN=$CN/emailAddress=$emailAddress"
fi
# Create directory for certificates
mkdir -p ~/.android-certs
# Generate keys
for key_type in releasekey platform shared media networkstack testkey cyngn-priv-app bluetooth sdk_sandbox verifiedboot nfc; do
./development/tools/make_key ~/.android-certs/$key_type "$subject"
done
# Move keys to the destination directory
mkdir -p "$destination_dir/keys"
mv ~/.android-certs/* "$destination_dir/keys"
# Create product.mk file
echo "PRODUCT_DEFAULT_DEV_CERTIFICATE := $destination_dir/keys/releasekey" > "$destination_dir/product.mk"
# Set appropriate permissions
chmod -R 755 "$destination_dir/keys"
echo "Key generation and setup completed successfully."