knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-320: Simplify scripts for using Knox on windows.
Date Fri, 21 Mar 2014 16:17:21 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.4.0 73000f5f8 -> 8973d4d12


KNOX-320: Simplify scripts for using Knox on windows.


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/8973d4d1
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/8973d4d1
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/8973d4d1

Branch: refs/heads/v0.4.0
Commit: 8973d4d121d12435af08135700ca07129cd14c52
Parents: 73000f5
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Fri Mar 21 12:17:14 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Fri Mar 21 12:17:14 2014 -0400

----------------------------------------------------------------------
 .gitattributes                       |  19 ++
 gateway-release/home/bin/gateway.cmd | 253 +++++--------------------
 gateway-release/home/bin/gateway.xml |   4 +-
 gateway-release/home/bin/ldap.cmd    | 305 +++++++-----------------------
 gateway-release/home/bin/ldap.xml    |   2 +-
 5 files changed, 136 insertions(+), 447 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/8973d4d1/.gitattributes
----------------------------------------------------------------------
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..7afdf7f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,19 @@
+##########################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+*.cmd text eol=crlf

http://git-wip-us.apache.org/repos/asf/knox/blob/8973d4d1/gateway-release/home/bin/gateway.cmd
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/gateway.cmd b/gateway-release/home/bin/gateway.cmd
index bc41bbf..d0fb54b 100644
--- a/gateway-release/home/bin/gateway.cmd
+++ b/gateway-release/home/bin/gateway.cmd
@@ -1,229 +1,64 @@
 @REM
+
 @REM Licensed to the Apache Software Foundation (ASF) under one or more
+
 @REM contributor license agreements. See the NOTICE file distributed with
+
 @REM this work for additional information regarding copyright ownership.
+
 @REM The ASF licenses this file to You under the Apache License, Version 2.0
+
 @REM (the "License"); you may not use this file except in compliance with
+
 @REM the License. You may obtain a copy of the License at
+
 @REM
+
 @REM http://www.apache.org/licenses/LICENSE-2.0
+
 @REM
+
 @REM Unless required by applicable law or agreed to in writing, software
+
 @REM distributed under the License is distributed on an "AS IS" BASIS,
+
 @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
 @REM See the License for the specific language governing permissions and
+
 @REM limitations under the License.
+
 @REM
+
 @ECHO OFF
 
-@REM Knox PID
-SET PID=0
-
-@REM  Start, stop, status, clean or setup
-SET KNOX_LAUNCH_COMMAND=%1
-
-@REM  User Name for setup parameter
-SET KNOX_LAUNCH_USER="%USERNAME%"
-
-@REM start/stop script location
-SET KNOX_SCRIPT_DIR=%~dp0
-
-SET KNOX_HOME=%KNOX_SCRIPT_DIR:~0,-5%
-
-@REM App name
-SET KNOX_NAME=knox
-
-@REM The Knox's jar name
-SET KNOX_JAR=%KNOX_SCRIPT_DIR%gateway.jar
-
-@REM Name of PID file
-SET PID_DIR=%KNOX_HOME%\pids
-SEt PID_FILE=%PID_DIR%\.pid
-
-@REM Name of LOG/OUT/ERR file
-SET LOG_DIR=%KNOX_HOME%\logs
-SET OUT_FILE=%LOG_DIR%\.out
-SET ERR_FILE=%LOG_DIR%\.err
-
-:main 
-	IF "%1" =="start" (
-		CALL :knoxStart
-		GOTO :EOF
-	)
-
-	IF "%1"=="stop" (
-		CALL :knoxStop
-		GOTO :EOF
-	)	
-
-	IF "%1"=="status" (
-		CALL :knoxStatus
-	GOTO :EOF
-	)	
-
-	IF "%1"=="clean" (
-		CALL :knoxClean
-		GOTO :EOF
-	)
-	   
-	IF "%1"=="setup" (
-		CALL :setupEnv %KNOX_LAUNCH_USER%
-		GOTO :EOF	
-	)
-	IF "%1" =="help" (
-		CALL :printHelp
-		GOTO :EOF
-	)
-	ECHO "Usage: $0 {start|stop|status|clean|setup [USER_NAME]}\n"
-	goto :EOF
-
-:knoxStart 
-	call :createLogFiles
-	call :getPID
-	IF %ERRORLEVEL%==0  (
-		ECHO "Knox is already running with PID=%PID%.\n"
-		GOTO :EOF
-	) 
-	ECHO "Starting Knox "
-	DEL "%PID_FILE%"
-	start   javaw  -jar "%KNOX_JAR%">> "%OUT_FILE%" 2>>"%ERR_FILE%"
-	echo "getting pid"
-	rem for /f "tokens=2 delims=," %%A in ('tasklist -v /fo csv /nh /fi "WINDOWTITLE  eq KnoxGateway"')
do (
-	for /f "tokens=2 delims=," %%A in ('tasklist -v /fo csv /nh /fi "Imagename  eq javaw.exe"')
do (
-	  echo %%A>"%PID_FILE%"
-	)
-	CALL :getPID
-	CALL :knoxIsRunning %PID%
-	IF  %ERRORLEVEL%==0 (
-		ECHO "failed"
-		Exit /B 1
-	)
-	ECHO "succeeded with PID %PID%
-	Exit /B 0
-   
-@REM Removed the Knox PID file if Knox is not run
-:knoxClean 
-	CALL :getPID
-	CALL :knoxIsRunning %PID%
-	IF  %ERRORLEVEL%==0 (
-		CALL :deleteLogFiles
-		GOTO :EOF
-	) 
-	ECHO "Can't clean files. Knox is running with PID=%PID%"
-	Exit /B 1
-   
-:createLogFiles 
-	dir "%LOG_DIR%" >NUL 2>NUL
-	IF not %errorlevel% ==0 (  
-		ECHO "Can't find log dir" 
-	Exit /B %1
-	) 
-	dir "%OUT_FILE%" >NUL 2>NUL
-		IF not %errorlevel% ==0 (  
-		ECHO. 2>"%OUT_FILE%"
-	)
-	dir "%ERR_FILE%" >NUL 2>NUL
-	IF not %errorlevel% ==0 (  
-		ECHO. 2>"%ERR_FILE%"
-	)
-	Exit /B 0
-
-:getPID 
-	dir "%PID_DIR%" >NUL 2>NUL
-	IF NOT %ERRORLEVEL% ==0 (
-		ECHO "Can't find pid dir. "
-		Exit /B 1
-	)
-	dir  "%PID_FILE%" >NUL 2>NUL
-	IF NOT %ERRORLEVEL% ==0 (
-		SET PID=0
-		Exit /B 1
-	)	
-	SET /p PID=<"%PID_FILE%"
-	Exit /B 0
-
-:knoxIsRunning 
-	IF %1==0 (
-		Exit /B 0
-	)
-	tasklist /FI "PID eq %1" |find ":" > nul
-	IF  %ERRORLEVEL%==0 (
-		Exit /B 0
-	)
-	Exit /B 1
-
-:setDirPermission 
-	SET dirName=%1
-	SET uName=%2
-	dir %dirName% >NUL 2>NUL
-	IF NOT %ERRORLEVEL% ==0 ( 
-		ECHO "making dir" %dirName%
-		mkdir  %dirName% 
-	)
-	IF NOT %ERRORLEVEL% ==0 (
-		ECHO "Can't access or create %dirName%
-		Exit /B %1
-	)	
-	GOTO :EOF
-
-:knoxStop {
-	echo pid %PID%
-	call   :getPID
-	call :knoxIsRunning %PID%
-	IF  %ERRORLEVEL% ==0 (
-		echo "Knox is not running."
-		GOTO :EOF
-	)
-	ECHO "Stopping Knox %PID% "
-	taskkill /F /PID  %PID%
-	IF NOT %ERRORLEVEL% ==0 (
-		ECHO  "failed. \n"
-		Exit /B 1
-	)
-	DEL /F "%PID_FILE%"
-	echo "succeeded.\n"
-	GOTO :EOF
-
-:knoxStatus {
-	CALL :getPID
-	IF not %ERRORLEVEL% ==0 (
-		echo "Knox is not running. No pid file found.\n"
-		GOTO :EOF
-	) 
-	CALL :knoxIsRunning %PID%
-	IF %ERRORLEVEL% ==1 (
-		echo "knox is running with PID=%PID%.\n"
-		Exit /B 1
-	)
-	ECHO "is not running.\n"
-	GOTO :EOF
-
-:deleteLogFiles 
-	DEL /F /Q "%PID_FILE%" 
-	ECHO "Removed the Knox PID file: %PID_FILE%"
-	DEL /F /Q "%OUT_FILE%"
-	ECHO "Removed the Knox OUT file: %OUT_FILE%"
-	DEL /F  /Q "%ERR_FILE%"
-	ECHO "Removed the Knox ERR file: %ERR_FILE%"
-	GOTO :EOF
-
-:setupEnv 
-	SET uName=%1
-	IF [%uName%]==[""] (
-		uName="%USERNAME%" 
-	)  	
-	CALL  :setDirPermission "%PID_DIR%" %uName%
-	CALL  :setDirPermission "%LOG_DIR%" %uName%
-	java -DGATEWAY_HOME="%KNOX_HOME%" -jar "%KNOX_JAR%" -persist-master -nostart
-	GOTO :EOF
-
-:printHelp 
-	java -jar "%KNOX_JAR%" -help
-	GOTO :EOF
-	
-
-
-
- 
 
 
+REM Start/stop script location
+
+SET APP_BIN_DIR=%~dp0
+
+
+
+REM The app's jar name
+
+SET APP_JAR=%APP_BIN_DIR%gateway.jar
+
+
+
+if not exist "%JAVA_HOME%"\bin\java.exe (
+
+  echo Error: JAVA_HOME is incorrectly set.
+
+  exit /B 1
+
+)
+set JAVA="%JAVA_HOME%"\bin\java
+
+
+
+"%JAVA%" -jar "%APP_JAR%
+
+"
+
+exit /B 0

http://git-wip-us.apache.org/repos/asf/knox/blob/8973d4d1/gateway-release/home/bin/gateway.xml
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/gateway.xml b/gateway-release/home/bin/gateway.xml
index 9ead1d4..7f1a4e9 100644
--- a/gateway-release/home/bin/gateway.xml
+++ b/gateway-release/home/bin/gateway.xml
@@ -18,7 +18,7 @@
 <service>
   <id>knox</id>
   <name>knox</name>
-  <description>This service runs the Knox Gateway</description>
+  <description>This service runs the Knox Gateway.</description>
   <executable>"cmd"</executable>
-  <arguments> /c gateway.cmd start </arguments>
+  <arguments> /c gateway.cmd </arguments>
 </service>

http://git-wip-us.apache.org/repos/asf/knox/blob/8973d4d1/gateway-release/home/bin/ldap.cmd
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/ldap.cmd b/gateway-release/home/bin/ldap.cmd
index ec67c9c..9132856 100644
--- a/gateway-release/home/bin/ldap.cmd
+++ b/gateway-release/home/bin/ldap.cmd
@@ -1,244 +1,79 @@
+@REM
+
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+
+@REM contributor license agreements. See the NOTICE file distributed with
+
+@REM this work for additional information regarding copyright ownership.
+
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+
+@REM (the "License"); you may not use this file except in compliance with
+
+@REM the License. You may obtain a copy of the License at
+
+@REM
+
+@REM http://www.apache.org/licenses/LICENSE-2.0
+
+@REM
+
+@REM Unless required by applicable law or agreed to in writing, software
+
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+@REM See the License for the specific language governing permissions and
+
+@REM limitations under the License.
+
+@REM
+
 @ECHO OFF
-REM  Licensed to the Apache Software Foundation (ASF) under one or more
-REM  contributor license agreements.  See the NOTICE file distributed with
-REM  this work for additional information regarding copyright ownership.
-REM  The ASF licenses this file to You under the Apache License, Version 2.0
-REM  (the "License"); you may not use this file except in compliance with
-REM  the License.  You may obtain a copy of the License at
-REM
-REM     http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM  distributed under the License is distributed on an "AS IS" BASIS,
-REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM  See the License for the specific language governing permissions and
-REM  limitations under the License.
-
-REM App name
-SET APP_LABEL=LDAP
-
-REM App name
-SET APP_NAME=ldap
-
-REM App name
-SET APP_JAR_NAME=ldap.jar
-
-REM start/stop script location
-SET APP_BIN_DIR=%~dp0
 
-REM The app's jar name
-SET APP_JAR=%APP_BIN_DIR%%APP_JAR_NAME%
+
 
 REM  The app's home dir
+
 SET APP_HOME_DIR=%APP_BIN_DIR:~0,-5%
 
+
+
 REM The apps home dir
+
 SET APP_CONF_DIR=%APP_HOME_DIR%\conf
 
-REM The app's log dir
-SET APP_LOG_DIR=%APP_HOME_DIR%\logs
-
-REM The app's Log4j options
-SET APP_LOG_OPTS=
-
-REM The app's memory options
-SET APP_MEM_OPTS=
-
-REM The app's debugging options
-SET APP_DBG_OPTS==
-
-REM Start, stop, status, clean
-SET APP_LAUNCH_COMMAND=%1
-
-REM The app's PID
-SET APP_PID=0
-
-
-REM The name of the PID file
-SET APP_PID_DIR=%APP_HOME_DIR%\pids
-SET APP_PID_FILE=%APP_PID_DIR%\%APP_NAME%.pid
-
-REM Name of LOG/OUT/ERR file
-SET APP_OUT_FILE=%APP_LOG_DIR%\%APP_NAME%.out
-SET APP_ERR_FILE=%APP_LOG_DIR%\%APP_NAME%.err
-
-REM The start wait time
-SET APP_START_WAIT_TIME=2
-
-REM  The kill wait time limit
-SET APP_KILL_WAIT_TIME=10
-
-REM Setup the common environment  
-REM . $APP_BIN_DIR/knox-env.sh
-
-:main 
-	IF "%1" =="start" (
-		CALL :appStart
-		GOTO :EOF
-	)
-
-	IF "%1"=="stop" (
-		CALL :appStop
-		GOTO :EOF
-	)	
-
-	IF "%1"=="status" (
-		CALL :appStatus
-	GOTO :EOF
-	)	
-
-	IF "%1"=="clean" (
-		CALL :appClean
-		GOTO :EOF
-	)
-	   
-	IF "%1" =="help" (
-		CALL :printHelp
-		GOTO :EOF
-	)
-	ECHO "Usage: %1 {start|stop|status|clean|setup [USER_NAME]}"
-	goto :EOF
-
-:appStart 
-   call :createLogFiles
-   call :getPID 
-   	IF %ERRORLEVEL%==0  (
-		ECHO "%APP_LABEL% is already running with PID=%APP_PID%.\n"
-		GOTO :EOF
-	) 
-   
-   ECHO "Starting %APP_LABEL% "
-   
-   DEL "%APP_PID_FILE%"
-   
-   start   javaw  %APP_MEM_OPTS% %APP_DBG_OPT% %APP_LOG_OPTS%  -jar  "%APP_JAR%"  "%APP_CONF_DIR%">>
"%APP_OUT_FILE%" 2>>"%APP_ERR_FILE%"
-   for /f "tokens=2 delims=," %%A in ('tasklist -v /fo csv /nh /fi "Imagename  eq javaw.exe"')
do (
-	echo %%A>"%APP_PID_FILE%"
-	)
-	CALL :getPID
-	echo "pid=%APP_PID%
-	Set i=0
-	: start
-	CALL :appIsRunning %APP_PID%
-	IF  %ERRORLEVEL%==0 (
-		 GOTO :break      
-	)
-	IF %i% leq %APP_START_WAIT_TIME% (
-    ping 224.244.244.244 -n 1 -w 1 > nul 
-    set /a i=%i%+1
-    GOTO :start	
-	 )
-	:break
-	CALL :appIsRunning %APP_PID%
-	IF  %ERRORLEVEL%==0 (
-		ECHO "failed"
-		DEL /F /Q "%APP_PID_FILE%" 
-		Exit /B 1
-	)
-	ECHO "succeeded with PID %APP_PID%
-	Exit /B 0
-
-: appStop 
-	echo pid %APP_PID%
-	call   :getPID
-	call :appIsRunning %APP_PID%
-	IF  %ERRORLEVEL% ==0 (
-		echo "%APP_NAME% is not running."
-		GOTO :EOF
-	)
-	ECHO "Stopping %APP_NAME% %APP_PID% "
-	taskkill /F /PID  %APP_PID%
-	IF NOT %ERRORLEVEL% ==0 (
-		ECHO  "failed. \n"
-		Exit /B 1
-	)
-	DEL /F "%APP_PID_FILE%"
-	echo "succeeded.\n"
-	GOTO :EOF
-
-:appStatus 
-   
-  CALL :getPID
-	IF not %ERRORLEVEL% ==0 (
-		echo " %APP_LABEL% is not running. No pid file found.\n"
-		GOTO :EOF
-	) 
-	CALL :appIsRunning %APP_PID%
-	IF %ERRORLEVEL% ==1 (
-		echo " %APP_LABEL% is running with PID=%APP_PID%.\n"
-		Exit /B 1
-	)
-	ECHO "%APP_LABEL% is not running.\n"
-	GOTO :EOF
-	
-:appClean 
-
-	CALL :getPID
-	CALL :appIsRunning %APP_PID%
-	IF  %ERRORLEVEL%==0 (
-		CALL :deleteLogFiles
-		GOTO :EOF
-	) 
-	ECHO "Can't clean files. %APP_LABEL% is running with PID=%APP_PID%"
-	Exit /B 1
-
-:getPID 
-	dir "%APP_PID_DIR%" >NUL 2>NUL
-	IF NOT %ERRORLEVEL% ==0 (
-		ECHO "Can't find pid dir. "
-		Exit /B 1
-	)
-	dir  "%APP_PID_FILE%" >NUL 2>NUL
-	IF NOT %ERRORLEVEL% ==0 (
-		SET APP_PID=0
-		Exit /B 1
-	)	
-	SET /p APP_PID=<"%APP_PID_FILE%"
-	Exit /B 0
-	
-:appIsRunning 
-	IF %1==0 (
-		Exit /B 0
-	)
-	tasklist /FI "PID eq %1" |find ":" > nul
-	IF  %ERRORLEVEL%==0 (
-		Exit /B 0
-	)
-	Exit /B 1
-
-:createLogFiles 
-	dir "%APP_LOG_DIR%" >NUL 2>NUL
-	IF not %errorlevel% ==0 (  
-		ECHO "Can't find log dir" 
-	Exit /B %1
-	) 
-	dir "%APP_OUT_FILE%" >NUL 2>NUL
-		IF not %errorlevel% ==0 (  
-		ECHO. 2>"%APP_OUT_FILE%"
-	)
-	dir "%APP_ERR_FILE%" >NUL 2>NUL
-	IF not %errorlevel% ==0 (  
-		ECHO. 2>"%APP_ERR_FILE%"
-	)
-	Exit /B 0
-	
-:deleteLogFiles 
-	DEL /F /Q "%APP_PID_FILE%" 
-	ECHO "Removed the  PID file: %APP_PID_FILE%"
-	DEL /F /Q "%APP_OUT_FILE%"
-	ECHO "Removed the OUT file: %APP_OUT_FILE%"
-	DEL /F  /Q "%APP_ERR_FILE%"
-	ECHO "Removed the  ERR file: %APP_ERR_FILE%"
-	GOTO :EOF
-
-:printHelp 
-	ECHO "Usage: %1 {start|stop|status|clean}"
-	GOTO :EOF
-	
-
-
-
-  
-
-
-- 
+
+
+REM Start/stop script location
+
+SET APP_BIN_DIR=%~dp0
+
+
+
+REM The app's jar name
+
+SET APP_JAR=%APP_BIN_DIR%ldap.jar
+
+
+
+if not exist "%JAVA_HOME%"\bin\java.exe (
+
+  echo Error: JAVA_HOME is incorrectly set.
+
+  exit /B 1
+
+)
+
+set JAVA="%JAVA_HOME%"\bin\java
+
+
+
+"%JAVA%" -jar "%APP_JAR%" "%APP_CONF_DIR%"
+
+
+
+exit /B 0
+
+

http://git-wip-us.apache.org/repos/asf/knox/blob/8973d4d1/gateway-release/home/bin/ldap.xml
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/ldap.xml b/gateway-release/home/bin/ldap.xml
index 68ce0e5..86a3581 100644
--- a/gateway-release/home/bin/ldap.xml
+++ b/gateway-release/home/bin/ldap.xml
@@ -20,5 +20,5 @@
   <name>knox-demo-ldap</name>
   <description>This service runs the Knox demonstration LDAP server.</description>
   <executable>"cmd"</executable>
-  <arguments> /c ldap.cmd</arguments>
+  <arguments> /c ldap.cmd </arguments>
 </service>


Mime
View raw message