#!/bin/bash
#
# Script to create a test keystore to allow automated tests# (e.g. on Travis-CI) to create release APks.
#

. scripts/inc.functions

# Constants
KEYSTORE=test.jks

# Checks
if [ -f ${KEYSTORE} ] ; then
    die "Keystore '${KEYSTORE}' already exists!"
fi
if [ -f local.properties ] ; then
    die "File 'local.properties' already exists!"
fi


safe keytool -genkey -v \
    -keystore ${KEYSTORE} \
    -keyalg RSA \
    -keysize 2048 \
    -validity 10000 \
    -alias test \
    -storepass test132 \
    -keypass test123 \
    -dname "cn=test"

cat << EOT > local.properties
signing.key.alias=test
signing.key.password=test123
signing.store.file=${PWD}/${KEYSTORE}
signing.store.password=test132
EOT
