From 73a3c13874e427bc24329badb967fbe9846fd25f Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 2 Jan 2022 17:47:30 +0100 Subject: [PATCH] Support initial setup with WSL. - adjust bash scripts - update readme - update gitignore Original pull request: gh-675 Closes gh-674 --- .gitignore | 12 +++++++++--- README.adoc | 14 ++++++++++++++ src/test/bash/create_certificates.sh | 18 ++++++++++++++---- src/test/bash/start.sh | 3 ++- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0b3fed5c..a6adb746 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,15 @@ bin build out target -/vault/ -/download/ -/work/ pom.xml.releaseBackup release.properties .flattened-pom.xml + +# Folder for setup & test +/vault/ +/download/ +/work/ +/spring-vault-core/work/ +/src/test/bash/work/ +/src/test/bash/download/ +/src/test/bash/vault/ \ No newline at end of file diff --git a/README.adoc b/README.adoc index 6f604813..c229d80e 100644 --- a/README.adoc +++ b/README.adoc @@ -80,6 +80,14 @@ To get started with Vault and this guide you need a *NIX-like operating systems * `curl`, `openssl` and `unzip` * at least Java 8 and a properly configured `JAVA_HOME` environment variable +[NOTE] +-- +If you use Windows Subsystem for Linux (WSL) you have to share `JAVA_HOME` between WSL and Windows. Call following command in PowerShell: +---- +$ setx WSLENV "JAVA_HOME/p" +---- +-- + *Install Vault* ---- @@ -245,6 +253,12 @@ The following scripts need to be run prior to building the project for the tests $ ./src/test/bash/env.sh $ ./src/test/bash/local_run_vault.sh +Alternatively you can run + +---- +$ ./src/test/bash/start.sh +---- + Changes to the documentation should be made to the adocs found under `src/main/asciidoc/` === Basic Compile and Test diff --git a/src/test/bash/create_certificates.sh b/src/test/bash/create_certificates.sh index b98b9161..83b64d3d 100755 --- a/src/test/bash/create_certificates.sh +++ b/src/test/bash/create_certificates.sh @@ -4,6 +4,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CA_DIR=work/ca KEYSTORE_FILE=work/keystore.jks CLIENT_CERT_KEYSTORE=work/client-cert.jks +RUNS_ON_WINDOWS_OS=false + +if [[ -n $WSL_DISTRO_NAME ]]; then + RUNS_ON_WINDOWS_OS=true + echo "[INFO] Script runs on Windows Subsystem for Linux" +fi if [[ -d work/ca ]] ; then rm -Rf ${CA_DIR} @@ -25,7 +31,11 @@ fi KEYTOOL=keytool if [ ! -x "${KEYTOOL}" ] ; then - KEYTOOL=${JAVA_HOME}/bin/keytool + if [ RUNS_ON_WINDOWS_OS ] ; then + KEYTOOL=${JAVA_HOME}/bin/keytool.exe + else + KEYTOOL=${JAVA_HOME}/bin/keytool + fi fi if [ ! -x "${KEYTOOL}" ] ; then @@ -112,15 +122,15 @@ openssl ca -config ${DIR}/openssl.cnf \ -in ${CA_DIR}/csr/client.csr.pem \ -out ${CA_DIR}/certs/client.cert.pem -echo "[INFO] Creating PKCS12 file with client certificate" +echo "[INFO] Creating PKCS12 file with client certificate" openssl pkcs12 -export -clcerts \ -in ${CA_DIR}/certs/client.cert.pem \ -inkey ${CA_DIR}/private/client.decrypted.key.pem \ -passout pass:changeit \ -out ${CA_DIR}/client.p12 -${KEYTOOL} -importcert -keystore ${KEYSTORE_FILE} -file ${CA_DIR}/certs/ca.cert.pem -noprompt -storepass changeit -${KEYTOOL} -importkeystore \ +"${KEYTOOL}" -importcert -keystore ${KEYSTORE_FILE} -file ${CA_DIR}/certs/ca.cert.pem -noprompt -storepass changeit +"${KEYTOOL}" -importkeystore \ -srckeystore ${CA_DIR}/client.p12 -srcstoretype PKCS12 -srcstorepass changeit\ -destkeystore ${CLIENT_CERT_KEYSTORE} -deststoretype JKS \ -noprompt -storepass changeit diff --git a/src/test/bash/start.sh b/src/test/bash/start.sh index d370cc98..42d7b620 100755 --- a/src/test/bash/start.sh +++ b/src/test/bash/start.sh @@ -12,4 +12,5 @@ pkill vault mkdir -p ${BASEDIR}/download ${BASEDIR}/src/test/bash/install_vault.sh ${BASEDIR}/src/test/bash/create_certificates.sh -${BASEDIR}/src/test/bash/local_run_vault.sh & +${BASEDIR}/src/test/bash/env.sh +${BASEDIR}/src/test/bash/local_run_vault.sh & \ No newline at end of file