2017-12-12 08:00:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euf pipefail
|
|
|
|
|
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-02-19 13:15:28 +00:00
|
|
|
function property_gradle() {
|
|
|
|
property ${GIT_ROOT}/android/gradle.properties ${1}
|
|
|
|
}
|
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
KEYSTORE_PASSWORD=$(property_gradle 'KEYSTORE_PASSWORD')
|
|
|
|
KEYSTORE_ALIAS=$(property_gradle 'KEYSTORE_ALIAS')
|
|
|
|
KEYSTORE_KEY_PASSWORD=$(property_gradle 'KEYSTORE_KEY_PASSWORD')
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
# Allow Makefile modify Keystore path if necessary
|
|
|
|
if [[ -z ${KEYSTORE_PATH} ]]; then
|
|
|
|
KEYSTORE_PATH=$(property_gradle 'KEYSTORE_FILE')
|
|
|
|
fi
|
|
|
|
# Replace ~ with proper absolute path
|
|
|
|
KEYSTORE_PATH=${KEYSTORE_FILE/#\~/$HOME}
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
if [[ -e "${KEYSTORE_PATH}" ]]; then
|
|
|
|
echo -e "${YLW}Keystore file already exists:${RST} ${KEYSTORE_PATH}" > /dev/stderr
|
|
|
|
echo "${KEYSTORE_PATH}"
|
2020-02-19 13:15:28 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
KEYSTORE_DIR=$(dirname "${S/TATUS_RELEASE_STORE_FILE}")
|
2020-02-19 13:15:28 +00:00
|
|
|
[[ -d $KEYSTORE_DIR ]] || mkdir -p $KEYSTORE_DIR
|
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
echo -e "${GRN}Generating keystore...${RST}" > /dev/stderr
|
2020-02-19 13:15:28 +00:00
|
|
|
|
|
|
|
keytool -genkey -v \
|
|
|
|
-keyalg RSA \
|
|
|
|
-keysize 2048 \
|
|
|
|
-validity 10000 \
|
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}" \
|
2020-02-19 13:15:28 +00:00
|
|
|
> /dev/stderr
|
2017-12-12 08:00:46 +00:00
|
|
|
|
2020-03-02 11:18:01 +00:00
|
|
|
echo "${KEYSTORE_PATH}"
|