Support initial setup with WSL.

- adjust bash scripts
- update readme
- update gitignore

Original pull request: gh-675
Closes gh-674
This commit is contained in:
Alex
2022-01-02 17:47:30 +01:00
committed by Mark Paluch
parent 56bab8395b
commit 73a3c13874
4 changed files with 39 additions and 8 deletions

12
.gitignore vendored
View File

@@ -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/

View File

@@ -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

View File

@@ -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

View File

@@ -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 &