2017-12-12 08:00:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-03-30 07:45:25 +00:00
|
|
|
set -ef pipefail
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-02-19 13:15:28 +00:00
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
|
|
source "${GIT_ROOT}/scripts/colors.sh"
|
|
|
|
|
|
|
|
function property() {
|
|
|
|
grep "${2}" "${1}" | cut -d'=' -f2
|
|
|
|
}
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-13 12:01:17 +00:00
|
|
|
function gradle_property() {
|
2022-07-25 20:38:41 +00:00
|
|
|
property "${GIT_ROOT}/android/gradle.properties" ${1}
|
2020-02-19 13:15:28 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 12:01:17 +00:00
|
|
|
function env_var_or_gradle_prop() {
|
|
|
|
VAR_NAME="${1}"
|
|
|
|
if [[ -n "${!VAR_NAME}" ]]; then
|
|
|
|
echo "${!VAR_NAME}"
|
|
|
|
else
|
|
|
|
gradle_property "${VAR_NAME}"
|
|
|
|
fi
|
|
|
|
}
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-13 12:01:17 +00:00
|
|
|
KEYSTORE_PASSWORD=$(env_var_or_gradle_prop 'KEYSTORE_PASSWORD')
|
|
|
|
KEYSTORE_ALIAS=$(env_var_or_gradle_prop 'KEYSTORE_ALIAS')
|
|
|
|
KEYSTORE_KEY_PASSWORD=$(env_var_or_gradle_prop 'KEYSTORE_KEY_PASSWORD')
|
|
|
|
KEYSTORE_PATH=$(env_var_or_gradle_prop 'KEYSTORE_PATH')
|
|
|
|
|
|
|
|
# Use absolute path for Keystore
|
2020-03-06 15:43:04 +00:00
|
|
|
KEYSTORE_PATH=${KEYSTORE_PATH/#\~/$HOME}
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
if [[ -e "${KEYSTORE_PATH}" ]]; then
|
2020-04-14 15:33:11 +00:00
|
|
|
echo -e "${YLW}Keystore file already exists:${RST} ${KEYSTORE_PATH}" >&2
|
2020-02-19 13:15:28 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-03-13 12:01:17 +00:00
|
|
|
KEYSTORE_DIR=$(dirname "${KEYSTORE_PATH}")
|
2020-02-19 13:15:28 +00:00
|
|
|
[[ -d $KEYSTORE_DIR ]] || mkdir -p $KEYSTORE_DIR
|
|
|
|
|
2020-04-14 15:33:11 +00:00
|
|
|
echo -e "${GRN}Generating keystore...${RST}" >&2
|
2020-02-19 13:15:28 +00:00
|
|
|
|
2022-04-22 08:20:01 +00:00
|
|
|
exec keytool -genkey -v \
|
2020-02-19 13:15:28 +00:00
|
|
|
-keyalg RSA \
|
|
|
|
-keysize 2048 \
|
|
|
|
-validity 10000 \
|
2020-06-03 19:47:01 +00:00
|
|
|
-deststoretype pkcs12 \
|
2020-03-02 11:18:01 +00:00
|
|
|
-dname "CN=, OU=, O=, L=, S=, C=" \
|
|
|
|
-keystore "${KEYSTORE_PATH}" \
|
|
|
|
-alias "${KEYSTORE_ALIAS}" \
|
|
|
|
-storepass "${KEYSTORE_PASSWORD}" \
|
|
|
|
-keypass "${KEYSTORE_KEY_PASSWORD}" \
|
2022-08-09 19:01:52 +00:00
|
|
|
>&2
|