From 0e6739e7c645ca909bfb87aa1ff4b82bdef8b096 Mon Sep 17 00:00:00 2001 From: Kristian Date: Mon, 19 Feb 2018 19:04:48 +0100 Subject: [PATCH] Modified ninja scripts for linux and windows --- dist/src/main/bin/export.bat | 27 ----- dist/src/main/bin/export.sh | 29 ----- dist/src/main/bin/import.bat | 27 ----- dist/src/main/bin/import.sh | 30 ----- dist/src/main/bin/keys.bat | 27 ----- dist/src/main/bin/keys.sh | 30 ----- dist/src/main/bin/ninja.bat | 228 +---------------------------------- dist/src/main/bin/ninja.sh | 114 +----------------- 8 files changed, 2 insertions(+), 510 deletions(-) delete mode 100644 dist/src/main/bin/export.bat delete mode 100755 dist/src/main/bin/export.sh delete mode 100644 dist/src/main/bin/import.bat delete mode 100755 dist/src/main/bin/import.sh delete mode 100644 dist/src/main/bin/keys.bat delete mode 100755 dist/src/main/bin/keys.sh diff --git a/dist/src/main/bin/export.bat b/dist/src/main/bin/export.bat deleted file mode 100644 index 6f601f7ddaf..00000000000 --- a/dist/src/main/bin/export.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off - -setlocal - -set "BIN_DIR=%~dp0" - -set "EXECUTABLE=%BIN_DIR%\ninja.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" export %CMD_LINE_ARGS% - -:end \ No newline at end of file diff --git a/dist/src/main/bin/export.sh b/dist/src/main/bin/export.sh deleted file mode 100755 index 1d3bc1e6e33..00000000000 --- a/dist/src/main/bin/export.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -SCRIPT_PATH=$(cd $(dirname "$0") && pwd -P)/ - -# resolve links - $0 may be a softlink -PRG="$0" - -while [ -h "$PRG" ]; do -ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`/"$link" - fi -done - -# Get standard environment variable -PRGDIR=`dirname "$PRG"` -EXECUTABLE=ninja.sh - - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi - -exec "$PRGDIR"/"$EXECUTABLE" export "$@" diff --git a/dist/src/main/bin/import.bat b/dist/src/main/bin/import.bat deleted file mode 100644 index d55d0d9b74e..00000000000 --- a/dist/src/main/bin/import.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off - -setlocal - -set "BIN_DIR=%~dp0" - -set "EXECUTABLE=%BIN_DIR%\ninja.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" import %CMD_LINE_ARGS% - -:end diff --git a/dist/src/main/bin/import.sh b/dist/src/main/bin/import.sh deleted file mode 100755 index d406c401f73..00000000000 --- a/dist/src/main/bin/import.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -SCRIPT_PATH=$(cd $(dirname "$0") && pwd -P)/ - -# resolve links - $0 may be a softlink -PRG="$0" - -while [ -h "$PRG" ]; do -ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`/"$link" - fi -done - -# Get standard environment variable -PRGDIR=`dirname "$PRG"` -EXECUTABLE=ninja.sh - - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi - -exec "$PRGDIR"/"$EXECUTABLE" import "$@" - diff --git a/dist/src/main/bin/keys.bat b/dist/src/main/bin/keys.bat deleted file mode 100644 index cdddbaae480..00000000000 --- a/dist/src/main/bin/keys.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off - -setlocal - -set "BIN_DIR=%~dp0" - -set "EXECUTABLE=%BIN_DIR%\ninja.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" keys %CMD_LINE_ARGS% - -:end \ No newline at end of file diff --git a/dist/src/main/bin/keys.sh b/dist/src/main/bin/keys.sh deleted file mode 100755 index eaca540f9b8..00000000000 --- a/dist/src/main/bin/keys.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -SCRIPT_PATH=$(cd $(dirname "$0") && pwd -P)/ - -# resolve links - $0 may be a softlink -PRG="$0" - -while [ -h "$PRG" ]; do -ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`/"$link" - fi -done - -# Get standard environment variable -PRGDIR=`dirname "$PRG"` -EXECUTABLE=ninja.sh - - if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "The file is absent or does not have execute permission" - echo "This file is needed to run this program" - exit 1 - fi - -exec "$PRGDIR"/"$EXECUTABLE" keys "$@" - diff --git a/dist/src/main/bin/ninja.bat b/dist/src/main/bin/ninja.bat index 7d043c3377d..77c533d4bb8 100644 --- a/dist/src/main/bin/ninja.bat +++ b/dist/src/main/bin/ninja.bat @@ -3,204 +3,6 @@ setlocal set "BIN_DIR=%~dp0" -set "COMMAND=%~1" - -:parse - -if "%~1"=="" goto endparse -if "%~1"=="-c" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="--charset" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="-h" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="--help" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="-m" ( - echo INFO: midpoint.home set by default -) -if "%~1"=="--midpoint-home" ( - echo INFO: midpoint.home set by default -) -if "%~1"=="-p" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="--password" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="-P" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="--password-ask" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="-s" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="--silent" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="-U" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="--url" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="-u" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="--username" ( - set "OPTIONS=%OPTIONS% %~1 %~2" -) -if "%~1"=="-v" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="--verbose" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="-V" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="--version" ( - set "OPTIONS=%OPTIONS% %~1" -) -if "%~1"=="-f" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="--filter" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="-o" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="--oid" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="-O" ( - if "%COMMAND%"=="export" ( - echo INFO: Output file already set by default - ) - if "%COMMAND%"=="import" ( - echo INFO: Overwrite option already set by default - ) -) -if "%~1"=="--output" ( - if "%COMMAND%"=="export" ( - echo INFO: Output file already set by default - ) - if "%COMMAND%"=="import" ( - echo INFO: Overwrite option already set by default - ) -) -if "%~1"=="--overwrite" ( - if "%COMMAND%"=="export" ( - echo INFO: Output file already set by default - ) - if "%COMMAND%"=="import" ( - echo INFO: Overwrite option already set by default - ) -) -if "%~1"=="-r" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" - ) -) -if "%~1"=="--raw" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" - ) -) -if "%~1"=="-t" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="--type" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1 %~2" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" - ) -) -if "%~1"=="-z" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" - ) -) -if "%~1"=="--zip" ( - if "%COMMAND%"=="export" ( - set "EXP_OPTIONS=%EXP_OPTIONS% %~1" - ) - if "%COMMAND%"=="import" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" - ) -) -if "%~1"=="-e" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" -) -if "%~1"=="--allowUnencryptedValues" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1" -) -if "%~1"=="-i" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" -) -if "%~1"=="--input" ( - set "IMP_OPTIONS=%IMP_OPTIONS% %~1 %~2" -) -if "%~1"=="-k" ( - set "KEY_OPTIONS=%KEY_OPTIONS% %~1 %~2" -) -if "%~1"=="--key-password" ( - set "KEY_OPTIONS=%KEY_OPTIONS% %~1 %~2" -) -if "%~1"=="-K" ( - set "KEY_OPTIONS=%KEY_OPTIONS% %~1" -) -if "%~1"=="--key-password-ask" ( - set "KEY_OPTIONS=%KEY_OPTIONS% %~1" -) - -shift -goto parse - -:endparse rem if script for execution is in bin directory if exist "%BIN_DIR%\ninja.bat" goto okBoot @@ -236,42 +38,14 @@ echo Unable to start as MIDPOINT_HOME contains a semicolon (;) character goto end :homeNoSemicolon -For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) -For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a-%%b) rem ----- Execute The Requested Command --------------------------------------- echo Using MIDPOINT_HOME: "%MIDPOINT_HOME%" -set _EXECJAVA=%_RUNJAVA% - -if ""%COMMAND%"" == ""export"" goto doExport -if ""%COMMAND%"" == ""import"" goto doImport -if ""%COMMAND%"" == ""keys"" goto doKeys - -:doExport -shift -goto execExport - -:doImport -shift -goto execImport - -:doKeys -shift -goto execKeys - -:execExport -start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" export %EXP_OPTIONS% -O "export.%mydate%_%mytime%.xml" +start /b java -jar "%cd%\lib\ninja.jar" -m "%MIDPOINT_HOME%" %* goto end -:execImport -start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" import %IMP_OPTIONS% -O -goto end - -:execKeys -start /b java -jar "%cd%\lib\ninja.jar" %OPTIONS% -m "%MIDPOINT_HOME%" keys %KEY_OPTIONS% -goto end :end diff --git a/dist/src/main/bin/ninja.sh b/dist/src/main/bin/ninja.sh index f6aa6fb4f30..489f6190762 100755 --- a/dist/src/main/bin/ninja.sh +++ b/dist/src/main/bin/ninja.sh @@ -50,119 +50,7 @@ else _RUNJAVA="$JAVA_HOME"/bin/java fi -DATE=`date '+%Y-%m-%d-%H:%M:%S'` -command="$1" - -OPTIONS="" -EXP_OPTIONS="" - -while [ "$2" != "" ]; -do -case $2 in - -c|--charset) - OPTIONS+="$2 $3 " - ;; - -h|--help) - OPTIONS+="$2 " - ;; - -m|--midpoint-home) - echo "INFO: midpoint.home set by default" - ;; - -p|--password) - OPTIONS+="$2 $3 " - ;; - -P|--password-ask) - OPTIONS+="$2 $3 " - ;; - -s|--silent) - OPTIONS+="$2 " - ;; - -U|--url) - OPTIONS+="$2 $3 " - ;; - -u|--username) - OPTIONS+="$2 $3 " - ;; - -v|--verbose) - OPTIONS+="$2 " - ;; - -V|--version) - OPTIONS+="$2 " - ;; - -f|--filter) - if [ "$command" = "export" ] ; then - EXP_OPTIONS+="$2 $3 " - fi - if [ "$command" = "import" ] ; then - IMP_OPTIONS+="$2 $3 " - fi - ;; - -o|--oid) - if [ "$command" = "export" ] ; then - EXP_OPTIONS+="$2 $3 " - fi - if [ "$command" = "import" ] ; then - IMP_OPTIONS+="$2 $3 " - fi - ;; - -O|--output|--overwrite) - if [ "$command" = "export" ] ; then - echo "INFO: Output file already set by default" - fi - if [ "$command" = "import" ] ; then - echo "INFO: Overwrite option already set by default" - fi - ;; - -r|--raw) - if [ "$command" = "export" ] ; then - EXP_OPTIONS+="$2 " - fi - if [ "$command" = "import" ] ; then - IMP_OPTIONS+="$2 " - fi - ;; - -t|--type) - if [ "$command" = "export" ] ; then - EXP_OPTIONS+="$2 $3 " - fi - if [ "$command" = "import" ] ; then - IMP_OPTIONS+="$2 $3 " - fi - ;; - -z|--zip) - if [ "$command" = "export" ] ; then - EXP_OPTIONS+="$2 " - fi - if [ "$command" = "import" ] ; then - IMP_OPTIONS+="$2 " - fi - ;; - -e|--allowUnencryptedValues) - IMP_OPTIONS+="$2 " - shift - ;; - -i|--input) - IMP_OPTIONS+="$2 $3 " - ;; - -k|--key-password) - KEY_OPTIONS+="$2 $3 " - ;; - -K|--key-password-ask) - KEY_OPTIONS+="$2 " - ;; -esac - -shift -done +exec "$_RUNJAVA" -jar $SCRIPT_PATH../lib/ninja.jar -m $MIDPOINT_HOME $@ -if [ "$command" = "export" ] ; then - exec "$_RUNJAVA" -jar $SCRIPT_PATH../lib/ninja.jar $OPTIONS -m $MIDPOINT_HOME export $EXP_OPTIONS -O "export.$DATE.xml" -fi -if [ "$command" = "import" ] ; then - exec "$_RUNJAVA" -jar $SCRIPT_PATH../lib/ninja.jar $OPTIONS -m $MIDPOINT_HOME import $IMP_OPTIONS -O -fi -if [ "$command" = "keys" ] ; then - exec "$_RUNJAVA" -jar $SCRIPT_PATH../lib/ninja.jar $OPTIONS -m $MIDPOINT_HOME keys $KEY_OPTIONS -fi