diff --git a/op_test.sh b/op_test.sh index c44f036..f04784d 100755 --- a/op_test.sh +++ b/op_test.sh @@ -161,6 +161,11 @@ verb_off () ERSA_OUT=0 } +wait_sec () +{ + ( sleep 4 2>/dev/null ) || { ( ping -n 1 127.0.0.1 2>/dev/null ) && ping -n 3 127.0.0.1; } +} + setup () { newline 1 @@ -466,7 +471,7 @@ create_pki () REQ_name="s01" build_full show_cert - sleep 3 + wait_sec renew_cert show_cert revoke_cert @@ -487,7 +492,7 @@ create_pki () REQ_name="c01" build_full show_cert - sleep 3 + wait_sec renew_cert show_cert revoke_cert diff --git a/wop_test.bat b/wop_test.bat new file mode 100644 index 0000000..d0def59 --- /dev/null +++ b/wop_test.bat @@ -0,0 +1,36 @@ +@echo off + +IF "%1"=="/SL" (set SAVE_LAYOUT=1) ELSE set SAVE_LAYOUT=0 + +set SYS_ARCH=test +IF %PROCESSOR_ARCHITECTURE%==x86 set SYS_ARCH=win32 +IF %PROCESSOR_ARCHITECTURE%==x86_64 set SYS_ARCH=win64 +IF %PROCESSOR_ARCHITECTURE%==AMD64 set SYS_ARCH=win64 +IF %SYS_ARCH%==test ( + echo Fatal Error: Unknown PROCESSOR_ARCHITECTURE + set SYS_ARCH= + exit /B 1 ) + +set WORK_DIR=%cd% +mkdir %WORK_DIR%\easyrsa3\bin +copy %WORK_DIR%\distro\windows\bin\* %WORK_DIR%\easyrsa3\bin +copy %WORK_DIR%\distro\windows\%SYS_ARCH%\* %WORK_DIR%\easyrsa3\bin +copy %WORK_DIR%\distro\windows\EasyRSA-Start.bat %WORK_DIR%\easyrsa3\EasyRSA-Start.bat +PATH=%PATH%;%WORK_DIR%\easyrsa3\bin;C:\PROGRA~1\openssl + +cmd /C "easyrsa3\bin\sh.exe wop_test.sh" +IF ERRORLEVEL 0 ( + IF %SAVE_LAYOUT% EQU 0 ( + echo rmdir /S /Q %WORK_DIR%\easyrsa3\bin + rmdir /S /Q %WORK_DIR%\easyrsa3\bin + echo del /Q %WORK_DIR%\easyrsa3\EasyRSA-Start.bat + del /Q %WORK_DIR%\easyrsa3\EasyRSA-Start.bat + REM 'rm' because Windows really is that dumb, try it yourself (Microsoft are saboteurs) + echo rm %WORK_DIR%\easyrsa3\.rnd + rm %WORK_DIR%\easyrsa3\.rnd + ) ELSE echo NOTICE; Saved Layout +) ELSE echo Error occurred, no clean up + +set SAVE_LAYOUT= +set SYS_ARCH= + diff --git a/wop_test.sh b/wop_test.sh new file mode 100644 index 0000000..800102b --- /dev/null +++ b/wop_test.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# shellcheck disable=SC2161,SC1091 + +# This script is a frontend designed to create & launch a POSIX shell +# environment suitable for use with Easy-RSA. mksh/Win32 is used with this +# project; use with other POSIX shells for Windows may require modification to +# this wrapper script. + +cd easyrsa3 || { echo "ERROR: Cannot find easyrsa3 direcory"; exit 1; } + +setup_path="${EASYRSA:-$PWD}" +export PATH="$setup_path;$setup_path/bin;$PATH" +export HOME="$setup_path" + +# This prevents reading from a user's .mkshrc if they have one. +# A user who runs mksh for other purposes might have it +export ENV="/disable-env" + +# Verify required externals are present +extern_list="which awk cat cp mkdir printf rm" +for f in $extern_list; do + if ! which "${f}.exe" >/dev/null 2>&1; then + echo "" + echo "FATAL: EasyRSA Shell init is missing a required external file:" + echo " ${f}.exe" + echo " Your installation is incomplete and cannot function without the required" + echo " files." + echo "" + echo " Press enter to exit." + #shellcheck disable=SC2162 + read + exit 1 + fi +done + +# set_var is defined as any vars file needs it. +# This is the same as in easyrsa, but we _don't_ export +set_var() { + var="$1" + shift + value="$*" + eval "$var=\"\${$var-$value}\"" +} #=> set_var() + +# Check for a usable openssl bin, referencing vars if present +[ -r "vars" ] && EASYRSA_CALLER=1 . "vars" 2>/dev/null +if [ -z "$EASYRSA_OPENSSL" ] && ! which openssl.exe >/dev/null 2>&1; then + echo "WARNING: openssl isn't in your system PATH. The openssl binary must be" + echo " available in the PATH, defined in the 'vars' file, or defined in a" + echo " named environment variable. See README-Windows.txt for more info." +fi + +[ -f "$setup_path/easyrsa" ] || { + echo "Missing easyrsa script. Expected to find it at: $setup_path/easyrsa" + exit 2 +} + +# Set prompt and welcome message +export PS1=' +EasyRSA Shell +# ' +echo "" +echo "Welcome to the EasyRSA 3 Shell for Windows." +echo "Easy-RSA 3 is available under a GNU GPLv2 license." +echo "" +echo "Invoke './easyrsa' to call the program. Without commands, help is displayed." + +cd .. + +./op_test.sh -vv